-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocker-compose.yml
186 lines (172 loc) · 5.76 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
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
############# Run Via CLI #################
# yarn scripts docker build
# yarn scripts docker run
# TODO - add common logging methods
services:
nginx-proxy:
image: nginxproxy/nginx-proxy
container_name: sami_webserver
ports:
- 80:80
- 443:443
volumes:
# Custom virtual host overrides
- ./docker/nginx/vhost.d:/etc/nginx/vhost.d:ro
# Generated default and global override conf
- ./docker/nginx/conf.d:/etc/nginx/conf.d
# SSL Certs
- html:/usr/share/nginx/html
- dhparam:/etc/nginx/dhparam
- ./docker/nginx/certs:/etc/nginx/certs:ro
- /var/run/docker.sock:/tmp/docker.sock:ro
networks:
- webserver
acme-companion:
image: nginxproxy/acme-companion
container_name: nginx-proxy-acme
environment:
NGINX_PROXY_CONTAINER: sami_webserver
# Testing certs
ACME_CA_URI: https://acme-staging-v02.api.letsencrypt.org/directory
volumes:
- ./docker/nginx/certs:/etc/nginx/certs:rw
- acme:/etc/acme.sh
- html:/usr/share/nginx/html
- dhparam:/etc/nginx/dhparam
- ./docker/nginx/vhost.d:/etc/nginx/vhost.d
- /var/run/docker.sock:/var/run/docker.sock:ro
backend:
profiles: [backend]
container_name: sami_backend
image: samicharity/backend:latest
restart: unless-stopped
ports:
- "1337:1337"
volumes:
# Uploads folder shared between frontend and backend for easier access
- ./docker/data/public:/app/public
- ./docker/data/db:/app/data/db
env_file:
- ./config/docker.env
- ./config/docker.local.env
environment:
# Load docker configuration
- NODE_ENV=docker
- DB_DIR=/app/data/db
# Local config (required if deploying to cloud run)
# - STRAPI_READONLY_TOKEN=
healthcheck:
test: "wget --no-verbose --tries=1 --spider http://localhost:1337 || exit 1"
interval: 30s
timeout: 30s
retries: 3
start_period: 30s
deploy:
resources:
limits:
cpus: "0.5"
memory: 2GB
reservations:
cpus: "0.1"
memory: 500M
networks:
- webserver
frontend:
profiles: [frontend]
container_name: sami_frontend
image: samicharity/frontend:latest
# command: "/bin/ash -c 'while sleep 3600; do :; done'"
restart: unless-stopped
# Env inlined during build however when running `next dev` can use on start
# TODO - ensure populated correctly
env_file:
- ./config/docker.env
- ./config/docker.local.env
volumes:
# Public folder shared between frontend and backend for easier access
- ./docker/data/public:/app/public
environment:
VIRTUAL_HOST: ${PUBLIC_DOMAIN}
VIRTUAL_PORT: "3000"
# TODO - configure for production and env vars
LETSENCRYPT_HOST: ${PUBLIC_DOMAIN}
LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL}
# Healthcheck can be slow, just start optimistically
# depends_on:
# backend:
# condition: service_healthy
ports:
- "3000:3000"
networks:
- webserver
# #####################################################################################
# Local development (windows)
# Sync local ./docker/data folders with Google Cloud Storage via gcsfuse and unison
# https://blog.konpat.me/dev/2017/02/26/docker-recipe-for-gcsfuse-google-cloud-storage-fuse-2.html
# #####################################################################################
gcs_fuse:
profiles: [gcs_fuse]
container_name: gcs_fuse
image: samicharity/gcs_fuse:latest
volumes:
- ./docker/data/db:/data/db
- ./docker/data/public:/data/public
- ./backend/config/service-account.json:/service-account.json
environment:
- GCP_PROJECT=sami-website-365718
- GCS_DB_BUCKET_NAME=sami_website_db
- GCS_PUBLIC_BUCKET_NAME=sami_website_public
- GCSFUSE_MNT=/mnt/gcs
- UNISON_MNT=/data
- GOOGLE_APPLICATION_CREDENTIALS=/service-account.json
privileged: true
deploy:
resources:
limits:
cpus: "0.5"
memory: 500M
reservations:
cpus: "0.05"
memory: 50M
# command: "/bin/ash -c 'while sleep 3600; do :; done'"
# If using Postgres
# db:
# container_name: sami_db
# platform: linux/amd64 #for platform error on Apple M1 chips
# restart: unless-stopped
# env_file:
# - ./config/docker.env
# - ./config/docker.local.env
# image: postgres:12.0-alpine
# environment:
# POSTGRES_USER: ${DATABASE_USERNAME}
# POSTGRES_PASSWORD: ${DATABASE_PASSWORD}
# POSTGRES_DB: ${DATABASE_NAME}
# volumes:
# - db-data:/var/lib/postgresql/data/ #using a volume
# networks:
# - webserver
networks:
webserver:
volumes:
html:
dhparam:
certs:
acme:
# TODO find a way to run nginx reverse proxy and dashboard on path
# https://docs.strapi.io/dev-docs/deployment/nginx-proxy
# https://forum.strapi.io/t/strapi-in-subfolder-issue/13401/4
#######################################################################################
# Legacy Notes - to confirm if still required
#######################################################################################
# Expose on 127.0.0.1 instead of default 0.0.0.0 as next.js rewrites localhost to this
# https://earthly.dev/blog/youre-using-docker-compose-wrong/
# https://github.com/vercel/next.js/issues/27865
# NOTE - might not work in WSL (?) https://github.com/docker/for-win/issues/13182
#######################################################################################
# Deprecated - use build from cli instead of compose (to ensure base builds correctly)
#######################################################################################
# build:
# dockerfile: ./docker/base.dockerfile
# tags:
# - "samicharity/base:1.0.0"