-
Notifications
You must be signed in to change notification settings - Fork 0
/
compose.yml
182 lines (177 loc) · 4.93 KB
/
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
###############################################################
# See README for docker setup and package.json
# for docker command aliases
###############################################################
version: "3.8" # latest docker-compose
volumes:
database-data:
database-test-data:
vendor-bundle:
x-db-consumer-env: &db-consumer-env
DATABASE_HOST: partiesforall-postgres
DATABASE_USERNAME: dev
DATABASE_PASSWORD: password
DATABASE_PORT: 5432
x-db-host-env: &postgres-env
POSTGRES_USER: dev
POSTGRES_PASSWORD: password
POSTGRES_DB: development
POSTGRES_HOST_AUTH_METHOD: trust
x-bundle-readonly-volume: &v-bundle-read
type: volume
source: vendor-bundle
target: /usr/src/app/vendor/bundle/
volume:
nocopy: true
x-default-service: &servicedefaults
build: &builddefaults
context: .
ssh:
- default
environment: &ssh-env
SSH_AUTH_SOCK: /ssh-agent/ssh-auth.sock
volumes:
- &ssh-pass /run/host-services/:/ssh-agent # pass through ssh agent
- &cache-app-dir ./:/usr/src/app:cached
- &ssh-keys ~/.ssh/:/root/.ssh:cached # link ssh keys into container so that npm install works with private github repos
restart: on-failure
services:
api:
<<: *servicedefaults
build:
<<: *builddefaults
target: server
environment:
<<: [*ssh-env, *db-consumer-env]
PORT: ${RAILS_PORT:-3000}
PIDFILE: /tmp/pid/rails.pid
RAILS_SERVE_STATIC_FILES: true
ports:
- "23000:${RAILS_PORT:-3000}"
container_name: partiesforall-app
volumes:
- *v-bundle-read
- *ssh-pass
- *cache-app-dir
- *ssh-keys
tmpfs:
- /tmp/pid
depends_on:
postgres:
condition: service_healthy
bundle-installer:
condition: service_completed_successfully
db-migrater:
condition: service_completed_successfully
# Shell only - must be run via `docker compose run`
api-test-shell:
<<: *servicedefaults
profiles:
- test
build:
<<: *builddefaults
target: server
environment:
<<: [*ssh-env, *db-consumer-env]
DATABASE_HOST: partiesforall-postgres-test
RAILS_ENV: test
container_name: partiesforall-shell
volumes:
- *v-bundle-read
- *ssh-pass
- *cache-app-dir
- *ssh-keys
depends_on:
postgres-test:
condition: service_healthy
bundle-installer:
condition: service_completed_successfully
db-migrater-test:
condition: service_completed_successfully
bundle-installer:
<<: *servicedefaults
build:
<<: *builddefaults
dockerfile: Dockerfile
target: bundle-installer
volumes:
- *ssh-pass
- *cache-app-dir
- *ssh-keys
# only container with write access to the bundle directory
- vendor-bundle:/usr/src/app/vendor/bundle/
db-migrater:
<<: *servicedefaults
build:
<<: *builddefaults
dockerfile: Dockerfile
target: db-migrater
environment:
<<: [*ssh-env, *db-consumer-env]
volumes:
- *ssh-pass
- *cache-app-dir
- *ssh-keys
- *v-bundle-read
depends_on:
postgres:
condition: service_healthy
bundle-installer:
condition: service_completed_successfully
db-migrater-test:
<<: *servicedefaults
profiles:
- test
build:
<<: *builddefaults
dockerfile: Dockerfile
target: db-migrater
environment:
<<: [*ssh-env, *db-consumer-env]
DATABASE_HOST: partiesforall-postgres-test
RAILS_ENV: test
volumes:
- *ssh-pass
- *cache-app-dir
- *ssh-keys
- *v-bundle-read
depends_on:
postgres-test:
condition: service_healthy
bundle-installer:
condition: service_completed_successfully
postgres: &postgres-container
container_name: partiesforall-postgres
image: postgres:14-alpine
environment: *postgres-env
ports:
- "25432:5432"
restart: on-failure
volumes:
- database-data:/var/lib/postgresql/data/:cached # persist data even if container shuts down
entrypoint: "docker-entrypoint.sh -i"
healthcheck: &postgres-healthcheck
# we have to hardcode the host and database because health checks are configured during build,
# and docker-compose env vars aren't available in the build
test: "pg_isready -h localhost -U dev -d development"
interval: 5s
timeout: 4s
retries: 3
start_period: 60s
postgres-test:
<<: *postgres-container
profiles:
- test
container_name: partiesforall-postgres-test
environment:
<<: *postgres-env
POSTGRES_DB: test
ports:
- "25433:5432"
volumes:
- database-test-data:/var/lib/postgresql/data/:cached # persist data even if container shuts down
healthcheck:
<<: *postgres-healthcheck
# we have to hardcode the host and database because health checks are configured during build,
# and docker-compose env vars aren't available in the build
test: "pg_isready -h localhost -U dev -d test"