|
| 1 | +FROM nginx:mainline-alpine |
| 2 | +MAINTAINER "cytopia" <cytopia@everythingcli.org> |
| 3 | + |
| 4 | +LABEL \ |
| 5 | + name="cytopia's nginx mainline image" \ |
| 6 | + image="devilbox/nginx-mainline" \ |
| 7 | + vendor="devilbox" \ |
| 8 | + license="MIT" |
| 9 | + |
| 10 | + |
| 11 | +### |
| 12 | +### Build arguments |
| 13 | +### |
| 14 | +ARG VHOST_GEN_GIT_REF=1.0.3 |
| 15 | +ARG WATCHERD_GIT_REF=v1.0.2 |
| 16 | +ARG CERT_GEN_GIT_REF=0.7 |
| 17 | + |
| 18 | +ENV BUILD_DEPS \ |
| 19 | + make \ |
| 20 | + wget |
| 21 | + |
| 22 | +ENV RUN_DEPS \ |
| 23 | + ca-certificates \ |
| 24 | + bash \ |
| 25 | + openssl \ |
| 26 | + py3-yaml \ |
| 27 | + shadow \ |
| 28 | + supervisor |
| 29 | + |
| 30 | + |
| 31 | +### |
| 32 | +### Runtime arguments |
| 33 | +### |
| 34 | +ENV MY_USER=nginx |
| 35 | +ENV MY_GROUP=nginx |
| 36 | +ENV HTTPD_START="/usr/sbin/nginx" |
| 37 | +ENV HTTPD_RELOAD="nginx -s stop" |
| 38 | + |
| 39 | + |
| 40 | +### |
| 41 | +### Install required packages |
| 42 | +### |
| 43 | +RUN set -eux \ |
| 44 | + && apk add --no-cache \ |
| 45 | + ${BUILD_DEPS} \ |
| 46 | + ${RUN_DEPS} \ |
| 47 | + \ |
| 48 | + # Install vhost-gen |
| 49 | + && wget --no-check-certificate -O vhost-gen.tar.gz "https://github.com/devilbox/vhost-gen/archive/refs/tags/${VHOST_GEN_GIT_REF}.tar.gz" \ |
| 50 | + && tar xvfz vhost-gen.tar.gz \ |
| 51 | + && cd "vhost-gen-${VHOST_GEN_GIT_REF}" \ |
| 52 | + && make install \ |
| 53 | + && cd .. \ |
| 54 | + && rm -rf vhost*gen* \ |
| 55 | + \ |
| 56 | + # Install cert-gen |
| 57 | + && wget --no-check-certificate -O /usr/bin/ca-gen https://raw.githubusercontent.com/devilbox/cert-gen/${CERT_GEN_GIT_REF}/bin/ca-gen \ |
| 58 | + && wget --no-check-certificate -O /usr/bin/cert-gen https://raw.githubusercontent.com/devilbox/cert-gen/${CERT_GEN_GIT_REF}/bin/cert-gen \ |
| 59 | + && chmod +x /usr/bin/ca-gen \ |
| 60 | + && chmod +x /usr/bin/cert-gen \ |
| 61 | + \ |
| 62 | + # Install watcherd |
| 63 | + && wget --no-check-certificate -O /usr/bin/watcherd https://raw.githubusercontent.com/devilbox/watcherd/${WATCHERD_GIT_REF}/watcherd \ |
| 64 | + && chmod +x /usr/bin/watcherd \ |
| 65 | + \ |
| 66 | + # Clean-up |
| 67 | + && apk del \ |
| 68 | + ${BUILD_DEPS} |
| 69 | + |
| 70 | + |
| 71 | +### |
| 72 | +### Create directories |
| 73 | +### |
| 74 | +# /docker-entrypoint.d/10-ipv6* was added by nginx to do some IPv6 magic (which breaks the image) |
| 75 | +RUN set -eux \ |
| 76 | + && rm -rf /docker-entrypoint.d || true \ |
| 77 | + && mkdir -p /etc/httpd-custom.d \ |
| 78 | + && mkdir -p /etc/httpd/conf.d \ |
| 79 | + && mkdir -p /etc/httpd/vhost.d \ |
| 80 | + && mkdir -p /var/www/default/htdocs \ |
| 81 | + && mkdir -p /shared/httpd \ |
| 82 | + && chmod 0775 /shared/httpd \ |
| 83 | + && chown ${MY_USER}:${MY_GROUP} /shared/httpd |
| 84 | + |
| 85 | + |
| 86 | +### |
| 87 | +### Symlink Python3 to Python |
| 88 | +### |
| 89 | +RUN set -eux \ |
| 90 | + && ln -sf /usr/bin/python3 /usr/bin/python |
| 91 | + |
| 92 | + |
| 93 | +### |
| 94 | +### Copy files |
| 95 | +### |
| 96 | +COPY ./data/nginx/nginx.conf /etc/nginx/nginx.conf |
| 97 | +COPY ./data/vhost-gen/main.yml /etc/vhost-gen/main.yml |
| 98 | +COPY ./data/vhost-gen/mass.yml /etc/vhost-gen/mass.yml |
| 99 | +COPY ./data/vhost-gen/templates-main /etc/vhost-gen/templates-main |
| 100 | +COPY ./data/create-vhost.sh /usr/local/bin/create-vhost.sh |
| 101 | +COPY ./data/docker-entrypoint.d /docker-entrypoint.d |
| 102 | +COPY ./data/docker-entrypoint.sh /docker-entrypoint.sh |
| 103 | + |
| 104 | + |
| 105 | +### |
| 106 | +### Ports |
| 107 | +### |
| 108 | +EXPOSE 80 |
| 109 | +EXPOSE 443 |
| 110 | + |
| 111 | + |
| 112 | +### |
| 113 | +### Volumes |
| 114 | +### |
| 115 | +VOLUME /shared/httpd |
| 116 | +VOLUME /ca |
| 117 | + |
| 118 | + |
| 119 | +### |
| 120 | +### Signals |
| 121 | +### |
| 122 | +STOPSIGNAL SIGTERM |
| 123 | + |
| 124 | + |
| 125 | +### |
| 126 | +### Entrypoint |
| 127 | +### |
| 128 | +ENTRYPOINT ["/docker-entrypoint.sh"] |
0 commit comments