Skip to content

Commit 77585fb

Browse files
committed
Adds modified docker-compose and supporting nginx
Some of the changes for nginx are based on #8 There are two main additions here: `docker-comose.yaml`: - Adds an updated docker-compose.yaml with: - Renamed services: We need to integrate the signal documentation services into an existing docker-compose setup. It will be easier to manage them all if we have some ability to tell them apart, so we add "sd" as a prefix in a few places. - Renamed containers: Similar to the above, this gives us a little bit of differentiation when building/running the images - Shell-style variable (`${}`) "markup" around container image names that will be used by CI when building the images. Essentially CI will add a registry and tag information into the `${}` variable placeholders. - Adds `image` keys to the services so that CI can build container images from docker-compose. - Adds the nginx container services that we will run in the production context for serving static files. `default.conf.template`: - Updates to proxy to the sdwebapp services name - Updates the static file location to use the same bind mounted direcotry that the web application uses to store the generated static files when it runs
1 parent c679877 commit 77585fb

File tree

2 files changed

+30
-13
lines changed

2 files changed

+30
-13
lines changed

docker-compose.yaml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ services:
77
container_name: signal_documentation-db
88
restart: always
99
env_file:
10-
- ./.env
10+
- ./.env
1111
environment:
1212
MYSQL_DATABASE: ${MYSQL_DATABASE}
1313
MYSQL_USER: ${MYSQL_USER}
@@ -18,11 +18,13 @@ services:
1818
ports:
1919
- "3306:3306"
2020

21-
webapp:
21+
sdwebapp:
22+
image: ${REGISTRY}signal_documentation-webapp${TAG}
2223
build: .
2324
env_file:
24-
- ./.env
25-
container_name: signal_documentation-web
25+
- ./.env
26+
container_name: signal_documentation-webapp
27+
restart: on-failure
2628
command: sh -c "python3 /usr/src/signal_documentation/src/manage.py migrate --noinput &&
2729
python3 /usr/src/signal_documentation/src/manage.py collectstatic --noinput &&
2830
python3 /usr/src/signal_documentation/src/manage.py loaddata ./fixtures/available_geography.json &&
@@ -44,6 +46,20 @@ services:
4446
ports:
4547
- "6379:6379"
4648

49+
sdnginx:
50+
image: ${REGISTRY}signal_documentation-nginx${TAG}
51+
build: ./nginx
52+
env_file:
53+
- ./.env
54+
container_name: signal_documentation-nginx
55+
restart: on-failure
56+
volumes:
57+
- ./src/staticfiles:/staticfiles
58+
ports:
59+
- "80:80"
60+
depends_on:
61+
- sdwebapp
4762
volumes:
4863
mysql:
4964
webapp:
65+
static:

nginx/default.conf.template

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
server {
22
listen 80;
3-
server_name _;
3+
server_name sdnginx;
44

5-
location / {
5+
location /static/ {
6+
autoindex on;
7+
alias /staticfiles/;
8+
}
9+
10+
location / {
11+
proxy_pass http://sdwebapp:8000/;
12+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
613
proxy_set_header Host $http_host;
714
proxy_set_header X-Real-IP $remote_addr;
8-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
915
proxy_set_header X-Forwarded-Proto $scheme;
10-
proxy_pass http://${APP_HOST}:8000;
11-
}
12-
13-
location /usr/src/signal_documentation {
14-
alias /static/;
15-
}
16+
}
1617
}

0 commit comments

Comments
 (0)