-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose-prod.yml
57 lines (57 loc) · 1.94 KB
/
docker-compose-prod.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
version: '3.7'
services:
frontend:
image: jy95/sourcecode-front
restart: always
depends_on:
- api
ports:
- "80:3000"
- "443:3000"
environment:
API_SERVER: "http://api:3000"
CDN_SERVER: "http://api:3000/files"
api:
image: jy95/sourcecode_api
# To create the db the first time (as it is the raw postgres image) (also work when restart, thanks to volume)
command: >
sh -c "if ! npx sequelize db:migrate:status; then
if [ ! -z $$DATABASE_SCHEMA ]; then
npm run createSchema
fi
npm run migrate
fi
npm run start"
restart: always
ports:
- "8080:3000"
depends_on:
- db
environment:
NODE_ENV: production
# To have understandable logs in docker logs
DEBUG: sourcecode_api:error_handler
DATABASE_URL: "postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-jy95}@db:5432/${POSTGRES_DB:-sourcecode}"
DATABASE_SCHEMA: exercises_library
# use a env file if you want to use other values that default ones
# https://docs.docker.com/compose/environment-variables/#the-env_file-configuration-option
volumes:
# For the CDN part of this advanced prototype
- ./sourcecode-api/files:/api/files
db:
image: postgres:12-alpine
restart: always
ports:
- "5432:5432"
environment:
# use a env file for that part later
# https://docs.docker.com/compose/environment-variables/#the-env_file-configuration-option
POSTGRES_USER: postgres
POSTGRES_PASSWORD: jy95
POSTGRES_DB: sourcecode
POSTGRES_PORT: 5432
volumes:
# the default value is "/var/lib/postgresql/data"
# (https://github.com/docker-library/docs/blob/master/postgres/README.md#pgdata)
# We must create the folder "/tmp/db_data" on the host with the required permisssions
- ./sourcecode-db:/var/lib/postgresql/data