commit 621f6a870fde64accb2e09742dee655abb1c6ec2 Author: imbytecat Date: Tue May 12 03:36:38 2026 +0800 chore: init docker compose for caddy, postgres, watchtower diff --git a/docker/caddy/compose.yaml b/docker/caddy/compose.yaml new file mode 100644 index 0000000..be43695 --- /dev/null +++ b/docker/caddy/compose.yaml @@ -0,0 +1,16 @@ +services: + caddy: + image: caddy:latest + restart: unless-stopped + ports: + - 80:80 + - 443:443 + - 443:443/udp + volumes: + - ./volumes/Caddyfile:/etc/caddy/Caddyfile + - ./volumes/data:/data + - ./volumes/config:/config + +networks: + default: + name: caddy diff --git a/docker/caddy/volumes/Caddyfile b/docker/caddy/volumes/Caddyfile new file mode 100644 index 0000000..0f00d98 --- /dev/null +++ b/docker/caddy/volumes/Caddyfile @@ -0,0 +1,11 @@ +spa.example.com { + root * /srv/spa + encode zstd gzip + try_files {path} /index.html + file_server +} + +app.example.com { + encode zstd gzip + reverse_proxy fullstack:3000 +} diff --git a/docker/postgres/.env.example b/docker/postgres/.env.example new file mode 100644 index 0000000..07cfbd5 --- /dev/null +++ b/docker/postgres/.env.example @@ -0,0 +1,2 @@ +POSTGRES_USER=postgres +POSTGRES_PASSWORD=postgres diff --git a/docker/postgres/compose.yaml b/docker/postgres/compose.yaml new file mode 100644 index 0000000..75740e1 --- /dev/null +++ b/docker/postgres/compose.yaml @@ -0,0 +1,23 @@ +services: + postgres: + image: postgres:18 + restart: unless-stopped + ports: + - 5432:5432 + volumes: + - ./volumes/data:/var/lib/postgresql + environment: + TZ: Asia/Shanghai + POSTGRES_USER: ${POSTGRES_USER} + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} + healthcheck: + test: + - CMD-SHELL + - pg_isready -U postgres + interval: 1s + timeout: 5s + retries: 10 + +networks: + default: + name: db diff --git a/docker/watchtower/compose.yaml b/docker/watchtower/compose.yaml new file mode 100644 index 0000000..7ee4f6f --- /dev/null +++ b/docker/watchtower/compose.yaml @@ -0,0 +1,9 @@ +services: + watchtower: + image: nickfedor/watchtower:latest + restart: unless-stopped + volumes: + - /var/run/docker.sock:/var/run/docker.sock + environment: + - TZ=Asia/Shanghai + command: --cleanup --interval 7200