File tree 6 files changed +58
-13
lines changed
6 files changed +58
-13
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
5
5
pkg-config \
6
6
build-essential \
7
7
libpq-dev \
8
+ git \
8
9
&& rm -rf /var/lib/apt/lists/*
9
10
10
11
WORKDIR /app
@@ -54,7 +55,9 @@ COPY --from=build /usr/local/bin/uwsgi /usr/local/bin/uwsgi
54
55
55
56
# Stage 3.2 - Copy source code
56
57
WORKDIR /app
58
+ COPY ./bin/wait_for_db.sh /wait_for_db.sh
57
59
COPY ./bin/docker_start.sh /start.sh
60
+ COPY ./bin/setup_configuration.sh /setup_configuration.sh
58
61
RUN mkdir /app/log /app/config
59
62
60
63
COPY --from=frontend-build /app/src/objecttypes/static /app/src/objecttypes/static
Original file line number Diff line number Diff line change @@ -15,12 +15,8 @@ uwsgi_threads=${UWSGI_THREADS:-2}
15
15
16
16
mountpoint=${SUBPATH:-/ }
17
17
18
- until pg_isready; do
19
- >&2 echo " Waiting for database connection..."
20
- sleep 1
21
- done
22
-
23
- >&2 echo " Database is up."
18
+ # wait for required services
19
+ ${SCRIPTPATH} /wait_for_db.sh
24
20
25
21
# Apply database migrations
26
22
>&2 echo " Apply database migrations"
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ # setup initial configuration using environment variables
4
+ # Run this script from the root of the repository
5
+
6
+ # set -e
7
+ ${SCRIPTPATH} /wait_for_db.sh
8
+
9
+ src/manage.py migrate
10
+
11
+ src/manage.py setup_configuration --no-selftest
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+ set -e
4
+
5
+ # Wait for the database container
6
+ # See: https://docs.docker.com/compose/startup-order/
7
+ export PGHOST=${DB_HOST:- db}
8
+ export PGPORT=${DB_PORT:- 5432}
9
+
10
+ until pg_isready; do
11
+ >&2 echo " Waiting for database connection..."
12
+ sleep 1
13
+ done
14
+
15
+ >&2 echo " Database is up."
Original file line number Diff line number Diff line change @@ -2,20 +2,37 @@ version: '3'
2
2
3
3
services :
4
4
db :
5
- # NOTE: No persistance storage configured.
6
- # See: https://hub.docker.com/_/postgres/
7
- image : postgres
5
+ image : postgres:11-alpine
8
6
environment :
9
- - POSTGRES_USER=${DB_USER:-objecttypes}
10
- - POSTGRES_PASSWORD=${DB_PASSWORD:-objecttypes}
7
+ - POSTGRES_HOST_AUTH_METHOD=trust
8
+ volumes :
9
+ - ./docker-init-db.sql:/docker-entrypoint-initdb.d/init_db.sql
10
+ # - db:/var/lib/postgresql/data
11
+ command : postgres -c max_connections=300 -c log_min_messages=LOG
11
12
12
13
web :
13
14
build : .
14
- environment :
15
+ environment : &app-env
15
16
- DJANGO_SETTINGS_MODULE=objecttypes.conf.docker
16
17
- SECRET_KEY=${SECRET_KEY:-fgv=c0hz&tl*8*3m3893@m+1pstrvidc9e^5@fpspmg%cy$15d}
17
18
- ALLOWED_HOSTS=*
19
+ - TWO_FACTOR_FORCE_OTP_ADMIN=no
20
+ - TWO_FACTOR_PATCH_ADMIN=no
21
+ # setup_configuration env vars
22
+ - OBJECTTYPES_DOMAIN=web:8000
23
+ - OBJECTTYPES_ORGANIZATION=ObjectTypes
24
+ - OBJECTS_OBJECTTYPES_TOKEN=some-random-string
25
+ - OBJECTS_OBJECTTYPES_PERSON=Some Person
26
+
18
27
ports :
19
28
- 8000:8000
20
29
depends_on :
21
- - db
30
+ web-init :
31
+ condition : service_completed_successfully
32
+
33
+ web-init :
34
+ build : .
35
+ environment : *app-env
36
+ command : /setup_configuration.sh
37
+ depends_on :
38
+ - db
Original file line number Diff line number Diff line change
1
+ CREATE USER objecttypes ;
2
+ CREATE DATABASE objecttypes ;
3
+ GRANT ALL PRIVILEGES ON DATABASE objecttypes TO objecttypes;
You can’t perform that action at this time.
0 commit comments