-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yml
102 lines (99 loc) · 2.89 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# https://docs.docker.com/compose/compose-file/05-services/
services:
# https://github.com/docker-library/docs/tree/master/postgres
# https://github.com/docker-library/postgres/blob/master/16/bullseye/Dockerfile
db:
image: postgres
restart: always
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
# here init app db, maybe run below in psql:
# create database hello_phx_prod
POSTGRES_DB: hello_phx_prod
ports:
- 25432:5432
# https://docs.docker.com/compose/compose-file/05-services/#healthcheck
healthcheck:
test: pg_isready -U postgres
interval: 1m30s
timeout: 10s
retries: 3
start_period: 30s
start_interval: 3s
# set shared memory limit when using docker-compose
shm_size: 256mb
# or set shared memory limit when deploy via swarm stack
#volumes:
# - type: tmpfs
# target: /dev/shm
# tmpfs:
# size: 134217728 # 128*2^20 bytes = 128Mb
# # init create db or init seed data here???
# psql:
# image: postgres
# depends_on:
# db:
# condition: service_healthy
# command: >
# sh -c "
# echo test connection by psql
# psql postgresql://postgres:postgres@db:5432/postgres -c 'select current_database()'
# psql postgresql://postgres:postgres@db/hello_phx_prod -c '\\conninfo'
# sleep 500000
# "
# https://github.com/cao7113/hello-phx/pkgs/container/hello-phx
# http://hello-phx-web-1.orb.local/
web:
image: ghcr.io/cao7113/hello-phx
# image: hello-phx-web
# build: .
depends_on:
db:
condition: service_healthy
command: >
sh -c "
echo Runing db migration
bin/migrate
echo Running web server
bin/server
"
# ports:
# - 4000
environment:
#DATABASE_URL: "postgres://postgres:postgres@db:5432/hello_phx_prod"
DATABASE_URL: "ecto://postgres:postgres@db:5432/hello_phx_prod"
SECRET_KEY_BASE: "nVRbwGkshVYZzRYao7G98WZJBSRVqYsyVXZE0NjuSt57hBxwYTI9yPPh0fEaS1z/"
# MIX_ENV: "prod"
# PHX_SERVER: true
PHX_HOST: "localhost"
# PORT: "4000"
# NOTE: not support ECTO_IPV6 in locally docker env???
# ECTO_IPV6: false
# https://docs.docker.com/compose/compose-file/05-services/#healthcheck
healthcheck:
test: bin/hello_phx pid || exit 1
interval: 1m30s
timeout: 10s
retries: 3
start_period: 30s
start_interval: 3s
curl:
image: curlimages/curl:8.8.0
depends_on:
web:
condition: service_healthy
command: >
sh -c "
set -e
# echo ping web
# ping -c 3 web
echo Ping web api
curl -sS http://web:4000/api/ping
echo
echo Get web build info
curl -sS http://web:4000/api
echo
echo Get db urls
curl -sS http://web:4000/api/urls
"