-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose.yml
93 lines (69 loc) · 2.07 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
version: '3.4'
services:
node:
image: node
# ☃️
build:
context: ./
dockerfile: ./Dockerfile
args:
BUILD_COMMAND: yarn run build
# the UID we'll use to run the app, use 0 if you want root
USER_ID: ${USER_ID} # 🔑
# other env variables needed by the build
NODE_ENV: production
# 🚪 a custom entrypoint to fix permissions
entrypoint: /entrypoint.sh # 🔑
# 🌳
environment:
NODE_ENV: production
DATABASE_URL: ${POSTGRES_CONNECTION_URL}/${POSTGRES_DATABASE}
YARN_DISABLE_SELF_UPDATE_CHECK: "true"
USER_ID: ${USER_ID}
chown_tmp: /tmp
chown_yarn_global_folder: /usr/local/share/.yarn
# 🔗
ports:
- ${NODE_PORT:-8001}:3000
# 👻
restart: "always"
# 🛡️ make everything read-only except the volumes
read_only: true
# always use root here, we'll change the user in the entrypoint
# to $USER_ID
# 🔑
user: "0"
# 📂
volumes:
# a custom entrypoint to fix permissions (depends on su-exec)
- ./entrypoint.sh:/entrypoint.sh # 🔑
# make these directories writable
- /tmp/migrami/node:/tmp
# share yarn cache folder with the other containers
- ./data/yarn-${USER_ID}:/usr/local/share/.cache/yarn
# prevent "cannot find a suitable global folder" warning
- ./data/yarn-${USER_ID}:/usr/local/share/.yarn
# utility scripts
- ./scripts/bin/wait-port:/usr/local/bin/wait-port:ro
# 🔧
working_dir: /app
# 🚀
command: >-
sh -c '
wait-port postgres 5432
&& echo ready; while true; do sleep 100; done
'
postgres:
image: postgres:14-alpine
# 🌳
environment:
POSTGRES_PASSWORD: postgrespassword
# 👻
restart: "always"
# 🛡️ make everything read-only except the volumes
read_only: true
# 📂
volumes:
- ./data/postgres:/var/lib/postgresql/data
- /tmp/${COMPOSE_PROJECT_NAME}/postgres:/tmp
- /tmp/${COMPOSE_PROJECT_NAME}/postgres-var-run:/var/run