-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yml
66 lines (60 loc) · 1.67 KB
/
docker-compose.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
58
59
60
61
62
63
64
65
66
# I will use this file only in the proudction for deployment
# I might not use it whatsoever if I don't find a good place to host it lol
# To summaize: Create a DB (postgres image) service -> Create Migrations on the Database (if any, but yet an important step just in case the migration has changed or something) -> Pick the configurations from Dockerfile and run the server on the specified port
version: "3"
services:
server:
build:
#make use of Dockerfile
context: .
args:
NPM_LOG_LEVEL: notice
ports:
- "${PORT}:4000"
environment:
DATABASE_URL: "${DATABASE_URL}"
depends_on:
- migration
migration:
build:
context: .
args:
NPM_LOG_LEVEL: notice
command: npm run db:init
working_dir: /app/server
environment:
DATABASE_URL: "${DATABASE_URL}"
depends_on:
db:
condition: service_healthy
#Same service as docker-compose.db.yaml - docker-compose.db.yml is for someone who doesn't want to use this docker-compose.yaml for building
db:
image: postgres:12
environment:
POSTGRES_USER: ${POSTGRESQL_USER}
POSTGRES_PASSWORD: ${POSTGRESQL_PASSWORD}
ports: ${POSTGRESQL_PORT}:5432
volumes:
- postgres:/var/lib/postgresql/data
healthcheck:
test:
[
"CMD",
"pg_isready",
"-q",
"-d",
"${POSTGRESQL_DB_NAME}",
"-U",
"${POSTGRESQL_USER}",
]
timeout: 45s
interval: 10s
retries: 10
cache:
image: redis:alpine
ports:
- "${REDIS_PORT}:6379"
command: ['--requirepass "secret"']
#for data to persist
volumes:
postgres: ~