-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yml
50 lines (45 loc) · 1.42 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
# Docker compose version 3.9 : is saying use the version 3.9 syntax
version: "3.9"
services:
# NAME OF THE SERVICES app and db
app:
build:
context: .
args:
- DEV=true
# THIS MAP PORT 8000 FROM OUR LOCAL MACHINE TO 8000 PORT IN DOCKER
ports:
- "8000:8000"
# VOLUMES ARE WAY OF MAPPING OR LINKING DIRECTORIES FROM OUR LOCAL MACHINE TO DOCKER
# WHY WE ADDING VOLUMES IS OTHER TO SYNC THE CODE ON OUR LOCAL MACHINE TO DOCKER IN REALTIME
# SO WE DON'T HAVE TO BUILD EVERYTIME
volumes:
- ./app:/app
- dev-static-data:/vol/web
command: >
sh -c "python manage.py wait_for_db &&
python manage.py migrate &&
python manage.py runserver 0.0.0.0:8000"
environment:
# we are using db because it is the host name of the database db
- DB_HOST=db
- DB_NAME=devdb
- DB_USER=devuser
- DB_PASS=changeme
- DEBUG=1
# depends_on will wait for the db service to start before moving on
# it would automatically create a network between the db service and app
depends_on:
- db
db:
image: postgres:13-alpine
# stores the database which is located in docker in our local machine
volumes:
- dev-db-data:/var/lib/postgresql/data
environment:
- POSTGRES_DB=devdb
- POSTGRES_USER=devuser
- POSTGRES_PASSWORD=changeme
volumes:
dev-db-data:
dev-static-data: