|
1 |
| -ARG CONTAINER_VERSION=1.19.2-alpine |
| 1 | +FROM quay.io/bedrock/alpine:3.19.1 AS base |
2 | 2 |
|
3 |
| -# builder used to create a dynamic spnego auth module |
4 |
| -# https://gist.github.com/hermanbanken/96f0ff298c162a522ddbba44cad31081 |
5 |
| -FROM nginx:${CONTAINER_VERSION} AS builder |
| 3 | +RUN apk add \ |
| 4 | + nginx \ |
| 5 | + python3 \ |
| 6 | + --no-cache |
6 | 7 |
|
7 |
| -ENV SPNEGO_AUTH_COMMIT_ID=72c8ee04c81f929ec84d5a6d126f789b77781a8c |
| 8 | +FROM base AS builder |
8 | 9 |
|
9 |
| -RUN set -x && \ |
10 |
| - NGINX_VERSION="$( nginx -v 2>&1 | awk -F/ '{print $2}' )" && \ |
11 |
| - NGINX_CONFIG="$( nginx -V 2>&1 | sed -n -e 's/^.*arguments: //p' )" && \ |
12 |
| - wget "http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz" -O nginx.tar.gz && \ |
13 |
| - wget https://github.com/stnoonan/spnego-http-auth-nginx-module/archive/${SPNEGO_AUTH_COMMIT_ID}.tar.gz -O spnego-http-auth.tar.gz && \ |
14 |
| - apk add --no-cache --virtual .build-deps \ |
| 10 | +RUN apk add \ |
15 | 11 | gcc \
|
| 12 | + gd-dev \ |
| 13 | + geoip-dev \ |
| 14 | + krb5-dev \ |
16 | 15 | libc-dev \
|
| 16 | + libffi-dev \ |
| 17 | + libmaxminddb-dev \ |
| 18 | + libxslt-dev \ |
| 19 | + linux-headers \ |
17 | 20 | make \
|
| 21 | + openssl \ |
| 22 | + openssl-dev \ |
18 | 23 | pcre-dev \
|
| 24 | + perl-dev \ |
| 25 | + python3-dev \ |
19 | 26 | zlib-dev \
|
20 |
| - krb5-dev \ |
21 |
| - && \ |
22 |
| - mkdir /usr/src && \ |
23 |
| - tar -xzC /usr/src -f nginx.tar.gz && \ |
24 |
| - tar -xzvf spnego-http-auth.tar.gz && \ |
25 |
| - SPNEGO_AUTH_DIR="$( pwd )/spnego-http-auth-nginx-module-${SPNEGO_AUTH_COMMIT_ID}" && \ |
26 |
| - cd "/usr/src/nginx-${NGINX_VERSION}" && \ |
27 |
| - ./configure --with-compat "${NGINX_CONFIG}" --add-dynamic-module="${SPNEGO_AUTH_DIR}" && \ |
28 |
| - make modules && \ |
29 |
| - cp objs/ngx_*_module.so /usr/lib |
| 27 | + --no-cache |
30 | 28 |
|
31 |
| -# Create the actual httptester container |
32 |
| -FROM nginx:${CONTAINER_VERSION} |
| 29 | +COPY extract_nginx_options.py /usr/src/extract_nginx_options.py |
| 30 | +COPY build_spnego_module.sh /usr/src/build_spnego_module.sh |
33 | 31 |
|
34 |
| -ADD constraints.txt /root/constraints.txt |
35 |
| -ADD krb5.conf /root/krb5.conf |
36 |
| -COPY --from=builder /usr/lib/ngx_*_module.so /usr/lib/nginx/modules/ |
| 32 | +RUN /usr/src/build_spnego_module.sh |
37 | 33 |
|
38 |
| -ENV PYTHONDONTWRITEBYTECODE=1 |
| 34 | +ADD requirements.txt /usr/src/requirements.txt |
| 35 | +ADD constraints.txt /usr/src/constraints.txt |
39 | 36 |
|
40 |
| -# The following packages are required to get httpbin/brotlipy/cffi installed |
41 |
| -# openssl-dev python3-dev libffi-dev gcc libstdc++ make musl-dev |
42 |
| -# Symlinking /usr/lib/libstdc++.so.6 to /usr/lib/libstdc++.so is specifically required for brotlipy |
43 |
| -RUN set -x && \ |
44 |
| - apk add --no-cache \ |
45 |
| - ca-certificates \ |
46 |
| - gcc \ |
47 |
| - krb5-libs \ |
48 |
| - krb5-server \ |
49 |
| - libffi-dev \ |
50 |
| - libstdc++ \ |
51 |
| - make \ |
52 |
| - musl-dev \ |
53 |
| - openssl \ |
54 |
| - openssl-dev \ |
55 |
| - py3-pip \ |
56 |
| - py3-setuptools \ |
57 |
| - py3-wheel \ |
58 |
| - python3-dev \ |
59 |
| - && \ |
60 |
| - update-ca-certificates && \ |
61 |
| - ln -s /usr/lib/libstdc++.so.6 /usr/lib/libstdc++.so && \ |
62 |
| - mkdir -p /root/ca/certs /root/ca/private /root/ca/newcerts && \ |
63 |
| - mkdir -p /root/ca2/certs /root/ca2/private /root/ca2/newcerts && \ |
64 |
| - echo 1000 > /root/ca/serial && \ |
65 |
| - echo 1000 > /root/ca2/serial && \ |
66 |
| - touch /root/ca/index.txt && \ |
67 |
| - touch /root/ca2/index.txt && \ |
68 |
| - cp /etc/ssl/openssl.cnf /etc/ssl/openssl_ca2.cnf && \ |
69 |
| - sed -i 's/\.\/demoCA/\/root\/ca/g' /etc/ssl/openssl.cnf && \ |
70 |
| - sed -i 's/\.\/demoCA/\/root\/ca2/g' /etc/ssl/openssl_ca2.cnf && \ |
71 |
| - openssl req -new -x509 -days 3650 -nodes -extensions v3_ca -keyout /root/ca/private/cakey.pem -out /root/ca/cacert.pem \ |
72 |
| - -subj "/C=US/ST=North Carolina/L=Durham/O=Ansible/CN=ansible.http.tests" && \ |
73 |
| - openssl req -new -x509 -days 3650 -nodes -extensions v3_ca -keyout /root/ca2/private/cakey.pem -out /root/ca2/cacert.pem \ |
74 |
| - -subj "/C=US/ST=North Carolina/L=Durham/O=Ansible/CN=ca2.ansible.http.tests" && \ |
75 |
| - openssl req -new -nodes -out /root/ca/ansible.http.tests-req.pem -keyout /root/ca/private/ansible.http.tests-key.pem \ |
76 |
| - -subj "/C=US/ST=North Carolina/L=Durham/O=Ansible/CN=ansible.http.tests" && \ |
77 |
| - yes | openssl ca -config /etc/ssl/openssl.cnf -days 3650 -out /root/ca/ansible.http.tests-cert.pem -infiles /root/ca/ansible.http.tests-req.pem && \ |
78 |
| - openssl req -new -nodes -out /root/ca/sni1.ansible.http.tests-req.pem -keyout /root/ca/private/sni1.ansible.http.tests-key.pem -config /etc/ssl/openssl.cnf \ |
79 |
| - -subj "/C=US/ST=North Carolina/L=Durham/O=Ansible/CN=sni1.ansible.http.tests" && \ |
80 |
| - yes | openssl ca -config /etc/ssl/openssl.cnf -days 3650 -out /root/ca/sni1.ansible.http.tests-cert.pem -infiles /root/ca/sni1.ansible.http.tests-req.pem && \ |
81 |
| - openssl req -new -nodes -out /root/ca/sni2.ansible.http.tests-req.pem -keyout /root/ca/private/sni2.ansible.http.tests-key.pem -config /etc/ssl/openssl.cnf \ |
82 |
| - -subj "/C=US/ST=North Carolina/L=Durham/O=Ansible/CN=sni2.ansible.http.tests" && \ |
83 |
| - yes | openssl ca -config /etc/ssl/openssl.cnf -days 3650 -out /root/ca/sni2.ansible.http.tests-cert.pem -infiles /root/ca/sni2.ansible.http.tests-req.pem && \ |
84 |
| - openssl req -new -nodes -out /root/ca/client.ansible.http.tests-req.pem -keyout /root/ca/private/client.ansible.http.tests-key.pem -config /etc/ssl/openssl.cnf \ |
85 |
| - -subj "/C=US/ST=North Carolina/L=Durham/O=Ansible/CN=client.ansible.http.tests" && \ |
86 |
| - yes | openssl ca -config /etc/ssl/openssl.cnf -days 3650 -out /root/ca/client.ansible.http.tests-cert.pem -infiles /root/ca/client.ansible.http.tests-req.pem && \ |
87 |
| - openssl req -new -nodes -out /root/ca2/self-signed.ansible.http.tests-req.pem -keyout /root/ca2/private/self-signed.ansible.http.tests-key.pem -config /etc/ssl/openssl_ca2.cnf \ |
88 |
| - -subj "/C=US/ST=North Carolina/L=Durham/O=Ansible/CN=self-signed.ansible.http.tests" && \ |
89 |
| - yes | openssl ca -config /etc/ssl/openssl_ca2.cnf -days 3650 -out /root/ca2/self-signed.ansible.http.tests-cert.pem -infiles /root/ca2/self-signed.ansible.http.tests-req.pem && \ |
90 |
| - cp /root/ca/cacert.pem /usr/share/nginx/html/cacert.pem && \ |
91 |
| - cp /root/ca2/cacert.pem /usr/share/nginx/html/ca2cert.pem && \ |
92 |
| - cp /root/ca/client.ansible.http.tests-cert.pem /usr/share/nginx/html/client.pem && \ |
93 |
| - cp /root/ca/private/client.ansible.http.tests-key.pem /usr/share/nginx/html/client.key && \ |
94 |
| - chmod 644 /usr/share/nginx/html/* && \ |
95 |
| - pip3 install --no-cache-dir --no-compile -c /root/constraints.txt gunicorn httpbin && \ |
96 |
| - apk del openssl-dev py3-pip py3-wheel python3-dev libffi-dev gcc libstdc++ make musl-dev && \ |
97 |
| - rm -rf /root/.cache/pip && \ |
98 |
| - find /usr/lib/python3.8 -type f -regex ".*\.py[co]" -delete && \ |
99 |
| - find /usr/lib/python3.8 -type d -name "__pycache__" -delete && \ |
100 |
| - echo "Microsoft Rulz" > /usr/share/nginx/html/gssapi && \ |
101 |
| - echo -e "load_module /usr/lib/nginx/modules/ngx_http_auth_spnego_module.so;\n$( cat /etc/nginx/nginx.conf )" > /etc/nginx/nginx.conf && \ |
102 |
| - cp /root/krb5.conf /etc/krb5.conf && \ |
103 |
| - PASSWORD="$( < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c30 )" && \ |
104 |
| - echo -e "${PASSWORD}\n${PASSWORD}" | /usr/sbin/kdb5_util create -r HTTP.TESTS && \ |
105 |
| - echo -e "*/[email protected]\t*" > /var/lib/krb5kdc/kadm5.acl && \ |
106 |
| - kadmin.local -q "addprinc -randkey HTTP/[email protected]" && \ |
107 |
| - kadmin.local -q "addprinc -randkey HTTP/[email protected]" && \ |
108 |
| - kadmin.local -q "ktadd -k /etc/nginx.keytab HTTP/[email protected]" && \ |
109 |
| - kadmin.local -q "ktadd -k /etc/nginx.keytab HTTP/[email protected]" && \ |
110 |
| - chmod 660 /etc/nginx.keytab && \ |
111 |
| - chown root:nginx /etc/nginx.keytab |
| 37 | +RUN python3 -m venv /usr/share/nginx/venv/ |
| 38 | +RUN /usr/share/nginx/venv/bin/pip install --no-cache-dir --no-compile -r /usr/src/requirements.txt -c /usr/src/constraints.txt |
| 39 | +RUN cd /usr/share/nginx/venv/lib/python*/site-packages/ && rm -rf pip pip-* setuptools setuptools-* |
| 40 | + |
| 41 | +ADD create_certs.sh /usr/src/create_certs.sh |
| 42 | +RUN /usr/src/create_certs.sh |
| 43 | + |
| 44 | +FROM base AS output |
| 45 | + |
| 46 | +COPY --from=builder /usr/lib/nginx/modules/ /usr/lib/nginx/modules/ |
| 47 | +COPY --from=builder /usr/share/nginx/venv/ /usr/share/nginx/venv/ |
| 48 | +COPY --from=builder /usr/src/nginx.conf /etc/nginx/nginx.conf |
| 49 | +COPY --from=builder /root/ca/ /root/ca/ |
| 50 | +COPY --from=builder /root/ca2/ /root/ca2/ |
| 51 | + |
| 52 | +ADD krb5.conf /usr/src/krb5.conf |
| 53 | +ADD configure_nginx.sh /usr/src/configure_nginx.sh |
| 54 | +RUN /usr/src/configure_nginx.sh |
112 | 55 |
|
113 | 56 | ADD services.sh /services.sh
|
114 |
| -ADD nginx.sites.conf /etc/nginx/conf.d/default.conf |
| 57 | +ADD nginx.sites.conf /etc/nginx/http.d/default.conf |
115 | 58 |
|
116 | 59 | EXPOSE 80 88 443 749
|
117 | 60 |
|
|
0 commit comments