-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose.yml
83 lines (80 loc) · 3.83 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Docker-compose file for full stack application
version: "3.7"
services:
client:
image: node:12-stretch # Pulls image from Docker Hub
container_name: client # Names running container 'client'
working_dir: /app # Sets working dir
volumes:
- ./client:/app # Binds './client' dir to '/app' inside container
ports:
- 3001:3000 # Binds port 3000 inside container to host's 3001 port
networks:
- sandbox # Adds container to sandbox network
command: npm start # Sets the container command
stdin_open: true # Needed for interactivity with terminal so CRA doesn't close upon starting
proxy:
image: nginx # Pulls image from Docker Hub
container_name: proxy # Names the running container
volumes:
- ./proxy/default.conf:/etc/nginx/conf.d/default.conf # Adds default.conf file to location in nginx
- static_files:/var/www/static # Bind volume to share static files from Django to proxy
ports:
- 80:80 # Binds container http port to host http port
networks:
- sandbox # Adds container to sandbox network
server:
build: ./server # Sets build context. Will build Dockerfile.
image: server # Tags built image with 'server' tag
container_name: server # Names container server
depends_on:
- db
command: ./manage.py runserver 0.0.0.0:8000 # Runs the development server
entrypoint: /scripts/entrypoint.sh # Runs this script upon starting container
environment: # Sets the environmental variables in the container for connection with DB
- POSTGRES_API_HOST=${POSTGRES_API_HOST:-db}
- POSTGRES_API_NAME=${POSTGRES_API_NAME:-api}
- POSTGRES_API_USER=${POSTGRES_API_USER:-lempira}
- POSTGRES_API_PASSWORD=${POSTGRES_API_PASSWORD:-changeme1234}
- SERVER_SECRET_KEY=${SERVER_SECRET_KEY:-changeme1234}
volumes:
- ./server/src:/app # Binds volume in './server' to '/app' in container
- ./server/scripts/entrypoint.sh:/scripts/entrypoint.sh # Adds entrypoint script to container
- static_files:/app/static # Bind volume to share static files from Django to proxy
ports:
- 8001:8000 # Binds port 8001 in container to port 8000 in host
networks:
- sandbox # Adds container to sandbox network
db:
image: postgres:12 # Pulls image from Docker hub
container_name: db # Names running container
restart: always # Will automatically restart container if it stop.
environment: # Sets the environmental variables in the container
- POSTGRES_PASSWORD=${POSTGRES_API_HOST:-changeme1234}
- POSTGRES_API_HOST= ${POSTGRES_API_HOST:-db}
- POSTGRES_API_NAME=${POSTGRES_API_NAME:-api}
- POSTGRES_API_USER=${POSTGRES_API_USER:-lempira}
- POSTGRES_API_PASSWORD=${POSTGRES_API_PASSWORD:-changeme1234}
volumes:
- postgres_data:/var/lib/postgresql/data/ # Creates named volumes to store DB data.
- ./db/scripts:/docker-entrypoint-initdb.d/ # Places init scripts in location where PG container will execute them on init.
ports:
- 5432:5432 # Binds PG DB port in container to same port in host.
networks:
- sandbox # Adds container sandbox network
dbadmin:
image: dpage/pgadmin4 # Pulls image from Docker Hub
container_name: dbadmin # Sets container name
environment: # Sets environmental variables inside container
- PGADMIN_DEFAULT_EMAIL=${PGADMIN_DEFAULT_EMAIL:[email protected]}
- PGADMIN_DEFAULT_PASSWORD=${PGADMIN_DEFAULT_PASSWORD:-changeme1234}
ports:
- 5050:80 # Binds port 80 in container to host port 5050. Port 80 already used by nginx
networks:
- sandbox # Adds container sandbox network
volumes:
postgres_data: # Create postgres volume to store DB data
static_files: # Create static directory to share between Django and proxy
networks: # Creates the 'sandbox' network to link all containers.
sandbox:
name: sandbox