Repository navigation
Expand file tree
/
Copy pathdocker-compose-prod.yaml
More file actions
64 lines (54 loc) · 1.53 KB
/
Copy pathdocker-compose-prod.yaml
File metadata and controls
64 lines (54 loc) · 1.53 KB
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
version: '3.9'
# instruction at the end of file
volumes:
postgres_data:
static:
media:
nginx_conf:
services:
db:
image: postgres:12.4
restart: always
volumes:
- postgres_data:/var/lib/postgresql/data/
env_file:
- ./.env
django:
image: matakov/django-docker:latest
depends_on:
- db
restart: always
env_file:
- ./.env
volumes:
- static:/code/static
- media:/code/media
- nginx_conf:/code/nginx/
entrypoint: /code/entrypoint.sh
environment:
- DEBUG=0
nginx:
image: nginx:1.19.0-alpine
ports:
- "127.0.0.1:1122:80"
volumes:
- static:/code/static
- media:/code/media
- nginx_conf:/etc/nginx/conf.d/
depends_on:
- django
restart: always
#### STEP 0 #### Create new context to remote control your server docker
# docker context create new_ip --docker "host=ssh://username@ip"
#### STEP 1 #### Build and push your docker image on local PC (use variables in .env)
# docker build -t username/project:latest .
# docker push username/project:latest
#### STEP 2 #### Switch to remote server docker
# docker context use new_ip
#### STEP 3 #### Down your compose, pull new image, up your compose
# docker compose -f docker-compose-prod.yaml down
# here consider deleting static volume if you have static files modified
# docker pull username/project:latest
# docker compose -f docker-compose-prod.yaml up -d --force-recreate
#### STEP 4 #### Don't forget to switch back to your local docker
# docker context use default