-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yaml
51 lines (47 loc) · 1.95 KB
/
docker-compose.yaml
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
# Docker Compose version
version: "3"
# Define the services that make up our Application
services:
# The "app" service
app:
# The build and it’s context, meaning where to get the code from. dot is root
build:
context: .
# Specify the ports to use for the “app”
ports:
- "8000:8000"
# Allows us to get the updates we make in our project get into the Docker Image,
# in real time -> Hot reload
volumes:
- ./app:/app
# Is used to run our Application in our Docker Container
# The ">" means that you're specifying the rest of the line on the next line,
# because commands to run in general can be very long so you'll want to use new lines
# Specifies the server in the runserver command which matches the one from the docker container.
command: >
sh -c "python manage.py wait_for_db &&
python manage.py wait_for_db migrate
python manage.py runserver 0.0.0.0:8000"
# Some environment (global) variables we can use in Django like settings.py
environment:
# The service running our db, and also means we can access the database via "db"
- DB_HOST=db
- DB_NAME=app
- DB_USER=postgres
- DB_PASS=supersecretpassword
# This tells docker that the django "app" is dependent on the db, meaning
# that the db microservice needs to start up before django starts up and,
# it tells the host that this service is available via the network when you use the hostname 'db'
depends_on:
- db
# Creates a db service as a seperate microservice
db:
# Grabs the version 10 the lightweight "alpine" version from docker hub
image: postgres:10-alpine
# The envirmoment (global) variables for accessing and creating the DB
# You would add the real encryptes db passwords in a real production in,
# your build envirnment like Travis CL or something else.
environment:
- POSTGRES_DB=app
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=supersecretpassword