-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose.alpine.yml
90 lines (85 loc) · 2.35 KB
/
docker-compose.alpine.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
84
85
86
87
88
89
90
# compose name
name: docker-compose-learning-alpine
# tell compose to create this all services
services:
# backend app service section
backend:
container_name: golang_container
# set container system environment
environment:
- DB_USER=${DB_USER}
- DB_PASS=${DB_PASS}
- DB_NAME=${DB_NAME}
- DB_HOST=${DB_HOST}
- DB_PORT=${DB_PORT}
# build with given Dockerfile
build:
context: ./go-sample-postgres/
dockerfile: Dockerfile.alpine
# environment file
env_file:
- .env
# port to expose <HOST_PORT>:<CONTAINER_PORT>
ports:
- 8080:8080
# restart policy, The policy always restarts the container until its removal
# https://github.com/compose-spec/compose-spec/blob/master/spec.md#restart
restart: always
# container will waiting postgresdb until condition service is healthy (indicate via healthcheck)
depends_on:
postgresdb:
condition: service_healthy
# container network
networks:
- learning
# frontend web service section
frontend:
container_name: vue_container
# build with given Dockerfile
build:
context: ./vue_sample/
dockerfile: Dockerfile.alpine
# environment file
env_file:
- .env
# port to expose <HOST_PORT>:<CONTAINER_PORT>
ports:
- 80:80
# restart policy, The policy always restarts the container until its removal
# https://github.com/compose-spec/compose-spec/blob/master/spec.md#restart
restart: always
# container network
networks:
- learning
# database service name postgresdb
postgresdb:
# image to pull and use
image: postgres:latest
container_name: postgres_container
environment:
- POSTGRES_USER=${DB_USER}
- POSTGRES_PASSWORD=${DB_PASS}
- POSTGRES_DB=${DB_NAME}
- DATABASE_HOST=${DB_HOST}
env_file:
- .env
ports:
- '5432:5432'
# map persistent data stores
volumes:
- learning_pg_data:/var/lib/postgresql/data
networks:
- learning
# indicator container is healty
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U postgres" ]
interval: 5s
timeout: 5s
retries: 5
# Volume for persistent postgres db data
volumes:
learning_pg_data:
# Networks to be created to facilitate communication between containers
networks:
learning:
driver: bridge