From 8157c30c080cf5850919688c655dc8ce72ba7762 Mon Sep 17 00:00:00 2001 From: kjuulh Date: Sat, 21 Mar 2026 01:13:25 +0100 Subject: [PATCH] feat: add forage and nats Signed-off-by: kjuulh --- docker-compose.yaml | 60 +++++++++++++++++++++++++++++++++++++++++++-- init-databases.sh | 7 ++++++ 2 files changed, 65 insertions(+), 2 deletions(-) create mode 100755 init-databases.sh diff --git a/docker-compose.yaml b/docker-compose.yaml index 432980c..a65105d 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,6 +1,6 @@ services: forest: - image: docker.io/kasperhermansen/forest-server:${FOREST_IMAGE_VERSION:-main} + image: git.kjuulh.io/kasperhermansen/forest:${FOREST_IMAGE_VERSION:-main} restart: always env_file: ".env" command: | @@ -24,6 +24,41 @@ services: postgres: condition: service_healthy restart: true + nats: + condition: service_healthy + restart: true + + forage: + image: git.kjuulh.io/forage/client::${FORAGE_IMAGE_VERSION:-main} + restart: always + env_file: ".env" + command: | + /app/forage serve + ports: + - "3000:3000" + environment: + RUST_LOG: "forage=debug,info" + LOG_LEVEL: short + FORAGE_HOST: 0.0.0.0:3000 + networks: + - public + - internal + healthcheck: + test: ["CMD", "/app/forage", "--external-host", "http://127.0.0.1:3000", "admin", "status"] + interval: 10s + timeout: 10s + retries: 3 + start_period: 30s + depends_on: + forest: + condition: service_healthy + restart: true + postgres: + condition: service_healthy + restart: true + nats: + condition: service_healthy + restart: true postgres: image: postgres:18 @@ -34,6 +69,7 @@ services: - internal volumes: - ./data/postgres/18:/var/lib/postgresql/18/docker + - ./init-databases.sh:/docker-entrypoint-initdb.d/init-databases.sh environment: POSTGRES_USER: forest POSTGRES_DB: forest @@ -56,7 +92,7 @@ services: - internal environment: - POSTGRES_HOST=postgres - - POSTGRES_DB=forest + - POSTGRES_DB=forest,forage - POSTGRES_USER=forest - POSTGRES_EXTRA_OPTS=-Z1 --schema=public --blobs - BACKUP_ON_START=TRUE @@ -66,6 +102,26 @@ services: - BACKUP_KEEP_MONTHS=6 # keep monthly backups for 6 months - HEALTHCHECK_PORT=8080 + nats: + image: nats:2-alpine + restart: always + command: | + -js -sd /data + networks: + - internal + ports: + - 4222:4222 + - 6222:6222 + - 8222:8222 + volumes: + ./data/nats/data:/data + healthcheck: + test: wget http://localhost:8222/healthz -q -S -O - + start_period: 3s + retries: 3 + timeout: 3s + interval: 14s + networks: public: internal: diff --git a/init-databases.sh b/init-databases.sh new file mode 100755 index 0000000..3b7ba71 --- /dev/null +++ b/init-databases.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -e + +psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL + CREATE USER forage WITH PASSWORD '$FORAGE_POSTGRES_PASSWORD'; + CREATE DATABASE forage OWNER forage; +EOSQL