From 494f11d5cc88f05df300f6f41bcf083a736487dc Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Sat, 20 Nov 2021 10:51:14 -0800 Subject: [PATCH] Switch from Alpine to Debian, refs #1522 --- demos/apache-proxy/Dockerfile | 80 +++++++++++++++++++++-------------- 1 file changed, 49 insertions(+), 31 deletions(-) diff --git a/demos/apache-proxy/Dockerfile b/demos/apache-proxy/Dockerfile index 59c2043327..40f5e31d18 100644 --- a/demos/apache-proxy/Dockerfile +++ b/demos/apache-proxy/Dockerfile @@ -1,46 +1,64 @@ -FROM python:3-alpine +FROM python:3.9.7-slim-bullseye -RUN apk add --no-cache \ - apache2 \ - apache2-proxy \ - bash +RUN apt-get update && \ + apt-get install -y apache2 supervisor && \ + apt clean && \ + rm -rf /var/lib/apt && \ + rm -rf /var/lib/dpkg/info/* + +# Apache environment, copied from +# https://github.com/ijklim/laravel-benfords-law-app/blob/e9bf385dcaddb62ea466a7b245ab6e4ef708c313/docker/os/Dockerfile +ENV APACHE_DOCUMENT_ROOT=/var/www/html/public +ENV APACHE_RUN_USER www-data +ENV APACHE_RUN_GROUP www-data +ENV APACHE_PID_FILE /var/run/apache2.pid +ENV APACHE_RUN_DIR /var/run/apache2 +ENV APACHE_LOCK_DIR /var/lock/apache2 +ENV APACHE_LOG_DIR /var/log +RUN ln -sf /dev/stdout /var/log/apache2-access.log +RUN ln -sf /dev/stderr /var/log/apache2-error.log +RUN mkdir -p $APACHE_RUN_DIR $APACHE_LOCK_DIR + +RUN a2enmod proxy +RUN a2enmod proxy_http +RUN a2enmod headers ARG DATASETTE_REF RUN pip install https://github.com/simonw/datasette/archive/${DATASETTE_REF}.zip -ENV TINI_VERSION v0.18.0 -ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-static /tini -RUN chmod +x /tini - # Append this to the end of the default httpd.conf file -RUN echo -e 'ServerName localhost\n\ +RUN echo '\n\ +\n\ + Options Indexes FollowSymLinks\n\ + AllowOverride None\n\ + Require all granted\n\ +\n\ \n\ -\n\ - Order deny,allow\n\ - Allow from all\n\ -\n\ -\n\ -ProxyPreserveHost On\n\ -ProxyPass /prefix/ http://localhost:8001/\n\ -Header add X-Proxied-By "Apache2"' >> /etc/apache2/httpd.conf - -RUN echo 'Datasette' > /var/www/localhost/htdocs/index.html +\n\ + ServerName localhost\n\ + DocumentRoot /app/html\n\ + ProxyPreserveHost On\n\ + ProxyPass /prefix/ http://127.0.0.1:8001/\n\ + Header add X-Proxied-By "Apache2 Debian"\n\ +\n\ +' > /etc/apache2/sites-enabled/000-default.conf WORKDIR /app +RUN mkdir -p /app/html +RUN echo 'Datasette' > /app/html/index.html ADD https://latest.datasette.io/fixtures.db /app/fixtures.db -RUN echo -e "#!/usr/bin/env bash\n\ -datasette /app/fixtures.db --setting base_url '/prefix/' --version-note '${DATASETTE_REF}' -h 0.0.0.0 -p 8001 &\n\ -\n\ -httpd -D FOREGROUND & \n\ -\n\ -wait -n\n\ -exit $?" > /app/start.sh - -RUN chmod +x /app/start.sh - EXPOSE 80 -CMD /tini -- /app/start.sh +RUN echo "[supervisord]" >> /app/supervisord.conf +RUN echo "nodaemon=true" >> /app/supervisord.conf +RUN echo "" >> /app/supervisord.conf +RUN echo "[program:apache2]" >> /app/supervisord.conf +RUN echo "command=apache2 -D FOREGROUND" >> /app/supervisord.conf +RUN echo "" >> /app/supervisord.conf +RUN echo "[program:datasette]" >> /app/supervisord.conf +RUN echo "command=datasette /app/fixtures.db --setting base_url '/prefix/' --version-note '${DATASETTE_REF}' -h 0.0.0.0 -p 8001" >> /app/supervisord.conf + +CMD ["/usr/bin/supervisord", "-c", "/app/supervisord.conf"]