-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose.yml
51 lines (42 loc) · 1.9 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
# version: "3.9"
services:
app: #name of service. each docker compose 'service' represents a container
#my understanding is each service/container can be built from a dockerfile (like what we have specified immediately below for this 'app' service using the 'build' instruction, or can be based off a pre-existing image like we have done in the 'db' service below using the 'image' instruction
build:
context: .
args:
- DEV=true
ports:
- "8000:8000"
volumes:
- ./app:/app
# this over-rides any default command specified in a 'CMD' instruction in the image Dockerfile
command: >
sh -c "python manage.py runserver 0.0.0.0:8000"
environment:
- DB_HOST=db #the variable name is set to 'db' which is the name of the database service below
# The values for database name, user and password below match what we have defined under the database service below:
- DB_NAME=devdb
- DB_USER=devuser
- DB_PASS=changeme
depends_on:
- db #this instructs docker to start the 'db' service before starting this 'app' service
db:
#image:postgres:13-alpine
image: postgres
volumes:
- dev-db-data:/var/lib/postgresql/
environment: #below variables are used to configure database for running locally NOT IN PRODUCTION, hence the loose way for creating and storing the username/password
- POSTGRES_DB=devdb
- POSTGRES_USER=devuser
- POSTGRES_PASSWORD=changeme
volumes:
dev-db-data:
# "docker-compose" is replaced by "docker compose" which is made available via "docker-compose-plugin" package that gets bundled with Docker Desktop.
# build image using this command (after cd'ing into the project's root dir):
# docker compose build
# helpful options
# --no-cache: force Docker to pull fresh dependencies
# --progress=plain verbose mode for troubleshooting
#run the server using:
# docker compose up