-
Notifications
You must be signed in to change notification settings - Fork 116
Expand file tree
/
Copy pathcompose.yml
More file actions
128 lines (123 loc) · 5.39 KB
/
Copy pathcompose.yml
File metadata and controls
128 lines (123 loc) · 5.39 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
configs:
ts-serve:
content: |
{"TCP":{"443":{"HTTPS":true}},
"Web":{"$${TS_CERT_DOMAIN}:443":
{"Handlers":{"/":
{"Proxy":"http://127.0.0.1:3010"}}}},
"AllowFunnel":{"$${TS_CERT_DOMAIN}:443":false}}
services:
# Make sure you have updated/checked the .env file with the correct variables.
# All the ${ xx } need to be defined there.
# Tailscale Sidecar Configuration
tailscale:
image: tailscale/tailscale:latest # Image to be used
container_name: tailscale-${SERVICE} # Name for local container management
hostname: ${SERVICE} # Name used within your Tailscale environment
environment:
- TS_AUTHKEY=${TS_AUTHKEY}
- TS_STATE_DIR=/var/lib/tailscale
- TS_SERVE_CONFIG=/config/serve.json # Tailscale Serve configuration to expose the web interface on your local Tailnet - remove this line if not required
- TS_USERSPACE=false
- TS_ENABLE_HEALTH_CHECK=true # Enable healthcheck endpoint: "/healthz"
- TS_LOCAL_ADDR_PORT=127.0.0.1:41234 # The <addr>:<port> for the healthz endpoint
#- TS_ACCEPT_DNS=true # Uncomment when using MagicDNS
- TS_AUTH_ONCE=true
configs:
- source: ts-serve
target: /config/serve.json
volumes:
- ./config:/config # Config folder used to store Tailscale files - you may need to change the path
- ./ts/state:/var/lib/tailscale # Tailscale requirement - you may need to change the path
devices:
- /dev/net/tun:/dev/net/tun # Network configuration for Tailscale to work
cap_add:
- net_admin # Tailscale requirement
#ports:
# - 0.0.0.0:${SERVICEPORT}:${SERVICEPORT} # Binding port ${SERVICE}PORT to the local network - may be removed if only exposure to your Tailnet is required
# If any DNS issues arise, use your preferred DNS provider by uncommenting the config below
# dns:
# - ${DNS_SERVER}
healthcheck:
test: [ "CMD", "wget", "--spider", "-q", "http://127.0.0.1:41234/healthz" ] # Check Tailscale has a Tailnet IP and is operational
interval: 1m # How often to perform the check
timeout: 10s # Time to wait for the check to succeed
retries: 3 # Number of retries before marking as unhealthy
start_period: 10s # Time to wait before starting health checks
restart: always
# ${SERVICE}
application:
image: ghcr.io/toeverything/affine:${AFFINE_REVISION:-stable} # Image to be used
container_name: app-${SERVICE} # Name for local container management
network_mode: service:tailscale # Sidecar configuration to route ${SERVICE} through Tailscale
depends_on:
redis:
condition: service_healthy
postgres:
condition: service_healthy
affine_migration:
condition: service_completed_successfully
volumes:
# custom configurations
- ./${SERVICE}-data/storage:/root/.affine/storage
- ./${SERVICE}-data/config:/root/.affine/config
env_file:
- .env
environment:
# Varibles are delared in .env file.
- REDIS_SERVER_HOST=redis
- DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${postgres:-affine}
- AFFINE_INDEXER_ENABLED=false
#- EXAMPLE_VAR=${EXAMPLE_VAR}
restart: always
affine_migration:
image: ghcr.io/toeverything/affine:${AFFINE_REVISION:-stable} # Image to be used
container_name: affine_migration_job # Name for local container management
volumes:
# custom configurations
- ./${SERVICE}-data/storage:/root/.affine/storage
- ./${SERVICE}-data/config:/root/.affine/config
command: [ 'sh', '-c', 'node ./scripts/self-host-predeploy.js' ]
env_file:
- .env
environment:
# Varibles are delared in .env file.
- REDIS_SERVER_HOST=redis
- DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${postgres:-affine}
- AFFINE_INDEXER_ENABLED=false
#- EXAMPLE_VAR=${EXAMPLE_VAR}
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
redis:
image: redis # Image to be used
container_name: affine_redis # Name for local container management
healthcheck:
test: [ 'CMD', 'redis-cli', '--raw', 'incr', 'ping' ] # Check if redis process is running
interval: 10s # How often to perform the check
timeout: 5s # Time to wait for the check to succeed
retries: 5 # Number of retries before marking as unhealthy
restart: always
postgres:
image: pgvector/pgvector:pg16 # Image to be used
container_name: affine_postgres # Name for local container management
volumes:
- ./${SERVICE}-data/postgres:/var/lib/postgresql/data
environment:
# Varibles are delared in .env file.
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DB=${postgres:-affine}
- POSTGRES_INITDB_ARGS='--data-checksums'
# you better set a password for you database
# or you may add 'POSTGRES_HOST_AUTH_METHOD=trust' to ignore postgres security policy
- POSTGRES_HOST_AUTH_METHOD=trust
#- EXAMPLE_VAR=${EXAMPLE_VAR}
healthcheck:
test: [ 'CMD', 'pg_isready', '-U', "${DB_USERNAME}", '-d', "${postgres:-affine}" ] # Check if postgres process is running
interval: 15s # How often to perform the check
timeout: 5s # Time to wait for the check to succeed
retries: 5 # Number of retries before marking as unhealthy
restart: always