-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompose.yaml
More file actions
105 lines (97 loc) · 2.8 KB
/
compose.yaml
File metadata and controls
105 lines (97 loc) · 2.8 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
services:
frontend:
build: ./frontend
# Set the working directory for runtime (for `command`)
working_dir: /app
# Mount the project directory from the host to the container, allowing for
# live reloads of the application code during development. Also, anonymously
# mount the node_modules directory to persist dependencies across container
# restarts and avoid the need for local installation of packages.
volumes:
- ./frontend:/app
- /app/node_modules
environment:
- NEXT_TELEMETRY_DISABLED=1
- NEXT_PUBLIC_API_URL=http://localhost:${BACKEND_PORT}
ports:
- ${FRONTEND_PORT}:${FRONTEND_PORT}
networks:
- container-network
restart: unless-stopped
depends_on:
- backend
command: npm run dev
backend:
build: ./backend
working_dir: /app
volumes:
- ./backend:/app
- /app/node_modules
environment:
- PORT=${BACKEND_PORT}
- MYSQL_DATABASE
- MYSQL_USER
- MYSQL_PASSWORD
- DATABASE_URL
- SHADOW_DATABASE_URL
# Disable Prisma telemetry
- CHECKPOINT_DISABLE=1
ports:
- ${BACKEND_PORT}:${BACKEND_PORT}
networks:
- container-network
restart: unless-stopped
depends_on:
db:
condition: service_healthy
# Generate the Prisma Client before starting the backend
command: >
sh -c "npx prisma generate
&& npx prisma migrate deploy
&& npm run dev"
db:
image: mysql:8.3
environment:
- MYSQL_DATABASE
- MYSQL_USER
- MYSQL_PASSWORD
- MYSQL_ROOT_PASSWORD
networks:
- container-network
ports:
- ${MYSQL_PORT}:${MYSQL_PORT}
restart: unless-stopped
healthcheck:
test: mysqladmin ping -u ${MYSQL_USER} --password=${MYSQL_PASSWORD}
interval: 5s
timeout: 3s
retries: 5
depends_on:
shadow-db:
condition: service_healthy
# Prisma ORM needs a second, temporary database that is created and deleted
# automatically each time you run prisma migrate dev. Either you add extra
# privileges to the main database user or you create a separate shadow db
# cf https://www.prisma.io/docs/orm/prisma-migrate/understanding-prisma-migrate/shadow-database
shadow-db:
image: mysql:8.3
environment:
- MYSQL_DATABASE=${SHADOW_DATABASE}
- MYSQL_USER
- MYSQL_PASSWORD
- MYSQL_ROOT_PASSWORD
networks:
- container-network
ports:
# Expose the container default MySQL port to the host's chosen port for
# connecting to the shadow db
- ${SHADOW_DB_PORT}:${MYSQL_PORT}
restart: unless-stopped
healthcheck:
test: mysqladmin ping -u ${MYSQL_USER} --password=${MYSQL_PASSWORD}
interval: 5s
timeout: 3s
retries: 5
networks:
container-network:
driver: bridge