Browse Source

Make the app run with Docker

tags/0.0.1b
Timur Demin 1 month ago
parent
commit
9edcc790cb
Signed by: Timur Demin <me@tdem.in> GPG Key ID: 9EDF3F9D9286FA20
4 changed files with 114 additions and 0 deletions
  1. 76
    0
      .dockerignore
  2. 23
    0
      Dockerfile
  3. 10
    0
      bin/run_uwsgi.sh
  4. 5
    0
      doc/config.json.example

+ 76
- 0
.dockerignore View File

@@ -0,0 +1,76 @@
1
+# Copied from .gitignore.
2
+.vscode
3
+.git
4
+.gitignore
5
+config.json
6
+*.db
7
+__pycache__/
8
+*.py[cod]
9
+*$py.class
10
+*.so
11
+.Python
12
+build/
13
+develop-eggs/
14
+dist/
15
+downloads/
16
+eggs/
17
+.eggs/
18
+lib/
19
+lib64/
20
+parts/
21
+sdist/
22
+var/
23
+wheels/
24
+pip-wheel-metadata/
25
+share/python-wheels/
26
+*.egg-info/
27
+.installed.cfg
28
+*.egg
29
+MANIFEST
30
+*.manifest
31
+*.spec
32
+pip-log.txt
33
+pip-delete-this-directory.txt
34
+htmlcov/
35
+.tox/
36
+.nox/
37
+.coverage
38
+.coverage.*
39
+.cache
40
+nosetests.xml
41
+coverage.xml
42
+*.cover
43
+.hypothesis/
44
+.pytest_cache/
45
+*.mo
46
+*.pot
47
+*.log
48
+local_settings.py
49
+db.sqlite3
50
+db.sqlite3-journal
51
+instance/
52
+.webassets-cache
53
+.scrapy
54
+docs/_build/
55
+target/
56
+.ipynb_checkpoints
57
+profile_default/
58
+ipython_config.py
59
+.python-version
60
+celerybeat-schedule
61
+*.sage.py
62
+.env
63
+.venv
64
+env/
65
+venv/
66
+ENV/
67
+env.bak/
68
+venv.bak/
69
+.spyderproject
70
+.spyproject
71
+.ropeproject
72
+/site
73
+.mypy_cache/
74
+.dmypy.json
75
+dmypy.json
76
+.pyre/

+ 23
- 0
Dockerfile View File

@@ -0,0 +1,23 @@
1
+FROM python:3.7-alpine
2
+LABEL maintainer "Timur Demin <me@tdem.in>"
3
+WORKDIR /app
4
+ENV UWSGI_PORT 8080
5
+ENV UWSGI_PROCESSES 1
6
+ENV UWSGI_THREADS 2
7
+
8
+COPY requirements.txt setup.py setup.cfg /app/
9
+COPY bin /app/bin
10
+COPY --chown=0:0 doc/config.json.example /etc/amber.json
11
+COPY project_amber /app/project_amber
12
+
13
+# we need gcc to build cffi, which is required by bcrypt
14
+RUN adduser -D -u 1000 amber && \
15
+    mkdir -p /data && chown amber /data && chmod 700 /data && \
16
+    apk add --no-cache build-base libffi-dev && \
17
+    pip install -r requirements.txt && \
18
+    pip install uwsgi && \
19
+    apk del build-base libffi-dev && \
20
+    chmod +x /app/bin/run_uwsgi.sh
21
+
22
+USER amber
23
+CMD [ "sh", "/app/bin/run_uwsgi.sh" ]

+ 10
- 0
bin/run_uwsgi.sh View File

@@ -0,0 +1,10 @@
1
+#!/bin/sh
2
+
3
+/usr/local/bin/uwsgi \
4
+    --http :${UWSGI_PORT} \
5
+    --master \
6
+    --plugin python,http \
7
+    --manage-script-name \
8
+    --mount /=project_amber:app \
9
+    --processes ${UWSGI_PROCESSES} \
10
+    --threads ${UWSGI_THREADS}

+ 5
- 0
doc/config.json.example View File

@@ -0,0 +1,5 @@
1
+{
2
+    "database": "sqlite:////data/amber.db",
3
+    "allow_signup": true,
4
+    "loglevel": 2
5
+}

Loading…
Cancel
Save