forked from sourcerer-io/sourcerer-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
126 lines (120 loc) 路 4.32 KB
/
Copy pathdocker-compose.yml
File metadata and controls
126 lines (120 loc) 路 4.32 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
services:
db:
image: postgres:18-alpine
environment:
POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD must be set}
POSTGRES_DB: ${POSTGRES_DB:-sourcerer}
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-postgres}"]
interval: 10s
timeout: 5s
retries: 5
volumes:
- postgres_data:/var/lib/postgresql
# Mount the schema file to initialize the DB automatically
- ./backend/schema.sql:/docker-entrypoint-initdb.d/init.sql:ro
restart: unless-stopped
deploy:
resources:
limits:
memory: 1g
# Builds the Kotlin extractor jar the backend shells out to. Opt-in so the
# normal `up` path is fast:
# docker compose --profile build run --rm cli-build
# The jar lands in ./cli/build/libs and is mounted read-only into backend.
cli-build:
image: gradle:4.10.3-jdk8
profiles:
- build
working_dir: /home/gradle/project
volumes:
- ./cli:/home/gradle/project
- gradle_cache:/home/gradle/.gradle
# `assemble`, not `build`: the Spek test dependencies resolve from
# dl.bintray.com, which is sunset, so compiling tests would fail. The
# production jar itself has no such dependency.
command: gradle --no-daemon assemble
backend:
build:
# Root context so the image can bake in cli/build/libs/sourcerer-app.jar.
# Run ./build_cli.sh first; .dockerignore keeps the context small.
context: .
dockerfile: backend/Dockerfile
expose:
- "8080"
environment:
- ENV=${ENV:-production}
- DATABASE_URL=host=db user=${POSTGRES_USER:-postgres} password=${POSTGRES_PASSWORD} dbname=${POSTGRES_DB:-sourcerer} sslmode=disable
- GITHUB_CLIENT_ID=${GITHUB_CLIENT_ID:?GITHUB_CLIENT_ID must be set}
- GITHUB_CLIENT_SECRET=${GITHUB_CLIENT_SECRET:?GITHUB_CLIENT_SECRET must be set}
- SESSION_SECRET=${SESSION_SECRET:?SESSION_SECRET must be set}
- API_INTERNAL_TOKEN=${API_INTERNAL_TOKEN:?API_INTERNAL_TOKEN must be set}
- PUBLIC_BASE_URL=${PUBLIC_BASE_URL:-}
- CORS_ALLOWED_ORIGINS=${CORS_ALLOWED_ORIGINS:-}
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://127.0.0.1:8080/healthz"]
interval: 15s
timeout: 5s
retries: 3
start_period: 20s
depends_on:
db:
condition: service_healthy
restart: unless-stopped
deploy:
resources:
limits:
# The JVM extractor runs inside this container; leave it headroom.
memory: 2g
proxy:
image: nginx:1.27-alpine
ports:
- "80:80"
- "443:443"
environment:
- SERVER_NAME=${SERVER_NAME:-_}
- SSL_CERTIFICATE=${SSL_CERTIFICATE:-/etc/nginx/ssl/fullchain.pem}
- SSL_CERTIFICATE_KEY=${SSL_CERTIFICATE_KEY:-/etc/nginx/ssl/privkey.pem}
volumes:
- ./nginx/templates:/etc/nginx/templates:ro
# Runs after the image's own 20-envsubst step; see the script's comment.
- ./nginx/entrypoint.d/99-cert-reload.sh:/docker-entrypoint.d/99-cert-reload.sh:ro
- ./nginx/ssl:/etc/nginx/ssl:ro
- ./certbot/conf:/etc/letsencrypt:ro
- ./certbot/www:/var/www/certbot:ro
healthcheck:
test: ["CMD", "nginx", "-t"]
interval: 30s
timeout: 5s
retries: 3
depends_on:
# nginx resolves upstream hostnames at startup and refuses to start if
# `backend` does not resolve, so waiting for merely "started" makes the
# proxy crash-loop alongside a backend that is still restarting.
backend:
condition: service_healthy
restart: unless-stopped
certbot:
image: certbot/certbot
profiles:
- prod
volumes:
- ./certbot/conf:/etc/letsencrypt
- ./certbot/www:/var/www/certbot
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
# Log viewer. Bound to loopback only: it mounts the Docker socket, which is
# root-equivalent on the host, and ships no authentication of its own.
# Reach it over an SSH tunnel: ssh -L 9999:localhost:9999 <host>
dozzle:
image: amir20/dozzle:latest
profiles:
- debug
ports:
- "127.0.0.1:9999:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
restart: unless-stopped
volumes:
postgres_data:
gradle_cache: