-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdocker-compose.yaml
More file actions
279 lines (276 loc) · 8.62 KB
/
docker-compose.yaml
File metadata and controls
279 lines (276 loc) · 8.62 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
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
# This is used by my editors LSP for autocomplete
# yaml-language-server: $schema=https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json
# This specifies the networks our containers are going to use.
# We are only using one network since this mostly for development, and it just keeps things tidy
networks:
app_network:
driver: bridge
# This is a named volume. It is used because of a an issue I was facing with permissions when mounting a volume for the database
volumes:
pgdata:
minio_data:
mc_data:
# Specifies the services that Docker Compose will start if we run this compose file
services:
# This service is the web app. For the source code, checkout the web directory
web:
# This specifies the docker file/context to build for the web app container
build:
context: .
dockerfile: ./web/dev.Dockerfile
# Attach this container to our dedicated network for the services in this compose file
networks:
- app_network
volumes:
- ./pnpm-lock.yaml:/app/pnpm-lock.yaml
- ./web:/app/web
- /app/node_modules
- /app/web/node_modules
# Expose the port that the web app uses so you can access it at localhost:3000
ports:
- 3000:3000
# Use the .env file from the web dir
env_file:
- ./web/.env
environment:
CHOKIDAR_USEPOLLING: true
# This container will wait for the api container to start before starting
depends_on:
- api
# This is used for dev purposes so we can auto reload containers wehen files change
develop:
watch:
- path: ./web/package.json
action: rebuild
# This service is the api. For the source code, checkout the api directory
api:
# This specifies the docker file/context to build for the api container
build:
context: ./api
dockerfile: dev.Dockerfile
# Attach this container to our dedicated network for the services in this compose file
networks:
- app_network
# Expose the port that the api uses so you can access it at localhost:8000
ports:
- 8000:8000
# Use the .env file from the api dir
env_file:
- ./api/.env
# This container will wait for the db container to start before starting
depends_on:
- db
- object-storage
links:
- db:postgres
- object-storage:minio
# This is used for dev purposes so we can auto reload containers wehen files change
develop:
watch:
- path: ./api/go.mod
action: rebuild
- path: ./api
target: /app
action: sync+restart
# This service is the database
db:
# We are using the PostgreSQL v16 image for this container
image: postgres:16
# Expose the default port for if we need to access the database from tools outside the docker context
ports:
- 5432:5432
# Attach this container to our dedicated network for the services in this compose file
networks:
- app_network
restart: unless-stopped
# Mount a local volume so the db data will persist on your local machine
volumes:
# pgdata is a dedicated volume mount specified earlier in the file under `volumes:`
- pgdata:/var/lib/postgresql/data
# Some environment variables to get this container up and running
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: forkd
object-storage:
image: minio/minio:RELEASE.2025-06-13T11-33-47Z
command: server --console-address ":9001" /data
ports:
- "9000:9000"
- "9001:9001"
networks:
- app_network
volumes:
- "minio_data:/data"
environment:
- MINIO_ROOT_USER=minio
- MINIO_ROOT_PASSWORD=minio-password
- MINIO_DEFAULT_BUCKETS=forkd
# A web admin for postgres
pgweb:
# Use the docker image for this web admin
image: sosedoff/pgweb:0.16.2
restart: unless-stopped
# Expose port 8081 to the local machine so you can access it at localhost:8081
ports:
- 8081:8081
# This container will wait for the db container to start before starting
depends_on:
- db
links:
- db:postgres
# Attach this container to our dedicated network for the services in this compose file
networks:
- app_network
# Environment variables the pgweb container needs to communicate with out database
environment:
PGWEB_DATABASE_URL: postgres://postgres:postgres@postgres:5432/postgres?sslmode=disable
# All services below here are used for one off script runs
# A container to run database migrations
gqlgen:
# Use the gqlgen.Dockerfile for this script
build:
context: ./api
dockerfile: gqlgen.Dockerfile
# Never restart this container
restart: no
# Mount our migrations directory so the geni cli can access those files
volumes:
- ./api/graph:/app/graph
# Attach this container to our dedicated network for the services in this compose file
networks:
- app_network
# This is important, we assign a profile so this container doesn't auto start when you run `docker-compose start`
profiles:
- "scripts"
# A container to run database migrations
migrate:
# Use the `migrate` docker image for https://github.com/golang-migrate/migrate
image: migrate/migrate:4
# Never restart this container
restart: no
# This container will wait for the db container to start before starting
depends_on:
- db
links:
- db:postgres
# Some environment variables required for the geni cli to function
environment:
DATABASE_URL: postgres://postgres:postgres@postgres:5432/postgres?sslmode=disable
# Mount our migrations directory so the geni cli can access those files
volumes:
- ./db/migrations/:/migrations
# Attach this container to our dedicated network for the services in this compose file
networks:
- app_network
# This is important, we assign a profile so this container doesn't auto start when you run `docker-compose start`
profiles:
- "scripts"
# A container to run SQLc gen
sqlc:
# Use the `sqlc` docker image for https://docs.sqlc.dev/en/stable/overview/install.html#docker
image: sqlc/sqlc:1.28.0
# Never restart this container
restart: no
# This container will wait for the db container to start before starting
depends_on:
- db
links:
- db:postgres
# Mount our db and app directories so the sqlc cli can access those files
volumes:
- ./db/:/db
- ./api:/app
working_dir: /app
# Attach this container to our dedicated network for the services in this compose file
networks:
- app_network
# This is important, we assign a profile so this container doesn't auto start when you run `docker-compose start`
profiles:
- "scripts"
mc:
image: minio/mc:RELEASE.2025-05-21T01-59-54Z
restart: no
depends_on:
- object-storage
links:
- object-storage:minio
networks:
- app_network
volumes:
- "minio_data:/root/.mc"
profiles:
- "scripts"
# Container to run golangci-lint
golangci-lint:
image: golangci/golangci-lint:v2.2.1-alpine
restart: no
volumes:
- ./api:/app
working_dir: /app
profiles:
- "scripts"
gofmt:
image: golang:1.23-alpine
restart: no
volumes:
- ./api:/app
working_dir: /app
profiles:
- "scripts"
eslint:
build:
context: .
dockerfile: ./eslint.Dockerfile
restart: no
volumes:
- ./:/app
profiles:
- "scripts"
prettier:
build:
context: .
dockerfile: ./prettier.Dockerfile
restart: no
volumes:
- ./:/app
profiles:
- "scripts"
sqlfluff:
image: sqlfluff/sqlfluff:3.4.2
restart: no
volumes:
- ./db:/db
working_dir: /db
profiles:
- "scripts"
seed:
# This specifies the docker file/context to build for the api container
build:
context: ./api
dockerfile: seed.Dockerfile
# Attach this container to our dedicated network for the services in this compose file
networks:
- app_network
# Expose the port that the api uses so you can access it at localhost:8000
# Use the .env file from the api dir
env_file:
- ./api/.env
# This container will wait for the db container to start before starting
depends_on:
- db
- object-storage
links:
- db:postgres
- object-storage:minio
profiles:
- "scripts"
commitizen:
# This specifies the docker file/context to build for the api container
build:
context: .
dockerfile: commitizen.Dockerfile
volumes:
- .:/app
profiles:
- "scripts"