diff options
| -rw-r--r-- | .dockerignore | 2 | ||||
| -rw-r--r-- | Dockerfile | 45 | ||||
| -rw-r--r-- | README.md | 18 | ||||
| -rw-r--r-- | docker-compose.yml | 17 | ||||
| -rw-r--r-- | docker-entrypoint.sh | 11 |
5 files changed, 1 insertions, 92 deletions
diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 6955232..0000000 --- a/.dockerignore +++ /dev/null | |||
| @@ -1,2 +0,0 @@ | |||
| 1 | README.md | ||
| 2 | LICENSE \ No newline at end of file | ||
diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index cb2b9df..0000000 --- a/Dockerfile +++ /dev/null | |||
| @@ -1,45 +0,0 @@ | |||
| 1 | FROM python:3.12-slim | ||
| 2 | |||
| 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 | ||
| 5 | |||
| 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 \ | ||
| 8 | tini \ | ||
| 9 | fontconfig \ | ||
| 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/* | ||
| 13 | |||
| 14 | # install Roboto Mono manually (not packaged in Debian, kj_sh604's fave font) | ||
| 15 | RUN apt-get update && apt-get install -y --no-install-recommends curl \ | ||
| 16 | && mkdir -p /usr/local/share/fonts/roboto-mono \ | ||
| 17 | && curl -fsSL "https://cdn.jsdelivr.net/gh/googlefonts/RobotoMono@main/fonts/ttf/RobotoMono-Regular.ttf" \ | ||
| 18 | -o "/usr/local/share/fonts/roboto-mono/RobotoMono-Regular.ttf" \ | ||
| 19 | && fc-cache -fv \ | ||
| 20 | && rm -rf /var/lib/apt/lists/* | ||
| 21 | |||
| 22 | WORKDIR /app | ||
| 23 | |||
| 24 | # install python dependencies | ||
| 25 | COPY src/requirements.txt . | ||
| 26 | RUN pip install --no-cache-dir -r requirements.txt | ||
| 27 | |||
| 28 | # copy entrypoint script | ||
| 29 | COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh | ||
| 30 | RUN chmod +x /usr/local/bin/docker-entrypoint.sh | ||
| 31 | |||
| 32 | # copy application | ||
| 33 | COPY src/ /app/ | ||
| 34 | |||
| 35 | # stash a seed copy of uploads so the entrypoint can populate a fresh volume | ||
| 36 | RUN mkdir -p /opt/uploads-seed \ | ||
| 37 | && cp -r /app/uploads/. /opt/uploads-seed/ \ | ||
| 38 | && chown -R www-data:www-data /app/uploads /opt/uploads-seed | ||
| 39 | |||
| 40 | EXPOSE 3000 | ||
| 41 | |||
| 42 | # tini as PID 1 ensures SIGTERM is properly forwarded to gunicorn, | ||
| 43 | # preventing the 'permission denied' error on docker stop | ||
| 44 | ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/docker-entrypoint.sh"] | ||
| 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 | ||
| @@ -21,22 +21,7 @@ using Python and vanilla JavaScript. | |||
| 21 | - **export** - download as `.sent` file for local sent, or export `.pdf` for portability | 21 | - **export** - download as `.sent` file for local sent, or export `.pdf` for portability |
| 22 | ## usage | 22 | ## usage |
| 23 | 23 | ||
| 24 | ### docker compose (recommended) | 24 | ### local python run |
| 25 | |||
| 26 | ```sh | ||
| 27 | docker compose up -d | ||
| 28 | ``` | ||
| 29 | |||
| 30 | Open [http://localhost:3000](http://localhost:3000). | ||
| 31 | |||
| 32 | ### docker build | ||
| 33 | |||
| 34 | ```sh | ||
| 35 | docker build -t sent-web . | ||
| 36 | docker run -d -p 3000:3000 --init --name sent-web sent-web | ||
| 37 | ``` | ||
| 38 | |||
| 39 | ### local python run (without docker) | ||
| 40 | 25 | ||
| 41 | Requirements: | 26 | Requirements: |
| 42 | 27 | ||
| @@ -90,7 +75,6 @@ with multiple lines | |||
| 90 | - **Gunicorn** - production WSGI server | 75 | - **Gunicorn** - production WSGI server |
| 91 | - **fontconfig** - `fc-list` for font enumeration | 76 | - **fontconfig** - `fc-list` for font enumeration |
| 92 | - **python-magic + libmagic** - content-based upload type checks | 77 | - **python-magic + libmagic** - content-based upload type checks |
| 93 | - **Docker** - containerized with fonts pre-installed | ||
| 94 | 78 | ||
| 95 | ## license | 79 | ## license |
| 96 | 80 | ||
diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index d5bcae1..0000000 --- a/docker-compose.yml +++ /dev/null | |||
| @@ -1,17 +0,0 @@ | |||
| 1 | name: sent-web | ||
| 2 | |||
| 3 | services: | ||
| 4 | sent-web: | ||
| 5 | build: . | ||
| 6 | image: sent-web:latest | ||
| 7 | container_name: sent-web | ||
| 8 | ports: | ||
| 9 | - "3000:3000" | ||
| 10 | volumes: | ||
| 11 | - uploads:/app/uploads | ||
| 12 | restart: unless-stopped | ||
| 13 | init: true | ||
| 14 | stop_grace_period: 10s | ||
| 15 | |||
| 16 | volumes: | ||
| 17 | uploads: \ No newline at end of file | ||
diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh deleted file mode 100644 index 6cbaccb..0000000 --- a/docker-entrypoint.sh +++ /dev/null | |||
| @@ -1,11 +0,0 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | set -e | ||
| 3 | |||
| 4 | if [ -z "$(ls -A /app/uploads 2>/dev/null)" ] && \ | ||
| 5 | [ -d /opt/uploads-seed ]; then | ||
| 6 | cp -r /opt/uploads-seed/. /app/uploads/ | ||
| 7 | fi | ||
| 8 | |||
| 9 | chown -R www-data:www-data /app/uploads | ||
| 10 | |||
| 11 | exec "$@" \ No newline at end of file | ||
