diff options
Diffstat (limited to 'Dockerfile')
| -rw-r--r-- | Dockerfile | 39 |
1 files changed, 14 insertions, 25 deletions
| @@ -1,13 +1,15 @@ | |||
| 1 | FROM php:8.3-apache | 1 | FROM python:3.12-slim |
| 2 | 2 | ||
| 3 | # enable contrib (fonts-ibm-plex) and non-free (fonts-ubuntu) components | 3 | # enable contrib (fonts-ibm-plex) and non-free (fonts-ubuntu) components |
| 4 | RUN sed -i 's/^Components: main$/Components: main contrib non-free/' /etc/apt/sources.list.d/debian.sources | 4 | RUN sed -i 's/^Components: main$/Components: main contrib non-free/' /etc/apt/sources.list.d/debian.sources |
| 5 | 5 | ||
| 6 | # install fonts, fontconfig (for fc-list), and tini (proper PID 1 / signal relay) | 6 | # install fonts, fontconfig (for fc-list), libmagic1 (for python-magic), and tini |
| 7 | RUN apt-get update && apt-get install -y --no-install-recommends \ | 7 | RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 8 | tini \ | 8 | tini \ |
| 9 | fontconfig \ | 9 | fontconfig \ |
| 10 | fonts-dejavu fonts-dejavu-core fonts-dejavu-extra fonts-dejavu-mono fonts-liberation fonts-liberation2 fonts-opensymbol fonts-urw-base35 fonts-noto-color-emoji fonts-noto-core fonts-noto-ui-core fonts-noto-extra fonts-noto-mono fonts-noto-cjk fonts-noto-cjk-extra fonts-roboto fonts-roboto-slab fonts-lato fonts-open-sans fonts-quicksand fonts-comfortaa fonts-cantarell fonts-beteckna fonts-ubuntu fonts-linuxlibertine fonts-ebgaramond fonts-ebgaramond-extra fonts-junicode fonts-stix fonts-texgyre fonts-sil-gentium fonts-sil-gentium-basic fonts-hack fonts-firacode fonts-cascadia-code fonts-inconsolata fonts-fantasque-sans fonts-terminus fonts-droid-fallback fonts-symbola fonts-ancient-scripts fonts-mathjax fonts-croscore fonts-nanum fonts-nanum-extra fonts-wqy-microhei fonts-wqy-zenhei fonts-arphic-ukai fonts-arphic-uming fonts-ipafont-gothic fonts-ipafont-mincho fonts-indic fonts-lohit-deva fonts-lohit-beng-assamese fonts-lohit-beng-bengali fonts-lohit-gujr fonts-lohit-guru fonts-lohit-knda fonts-lohit-mlym fonts-lohit-orya fonts-lohit-taml fonts-lohit-taml-classical fonts-lohit-telu fonts-smc fonts-arabeyes fonts-hosny-amiri fonts-sil-abyssinica fonts-beng fonts-thai-tlwg fonts-gfs-artemisia fonts-gfs-baskerville fonts-gfs-bodoni-classic fonts-gfs-didot fonts-gfs-gazis fonts-gfs-neohellenic fonts-gfs-olga fonts-gfs-porson fonts-gfs-solomos fonts-gfs-theokritos fonts-crosextra-carlito fonts-crosextra-caladea fonts-cabin fonts-vollkorn fonts-yanone-kaffeesatz fonts-ibm-plex fonts-freefont-ttf fonts-mplus fonts-monofur fonts-courier-prime fonts-anonymous-pro fonts-hermit | 10 | libmagic1 \ |
| 11 | fonts-dejavu fonts-dejavu-core fonts-dejavu-extra fonts-dejavu-mono fonts-liberation fonts-liberation2 fonts-opensymbol fonts-urw-base35 fonts-noto-color-emoji fonts-noto-core fonts-noto-ui-core fonts-noto-extra fonts-noto-mono fonts-noto-cjk fonts-noto-cjk-extra fonts-roboto fonts-roboto-slab fonts-lato fonts-open-sans fonts-quicksand fonts-comfortaa fonts-cantarell fonts-beteckna fonts-ubuntu fonts-linuxlibertine fonts-ebgaramond fonts-ebgaramond-extra fonts-junicode fonts-stix fonts-texgyre fonts-sil-gentium fonts-sil-gentium-basic fonts-hack fonts-firacode fonts-cascadia-code fonts-inconsolata fonts-fantasque-sans fonts-terminus fonts-droid-fallback fonts-symbola fonts-ancient-scripts fonts-mathjax fonts-croscore fonts-nanum fonts-nanum-extra fonts-wqy-microhei fonts-wqy-zenhei fonts-arphic-ukai fonts-arphic-uming fonts-ipafont-gothic fonts-ipafont-mincho fonts-indic fonts-lohit-deva fonts-lohit-beng-assamese fonts-lohit-beng-bengali fonts-lohit-gujr fonts-lohit-guru fonts-lohit-knda fonts-lohit-mlym fonts-lohit-orya fonts-lohit-taml fonts-lohit-taml-classical fonts-lohit-telu fonts-smc fonts-arabeyes fonts-hosny-amiri fonts-sil-abyssinica fonts-beng fonts-thai-tlwg fonts-gfs-artemisia fonts-gfs-baskerville fonts-gfs-bodoni-classic fonts-gfs-didot fonts-gfs-gazis fonts-gfs-neohellenic fonts-gfs-olga fonts-gfs-porson fonts-gfs-solomos fonts-gfs-theokritos fonts-crosextra-carlito fonts-crosextra-caladea fonts-cabin fonts-vollkorn fonts-yanone-kaffeesatz fonts-ibm-plex fonts-freefont-ttf fonts-mplus fonts-monofur fonts-courier-prime fonts-anonymous-pro fonts-hermit \ | ||
| 12 | && rm -rf /var/lib/apt/lists/* | ||
| 11 | 13 | ||
| 12 | # install Roboto Mono manually (not packaged in Debian, kj_sh604's fave font) | 14 | # install Roboto Mono manually (not packaged in Debian, kj_sh604's fave font) |
| 13 | RUN apt-get update && apt-get install -y --no-install-recommends curl \ | 15 | RUN apt-get update && apt-get install -y --no-install-recommends curl \ |
| @@ -17,40 +19,27 @@ RUN apt-get update && apt-get install -y --no-install-recommends curl \ | |||
| 17 | && fc-cache -fv \ | 19 | && fc-cache -fv \ |
| 18 | && rm -rf /var/lib/apt/lists/* | 20 | && rm -rf /var/lib/apt/lists/* |
| 19 | 21 | ||
| 20 | # configure apache: set document root to /var/www/html/src | 22 | WORKDIR /app |
| 21 | ENV APACHE_DOCUMENT_ROOT=/var/www/html/src | ||
| 22 | RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' \ | ||
| 23 | /etc/apache2/sites-available/*.conf \ | ||
| 24 | /etc/apache2/apache2.conf \ | ||
| 25 | /etc/apache2/conf-available/*.conf | ||
| 26 | |||
| 27 | # switch apache from port 80 to port 3000 | ||
| 28 | RUN sed -i 's/Listen 80/Listen 3000/' /etc/apache2/ports.conf \ | ||
| 29 | && sed -i 's/<VirtualHost \*:80>/<VirtualHost *:3000>/' \ | ||
| 30 | /etc/apache2/sites-available/*.conf | ||
| 31 | |||
| 32 | # enable mod_rewrite | ||
| 33 | RUN a2enmod rewrite | ||
| 34 | 23 | ||
| 35 | # php upload limits | 24 | # install python dependencies |
| 36 | RUN echo "upload_max_filesize = 50M" > /usr/local/etc/php/conf.d/sent-web.ini \ | 25 | COPY src/requirements.txt . |
| 37 | && echo "post_max_size = 50M" >> /usr/local/etc/php/conf.d/sent-web.ini | 26 | RUN pip install --no-cache-dir -r requirements.txt |
| 38 | 27 | ||
| 39 | # copy entrypoint script | 28 | # copy entrypoint script |
| 40 | COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh | 29 | COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh |
| 41 | RUN chmod +x /usr/local/bin/docker-entrypoint.sh | 30 | RUN chmod +x /usr/local/bin/docker-entrypoint.sh |
| 42 | 31 | ||
| 43 | # copy application | 32 | # copy application |
| 44 | COPY src/ /var/www/html/src/ | 33 | COPY src/ /app/ |
| 45 | 34 | ||
| 46 | # stash a seed copy of uploads so the entrypoint can populate a fresh volume | 35 | # stash a seed copy of uploads so the entrypoint can populate a fresh volume |
| 47 | RUN mkdir -p /opt/uploads-seed \ | 36 | RUN mkdir -p /opt/uploads-seed \ |
| 48 | && cp -r /var/www/html/src/uploads/. /opt/uploads-seed/ \ | 37 | && cp -r /app/uploads/. /opt/uploads-seed/ \ |
| 49 | && chown -R www-data:www-data /var/www/html/src/uploads /opt/uploads-seed | 38 | && chown -R www-data:www-data /app/uploads /opt/uploads-seed |
| 50 | 39 | ||
| 51 | EXPOSE 3000 | 40 | EXPOSE 3000 |
| 52 | 41 | ||
| 53 | # tini as PID 1 ensures SIGTERM is properly forwarded to apache, | 42 | # tini as PID 1 ensures SIGTERM is properly forwarded to gunicorn, |
| 54 | # preventing the 'permission denied' error on docker stop | 43 | # preventing the 'permission denied' error on docker stop |
| 55 | ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/docker-entrypoint.sh"] | 44 | ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/docker-entrypoint.sh"] |
| 56 | CMD ["apache2-foreground"] \ No newline at end of file | 45 | CMD ["gunicorn", "--bind", "0.0.0.0:3000", "--workers", "2", "--user", "www-data", "--group", "www-data", "app:app"] \ No newline at end of file |
