From f5c90ae842399f6344b6bdd4bd510dc04791a63a Mon Sep 17 00:00:00 2001 From: thierrycoopman Date: Wed, 21 Jan 2026 10:52:06 +0100 Subject: [PATCH 1/3] feat: add Dockerfile and docker-compose configuration for standalone wallets service --- Dockerfile | 27 ++++++++++ deployments/docker-compose/Caddyfile | 39 +++++++++++++++ docker-compose.yml | 75 ++++++++++++++++++++++++++++ 3 files changed, 141 insertions(+) create mode 100644 Dockerfile create mode 100644 deployments/docker-compose/Caddyfile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6887463 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +FROM golang:1.24-alpine AS builder + +RUN apk add --no-cache git ca-certificates + +WORKDIR /src + +# Cache dependencies +COPY go.mod go.sum ./ +RUN go mod download + +# Copy source +COPY . . + +# Build +RUN CGO_ENABLED=0 GOOS=linux go build -o /wallets . + +# Final image +FROM alpine:3.19 + +RUN apk add --no-cache ca-certificates curl + +COPY --from=builder /wallets /usr/bin/wallets + +ENV OTEL_SERVICE_NAME=wallets + +ENTRYPOINT ["/usr/bin/wallets"] +CMD ["serve"] diff --git a/deployments/docker-compose/Caddyfile b/deployments/docker-compose/Caddyfile new file mode 100644 index 0000000..4f60590 --- /dev/null +++ b/deployments/docker-compose/Caddyfile @@ -0,0 +1,39 @@ +{ + admin off + auto_https off +} + +:80 { + # Route ledger API requests + handle /api/ledger/* { + uri strip_prefix /api/ledger + reverse_proxy ledger:3068 + } + + # Route wallets API requests + handle /api/wallets/* { + uri strip_prefix /api/wallets + reverse_proxy wallets:8081 + } + + # Health check endpoint + handle /_healthcheck { + respond "OK" 200 + } + + # Service info endpoint + handle /_info { + header Content-Type application/json + respond `{"services":{"ledger":"/api/ledger","wallets":"/api/wallets"},"version":"standalone"}` 200 + } + + # Catch-all for unknown /api/* routes + handle /api/* { + respond "Bad Gateway" 502 + } + + # Default handler + handle { + respond "Not Found" 404 + } +} diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..0cd68e0 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,75 @@ +volumes: + postgres: + +services: + # API Gateway - routes to ledger and wallets + gateway: + image: caddy:2-alpine + healthcheck: + test: ["CMD", "wget", "-q", "--spider", "http://127.0.0.1:80/_healthcheck"] + interval: 5s + timeout: 3s + retries: 10 + depends_on: + ledger: + condition: service_healthy + ports: + - "${GATEWAY_PORT:-8080}:80" + volumes: + - ./deployments/docker-compose/Caddyfile:/etc/caddy/Caddyfile + + # PostgreSQL database for Ledger + postgres: + image: postgres:16-alpine + healthcheck: + test: ["CMD-SHELL", "pg_isready -U ledger"] + interval: 10s + timeout: 5s + retries: 5 + environment: + POSTGRES_USER: ledger + POSTGRES_PASSWORD: ledger + POSTGRES_DB: ledger + command: -c max_connections=200 + # Uncomment for persistent data: + # volumes: + # - postgres:/var/lib/postgresql/data + + # Ledger service - the backing store for wallets + ledger: + image: ghcr.io/formancehq/ledger:latest + healthcheck: + test: ["CMD", "curl", "-f", "http://127.0.0.1:3068/_healthcheck"] + interval: 10s + timeout: 5s + retries: 10 + depends_on: + postgres: + condition: service_healthy + ports: + - "${LEDGER_PORT:-3068}:3068" + environment: + DEBUG: ${DEBUG:-true} + POSTGRES_URI: postgres://ledger:ledger@postgres:5432/ledger?sslmode=disable + EXPERIMENTAL_FEATURES: "true" + AUTO_UPGRADE: "true" + + # Wallets service (runs from local source) + wallets: + image: golang:1.24-alpine + healthcheck: + test: ["CMD", "wget", "-q", "--spider", "http://127.0.0.1:8081/_healthcheck"] + interval: 10s + timeout: 5s + retries: 10 + depends_on: + gateway: + condition: service_healthy + ports: + - "${WALLETS_PORT:-8082}:8081" + volumes: + - .:/src + working_dir: /src + environment: + DEBUG: ${DEBUG:-true} + command: ["go", "run", ".", "serve", "--stack-url", "http://gateway", "--ledger", "wallets-001", "--listen", ":8081"] From 414c747a59e970fd841b93bee296030014105a23 Mon Sep 17 00:00:00 2001 From: thierrycoopman Date: Wed, 21 Jan 2026 11:53:44 +0100 Subject: [PATCH 2/3] chore: update goVersion to 24 in flake.nix and refresh flake.lock --- flake.lock | 40 +++++++++------------------------------- flake.nix | 2 +- 2 files changed, 10 insertions(+), 32 deletions(-) diff --git a/flake.lock b/flake.lock index 821b90b..a851d5c 100644 --- a/flake.lock +++ b/flake.lock @@ -23,12 +23,12 @@ }, "nixpkgs": { "locked": { - "lastModified": 1737062831, - "narHash": "sha256-Tbk1MZbtV2s5aG+iM99U8FqwxU/YNArMcWAv6clcsBc=", - "rev": "5df43628fdf08d642be8ba5b3625a6c70731c19c", - "revCount": 738982, + "lastModified": 1768886240, + "narHash": "sha256-C2TjvwYZ2VDxYWeqvvJ5XPPp6U7H66zeJlRaErJKoEM=", + "rev": "80e4adbcf8992d3fd27ad4964fbb84907f9478b0", + "revCount": 930839, "type": "tarball", - "url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.1.738982%2Brev-5df43628fdf08d642be8ba5b3625a6c70731c19c/01947627-561b-7a9f-a379-f9ac4c680cb0/source.tar.gz" + "url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.1.930839%2Brev-80e4adbcf8992d3fd27ad4964fbb84907f9478b0/019bdece-8709-77ea-a1d6-9d410df27131/source.tar.gz" }, "original": { "type": "tarball", @@ -40,15 +40,14 @@ "flake-parts": "flake-parts", "nixpkgs": [ "nixpkgs" - ], - "treefmt-nix": "treefmt-nix" + ] }, "locked": { - "lastModified": 1737355203, - "narHash": "sha256-nJ2OakILvf7Z+4jl1z/db91YdzHr9QRmGJEXBXJj9WM=", + "lastModified": 1768987531, + "narHash": "sha256-OUuPCbbpt2TScCThL4xPByL5U7gOXQ83aJvXbtcnV9Y=", "owner": "nix-community", "repo": "NUR", - "rev": "faa786a8b89e71301d620cb1320df7b2195d8b54", + "rev": "8e6425272de3f758a3b7103b49d6b7edbfb01b40", "type": "github" }, "original": { @@ -62,27 +61,6 @@ "nixpkgs": "nixpkgs", "nur": "nur" } - }, - "treefmt-nix": { - "inputs": { - "nixpkgs": [ - "nur", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1733222881, - "narHash": "sha256-JIPcz1PrpXUCbaccEnrcUS8jjEb/1vJbZz5KkobyFdM=", - "owner": "numtide", - "repo": "treefmt-nix", - "rev": "49717b5af6f80172275d47a418c9719a31a78b53", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "treefmt-nix", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 467e161..022bc85 100644 --- a/flake.nix +++ b/flake.nix @@ -12,7 +12,7 @@ outputs = { self, nixpkgs, nur }: let - goVersion = 23; + goVersion = 24; supportedSystems = [ "x86_64-linux" From e72966d2f18cd6e782660e476ae849eb562d0e71 Mon Sep 17 00:00:00 2001 From: thierrycoopman Date: Wed, 21 Jan 2026 11:59:33 +0100 Subject: [PATCH 3/3] chore: suppress staticcheck warnings for ginkgo imports in testserver.go --- pkg/testserver/testserver.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/testserver/testserver.go b/pkg/testserver/testserver.go index 0262207..a52b1f0 100644 --- a/pkg/testserver/testserver.go +++ b/pkg/testserver/testserver.go @@ -5,10 +5,10 @@ import ( "github.com/formancehq/go-libs/v3/httpserver" "github.com/formancehq/go-libs/v3/testing/deferred" "github.com/formancehq/go-libs/v3/testing/testservice" - . "github.com/formancehq/go-libs/v3/testing/testservice/ginkgo" + . "github.com/formancehq/go-libs/v3/testing/testservice/ginkgo" //nolint:staticcheck "github.com/formancehq/wallets/cmd" walletsclient "github.com/formancehq/wallets/pkg/client" - . "github.com/onsi/ginkgo/v2/dsl/core" + . "github.com/onsi/ginkgo/v2/dsl/core" //nolint:staticcheck ) func StackURLInstrumentation(stackURL *deferred.Deferred[string]) testservice.Instrumentation {