From 9edcc790cb3c0155e04e7a2b33735791b5deda49 Mon Sep 17 00:00:00 2001 From: Timur Demin Date: Fri, 14 Jun 2019 01:45:16 +0500 Subject: [PATCH] Make the app run with Docker --- .dockerignore | 76 +++++++++++++++++++++++++++++++++++++++++ Dockerfile | 23 +++++++++++++ bin/run_uwsgi.sh | 10 ++++++ doc/config.json.example | 5 +++ 4 files changed, 114 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 bin/run_uwsgi.sh create mode 100644 doc/config.json.example diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..5d88327 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,76 @@ +# Copied from .gitignore. +.vscode +.git +.gitignore +config.json +*.db +__pycache__/ +*.py[cod] +*$py.class +*.so +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST +*.manifest +*.spec +pip-log.txt +pip-delete-this-directory.txt +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ +*.mo +*.pot +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal +instance/ +.webassets-cache +.scrapy +docs/_build/ +target/ +.ipynb_checkpoints +profile_default/ +ipython_config.py +.python-version +celerybeat-schedule +*.sage.py +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ +.spyderproject +.spyproject +.ropeproject +/site +.mypy_cache/ +.dmypy.json +dmypy.json +.pyre/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6495a9a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM python:3.7-alpine +LABEL maintainer "Timur Demin " +WORKDIR /app +ENV UWSGI_PORT 8080 +ENV UWSGI_PROCESSES 1 +ENV UWSGI_THREADS 2 + +COPY requirements.txt setup.py setup.cfg /app/ +COPY bin /app/bin +COPY --chown=0:0 doc/config.json.example /etc/amber.json +COPY project_amber /app/project_amber + +# we need gcc to build cffi, which is required by bcrypt +RUN adduser -D -u 1000 amber && \ + mkdir -p /data && chown amber /data && chmod 700 /data && \ + apk add --no-cache build-base libffi-dev && \ + pip install -r requirements.txt && \ + pip install uwsgi && \ + apk del build-base libffi-dev && \ + chmod +x /app/bin/run_uwsgi.sh + +USER amber +CMD [ "sh", "/app/bin/run_uwsgi.sh" ] diff --git a/bin/run_uwsgi.sh b/bin/run_uwsgi.sh new file mode 100644 index 0000000..dd9490a --- /dev/null +++ b/bin/run_uwsgi.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +/usr/local/bin/uwsgi \ + --http :${UWSGI_PORT} \ + --master \ + --plugin python,http \ + --manage-script-name \ + --mount /=project_amber:app \ + --processes ${UWSGI_PROCESSES} \ + --threads ${UWSGI_THREADS} diff --git a/doc/config.json.example b/doc/config.json.example new file mode 100644 index 0000000..7fb2280 --- /dev/null +++ b/doc/config.json.example @@ -0,0 +1,5 @@ +{ + "database": "sqlite:////data/amber.db", + "allow_signup": true, + "loglevel": 2 +}