|
| 1 | +FROM debian AS cert |
| 2 | + |
| 3 | +WORKDIR /kool/ssl |
| 4 | + |
| 5 | +RUN apt-get update && \ |
| 6 | + apt-get install -y openssl && \ |
| 7 | + openssl genrsa -des3 -passout pass:x -out server.pass.key 2048 && \ |
| 8 | + openssl rsa -passin pass:x -in server.pass.key -out _.localhost.key && \ |
| 9 | + rm server.pass.key && \ |
| 10 | + openssl req -new -key _.localhost.key -out server.csr \ |
| 11 | + -subj "/C=XX/ST=XX/L=XX/O=Kool-Local/OU=Localhost/CN=*.localhost" && \ |
| 12 | + openssl x509 -req -days 365 -in server.csr -signkey _.localhost.key -out _.localhost.crt && \ |
| 13 | + openssl x509 -in _.localhost.crt -out _.localhost.pem |
| 14 | + |
| 15 | +FROM kooldev/php:8.3-prod |
| 16 | + |
| 17 | +ENV PHP_FPM_LISTEN=/run/php-fpm.sock \ |
| 18 | + NGINX_LISTEN=80 \ |
| 19 | + NGINX_HTTPS=false \ |
| 20 | + NGINX_LISTEN_HTTPS=443 \ |
| 21 | + NGINX_HTTPS_CERT=/kool/ssl/_.localhost.pem \ |
| 22 | + NGINX_HTTPS_CERT_KEY=/kool/ssl/_.localhost.key \ |
| 23 | + NGINX_ROOT=/app/public \ |
| 24 | + NGINX_INDEX=index.php \ |
| 25 | + NGINX_CLIENT_MAX_BODY_SIZE=25M \ |
| 26 | + NGINX_PHP_FPM=unix:/run/php-fpm.sock \ |
| 27 | + NGINX_FASTCGI_READ_TIMEOUT=60s \ |
| 28 | + NGINX_FASTCGI_BUFFERS='8 8k' \ |
| 29 | + NGINX_FASTCGI_BUFFER_SIZE='16k' \ |
| 30 | + NGINX_ENTRYPOINT_WORKER_PROCESSES_AUTOTUNE=true |
| 31 | + |
| 32 | +RUN curl -L https://github.com/ochinchina/supervisord/releases/download/v0.6.3/supervisord_static_0.6.3_linux_amd64 -o /usr/local/bin/supervisord \ |
| 33 | + && chmod +x /usr/local/bin/supervisord \ |
| 34 | + && apk add --no-cache nginx \ |
| 35 | + && chown -R kool:kool /var/lib/nginx \ |
| 36 | + && chmod 770 /var/lib/nginx/tmp \ |
| 37 | + && ln -sf /dev/stdout /var/log/nginx/access.log \ |
| 38 | + && ln -sf /dev/stderr /var/log/nginx/error.log \ |
| 39 | + # add h5bp/server-configs-nginx |
| 40 | + && mkdir -p /etc/nginx/conf.d \ |
| 41 | + && mkdir /etc/nginx/h5bp \ |
| 42 | + && cd /etc/nginx/h5bp \ |
| 43 | + && wget https://github.com/h5bp/server-configs-nginx/archive/refs/tags/3.3.0.tar.gz -O h5bp.tgz \ |
| 44 | + && tar xzvf h5bp.tgz \ |
| 45 | + && rm -f h5bp.tgz \ |
| 46 | + && mv server-configs-nginx-*/h5bp/* . \ |
| 47 | + && mv server-configs-nginx-*/nginx.conf /etc/nginx/nginx.conf \ |
| 48 | + && sed -i "s|^user .*|user\ kool kool;|g" /etc/nginx/nginx.conf \ |
| 49 | + && mv server-configs-nginx-*/mime.types /etc/nginx/mime.types \ |
| 50 | + && rm -rf server-configs-nginx-* \ |
| 51 | + && curl -L https://raw.githubusercontent.com/nginxinc/docker-nginx/master/entrypoint/30-tune-worker-processes.sh -o /kool/30-tune-worker-processes.sh \ |
| 52 | + && chmod +x /kool/30-tune-worker-processes.sh |
| 53 | + |
| 54 | +COPY supervisor.conf /kool/supervisor.conf |
| 55 | +COPY default.tmpl /kool/default.tmpl |
| 56 | +COPY entrypoint /kool/entrypoint |
| 57 | +COPY --from=cert /kool/ssl /kool/ssl |
| 58 | +RUN chmod +x /kool/entrypoint |
| 59 | + |
| 60 | +EXPOSE 80 |
| 61 | + |
| 62 | +CMD [ "supervisord", "-c", "/kool/supervisor.conf" ] |
0 commit comments