From 9fbd628f8d9fc67d6b8d1f59fe4ec0ea3e24637e Mon Sep 17 00:00:00 2001 From: Thomas Schneider <thomas@fsmpi.rwth-aachen.de> Date: Thu, 12 Sep 2024 13:29:44 +0200 Subject: [PATCH] Add Containerfile and Gunicorn example config for deployment --- .containerignore | 1 + .gitignore | 1 + Containerfile | 26 ++++++++++++++++++++++++++ examples/gunicorn.conf.py | 3 +++ 4 files changed, 31 insertions(+) create mode 120000 .containerignore create mode 100644 Containerfile create mode 100644 examples/gunicorn.conf.py diff --git a/.containerignore b/.containerignore new file mode 120000 index 0000000..3e4e48b --- /dev/null +++ b/.containerignore @@ -0,0 +1 @@ +.gitignore \ No newline at end of file diff --git a/.gitignore b/.gitignore index 11c022d..5fc546c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.pdf /instance /schilder2000/static +/gunicorn.conf.py # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..250a2cf --- /dev/null +++ b/Containerfile @@ -0,0 +1,26 @@ +FROM docker.io/library/node:20-alpine AS build-node +WORKDIR /usr/app +COPY . . +RUN ["npm", "ci"] +RUN ["npm", "run", "build"] + +FROM docker.io/library/python:3.12-alpine AS build-python +WORKDIR /usr/src/app +COPY . . +COPY --from=build-node /usr/app/schilder2000/static ./schilder2000/static +RUN ["apk", "add", "git"] +RUN ["pip", "install", "build"] +RUN ["pyproject-build", "-C", "without-npm"] + +FROM docker.io/library/python:3.12-alpine +RUN ["apk", "add", "pango", "font-terminus", "font-inconsolata", "font-dejavu", "font-noto", "font-noto-cjk", "font-awesome", "font-noto-extra", "libldap", "mariadb-connector-c"] +COPY --from=build-python /usr/src/app/dist/schilder2000-*.whl /tmp/ +RUN apk add -t .build-deps build-base mysql-dev openldap-dev git && \ + pip install gunicorn /tmp/schilder2000-*.whl schilder2000[all] && \ + rm /tmp/schilder2000-*.whl && \ + apk del .build-deps +VOLUME /usr/local/var/schilder2000-instance/ +COPY examples /usr/local/var/schilder2000-instance +WORKDIR /usr/local/var/schilder2000-instance/ +ENV FLASK_APP=schilder2000 +CMD ["gunicorn", "schilder2000:create_app()"] diff --git a/examples/gunicorn.conf.py b/examples/gunicorn.conf.py new file mode 100644 index 0000000..cf53d5c --- /dev/null +++ b/examples/gunicorn.conf.py @@ -0,0 +1,3 @@ +wsgi_app = "schilder2000:create_app()" +bind = "[::]:8080" +accesslog = "-" -- GitLab