Created
May 12, 2023 01:54
-
-
Save pirogoeth/7f83012463165dd0cf524bd4ce6ebf0f to your computer and use it in GitHub Desktop.
coder provisioner server w/ tailscale router
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3.9" | |
networks: | |
backend: {} | |
outbound: {} | |
tailnet: | |
ipam: | |
driver: default | |
config: | |
- subnet: 172.20.0.0/16 | |
ip_range: 172.20.0.0/24 | |
gateway: 172.20.0.1 | |
servicenet: | |
external: true | |
volumes: | |
coder-data: | |
external: true | |
tailscale-data: {} | |
services: | |
coder: | |
# This MUST be stable for our documentation and | |
# other automations. | |
image: ghcr.io/coder/coder:${CODER_VERSION:-latest} | |
environment: | |
CODER_PG_CONNECTION_URL: "postgresql://${POSTGRES_USER:-username}:${POSTGRES_PASSWORD:-password}@database/${POSTGRES_DB:-coder}?sslmode=disable" | |
CODER_ADDRESS: "0.0.0.0:7080" | |
# You'll need to set CODER_ACCESS_URL to an IP or domain | |
# that workspaces can reach. This cannot be localhost | |
# or 127.0.0.1 for non-Docker templates! | |
CODER_ACCESS_URL: "${CODER_ACCESS_URL}" | |
# If the coder user does not have write permissions on | |
# the docker socket, you can uncomment the following | |
# lines and set the group ID to one that has write | |
# permissions on the docker socket. | |
group_add: | |
- "997" # docker group on host | |
volumes: | |
- /var/run/docker.sock:/var/run/docker.sock | |
depends_on: | |
database: | |
condition: service_healthy | |
networks: | |
- servicenet | |
- backend | |
labels: | |
- "appname=coder" | |
- "traefik.enable=true" | |
- "traefik.http.routers.coder.rule=Host(`${FRONTEND_HOST}`)" | |
- "traefik.http.routers.coder.entrypoints=web-secure" | |
- "traefik.http.routers.coder.service=coder" | |
- "traefik.http.routers.coder.tls=true" | |
- "traefik.http.routers.coder.tls.certResolver=default-le" | |
- "traefik.http.services.coder.loadbalancer.server.port=7080" | |
- "traefik.http.services.coder.loadbalancer.passhostheader=true" | |
database: | |
image: "postgres:14.2" | |
environment: | |
POSTGRES_USER: ${POSTGRES_USER:-username} # The PostgreSQL user (useful to connect to the database) | |
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-password} # The PostgreSQL password (useful to connect to the database) | |
POSTGRES_DB: ${POSTGRES_DB:-coder} # The PostgreSQL default database (automatically created at first launch) | |
volumes: | |
- coder-data:/var/lib/postgresql/data # Use "docker volume rm coder-data" to reset Coder | |
networks: | |
- backend | |
healthcheck: | |
test: | |
[ | |
"CMD-SHELL", | |
"pg_isready -U ${POSTGRES_USER:-username} -d ${POSTGRES_DB:-coder}", | |
] | |
interval: 5s | |
timeout: 5s | |
retries: 5 | |
tailscale: | |
image: "tailscale/tailscale:stable" | |
cap_add: | |
- NET_ADMIN | |
- NET_RAW | |
environment: | |
TS_AUTHKEY: "${TS_AUTHKEY}" | |
TS_ACCEPT_DNS: "${TS_ACCEPT_DNS:-true}" | |
TS_EXTRA_ARGS: "${TS_EXTRA_ARGS}" | |
TS_ROUTES: "${TS_ROUTES:-172.20.0.0/24}" | |
TS_USERSPACE: "${TS_USERSPACE:-false}" | |
volumes: | |
- tailscale-data:/var/lib | |
devices: | |
- /dev/net/tun:/dev/net/tun | |
sysctls: | |
net.ipv4.ip_forward: 1 | |
net.ipv6.conf.all.forwarding: 1 | |
networks: | |
- outbound | |
- tailnet |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment