Browse Source

Add an example docker-compose config

* Make uwsgi use its own proto, and not http
* Bundle psycopg2 with the image
* Add an example nginx config
tags/0.0.1b
Timur Demin 1 month ago
parent
commit
66b40df034
Signed by: Timur Demin <me@tdem.in> GPG Key ID: 9EDF3F9D9286FA20
4 changed files with 51 additions and 5 deletions
  1. 4
    3
      Dockerfile
  2. 1
    2
      bin/run_uwsgi.sh
  3. 8
    0
      doc/nginx.conf.example
  4. 38
    0
      docker-compose.yml

+ 4
- 3
Dockerfile View File

@@ -10,12 +10,13 @@ COPY bin /app/bin
10 10
 COPY --chown=0:0 doc/config.json.example /etc/amber.json
11 11
 COPY project_amber /app/project_amber
12 12
 
13
-# we need gcc to build cffi, which is required by bcrypt
13
+# we do not remove postgresql-dev after installation, as psycopg2 needs libpq
14
+# present on the system
14 15
 RUN adduser -D -u 1000 amber && \
15 16
     mkdir -p /data && chown amber /data && chmod 700 /data && \
16
-    apk add --no-cache build-base libffi-dev && \
17
+    apk add --no-cache build-base libffi-dev postgresql-dev && \
17 18
     pip install -r requirements.txt && \
18
-    pip install uwsgi && \
19
+    pip install uwsgi psycopg2 && \
19 20
     apk del build-base libffi-dev && \
20 21
     chmod +x /app/bin/run_uwsgi.sh
21 22
 

+ 1
- 2
bin/run_uwsgi.sh View File

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

+ 8
- 0
doc/nginx.conf.example View File

@@ -0,0 +1,8 @@
1
+server {
2
+    listen 80 default_server;
3
+    location / { try_files $uri @amber; }
4
+    location @amber {
5
+        include uwsgi_params;
6
+        uwsgi_pass amber:8080;
7
+    }
8
+}

+ 38
- 0
docker-compose.yml View File

@@ -0,0 +1,38 @@
1
+version: "3"
2
+
3
+volumes:
4
+  postgres:
5
+
6
+services:
7
+  amber:
8
+    build: .
9
+    restart: always
10
+    # You'll likely need to add other drivers, like mysql-connector-python, to
11
+    # connect to databases other than the default SQLite and PostgreSQL. See:
12
+    # https://docs.sqlalchemy.org/en/13/core/engines.html#database-urls
13
+    environment:
14
+      - AMBER_DATABASE=postgres://amber:CHANGEME@database:5432/amber
15
+      - AMBER_LOGLEVEL=2
16
+      - AMBER_ALLOW_SIGNUP=0
17
+      - UWSGI_PORT=8080
18
+      - UWSGI_PROCESSES=1
19
+      - UWSGI_THREADS=2
20
+    depends_on:
21
+      - database
22
+  database:
23
+    image: postgres:11-alpine
24
+    restart: always
25
+    environment:
26
+      - POSTGRES_DB=amber
27
+      - POSTGRES_USER=amber
28
+      - POSTGRES_PASSWORD=CHANGEME
29
+    volumes:
30
+      - postgres:/var/lib/postgresql/data
31
+  web:
32
+    image: nginx:1.16-alpine
33
+    ports:
34
+      - 80:80
35
+    depends_on:
36
+      - amber
37
+    volumes:
38
+      - ./doc/nginx.conf.example:/etc/nginx/conf.d/default.conf:ro

Loading…
Cancel
Save