Skip to content

Commit

Permalink
feat: Add all-in-one
Browse files Browse the repository at this point in the history
  • Loading branch information
flemzord committed Jul 7, 2023
1 parent 87d7997 commit 9a0b489
Show file tree
Hide file tree
Showing 7 changed files with 166 additions and 199 deletions.
37 changes: 32 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,34 @@
FROM node:latest
# syntax=docker/dockerfile:1
FROM ghcr.io/formancehq/gateway:v0.1.7 as gateway
FROM ghcr.io/formancehq/ledger:v1.10.3 as ledger
FROM ghcr.io/formancehq/payments:v0.7.1 as payments
FROM ghcr.io/formancehq/auth:v0.4.3 as auth
FROM ghcr.io/formancehq/search:v0.7.0 as search
FROM ghcr.io/formancehq/wallets:v0.4.3 as wallets
FROM ghcr.io/formancehq/webhooks:v0.6.6 as webhooks
FROM ghcr.io/formancehq/control:v1.7.0 as control
FROM ghcr.io/formancehq/auth-dex:latest as dex
FROM jeffail/benthos:4.12.1 as benthos

FROM node:18
WORKDIR /tmp
RUN apt update && apt install -y wget &&\
export ARCH=$(dpkg --print-architecture) && \
wget https://github.com/F1bonacc1/process-compose/releases/download/v0.51.4/process-compose_Linux_$ARCH.tar.gz && \
tar -xvf process-compose_Linux_$ARCH.tar.gz -C /tmp &&\
cp -R process-compose /usr/bin/process-compose
COPY --from=gateway /usr/bin/caddy /usr/bin/gateway
COPY --from=dex /usr/local/bin/dex /usr/bin/dex
COPY --from=auth /usr/bin/auth /usr/bin/auth
COPY --from=ledger /usr/local/bin/numary /usr/bin/ledger
COPY --from=payments /usr/bin/payments /usr/bin/payments
COPY --from=search /usr/bin/search /usr/bin/search
COPY --from=wallets /usr/bin/wallets /usr/bin/wallets
COPY --from=webhooks /usr/bin/webhooks /usr/bin/webhooks
COPY --from=benthos /benthos /usr/bin/benthos
COPY --from=control /app /app
COPY ./config /etc/formance
COPY ./components/search/benthos /benthos
WORKDIR /app
RUN npm install -g @moonrepo/cli
COPY ./.moon/docker/workspace .
RUN moon docker setup
RUN moon run auth:lint
COPY process-compose.yaml /running/process-compose.yaml
CMD ["process-compose", "up", "--config", "/running/process-compose.yaml", "--tui=false", "-p", "9090"]
28 changes: 14 additions & 14 deletions config/gateway/Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,24 +62,24 @@ localhost:80 {
}

import handle_route_without_auth "/api/auth/dex" "127.0.0.1:5556"
import handle_path_route_without_auth "/api/auth" "127.0.0.1:8080"
import handle_path_route_with_auth "/api/ledger" "ledger:3068"
import handle_path_route_with_auth "/api/wallets" "wallets:8080"
import handle_path_route_with_auth "/api/payments" "payments:8080"
import handle_path_route_with_auth "/api/search" "search:8080"
import handle_path_route_with_auth "/api/webhooks" "webhooks:8080"
import handle_path_route_without_auth "/api/auth" "127.0.0.1:8083"
import handle_path_route_with_auth "/api/ledger" "127.0.0.1:3068"
import handle_path_route_with_auth "/api/wallets" "127.0.0.1:8081"
import handle_path_route_with_auth "/api/payments" "127.0.0.1:8082"
import handle_path_route_with_auth "/api/search" "127.0.0.1:8080"
import handle_path_route_with_auth "/api/webhooks" "127.0.0.1:8084"

handle /versions {
versions {
region "us-east-1"
env "staging"
region "local"
env "local"
endpoints {
auth http://127.0.0.1:8080/_info http://127.0.0.1:8080/_healthcheck
ledger http://ledger:3068/_info http://ledger:3068/_healthcheck
wallets http://wallets:8080/_info http://wallets:8080/_healthcheck
payments http://payments:8080/_info http://payments:8080/_healthcheck
search http://search:8080/_info http://search:8080/_healthcheck
webhooks http://webhooks:8080/_info http://webhooks:8080/_healthcheck
auth http://127.0.0.1:8083/_info http://127.0.0.1:8083/_healthcheck
ledger http://127.0.0.1:3068/_info http://127.0.0.1:3068/_healthcheck
wallets http://127.0.0.1:8081/_info http://127.0.0.1:8081/_healthcheck
payments http://127.0.0.1:8082/_info http://127.0.0.1:8082/_healthcheck
search http://127.0.0.1:8080/_info http://127.0.0.1:8080/_healthcheck
webhooks http://127.0.0.1:8084/_info http://127.0.0.1:8084/_healthcheck
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions config/redpanda/config.yaml

This file was deleted.

1 change: 1 addition & 0 deletions devbox.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"github:goreleaser/nur#goreleaser-pro",
"path:nix/speakeasy#speakeasy",
"path:nix/moon#moon",
"[email protected]",
"[email protected]"
],
"shell": {},
Expand Down
5 changes: 5 additions & 0 deletions devbox.lock
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
"resolved": "github:NixOS/nixpkgs/8670e496ffd093b60e74e7fa53526aa5920d09eb#nodejs",
"version": "18.16.0"
},
"[email protected]": {
"last_modified": "2023-05-01T16:53:22Z",
"resolved": "github:NixOS/nixpkgs/8670e496ffd093b60e74e7fa53526aa5920d09eb#process-compose",
"version": "0.43.1"
},
"[email protected]": {
"last_modified": "2023-05-01T16:53:22Z",
"resolved": "github:NixOS/nixpkgs/8670e496ffd093b60e74e7fa53526aa5920d09eb#yarn",
Expand Down
193 changes: 15 additions & 178 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,72 +13,30 @@ services:
COLLECTOR_OTLP_ENABLED: "true"
LOG_LEVEL: "debug"

gateway:
image: "ghcr.io/formancehq/gateway:v0.1.7"
network_mode: service:auth-dex
environment:
OTEL_SERVICE_NAME: "gateway"
OTEL_EXPORTER_OTLP_ENDPOINT: "http://jaeger:4317"
OTEL_EXPORTER_OTLP_INSECURE: "true"
OTEL_EXPORTER_OTLP_PROTOCOL: "grpc"
GRPC_GO_LOG_VERBOSITY_LEVEL: "99"
GRPC_GO_LOG_SEVERITY_LEVEL: "info"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
- "./config/gateway/Caddyfile:/etc/caddy/Caddyfile:ro"

auth-dex:
image: "ghcr.io/formancehq/auth-dex:latest"
restart: always
volumes:
- ./config/dex/dex-config.yaml:/etc/dex/config.docker.yaml
all-in-one:
build:
context: .
dockerfile: Dockerfile
depends_on:
postgres:
condition: service_healthy
ports:
- "80:80"
- "443:443"
- "8091:8081"
- "8080:8080"

auth:
image: "ghcr.io/formancehq/auth:v0.4.3"
restart: always
network_mode: service:auth-dex
command: serve
depends_on:
postgres:
opensearch:
condition: service_healthy
environment:
DEBUG: "true"
CONFIG: "./config.yaml"
POSTGRES_URI: "host=postgres user=formance password=formance dbname=auth port=5432 sslmode=disable"
CAOS_OIDC_DEV: "1"
DELEGATED_CLIENT_ID: "gateway"
DELEGATED_CLIENT_SECRET: "ZXhhbXBsZS1hcHAtc2VjcmV0"
DELEGATED_ISSUER: "http://localhost/api/auth/dex"
BASE_URL: "http://localhost/api/auth"
volumes:
- ./config/auth/config.yaml:/config.yaml

control:
image: "ghcr.io/formancehq/control:v1.7.0"
restart: always
network_mode: service:gateway
environment:
API_URL: "http://localhost/api"
REDIRECT_URI: "http://localhost"
CLIENT_ID: "control"
CLIENT_SECRET: "mysupersecret"
ENCRYPTION_KEY: "mysuperencryptionkey"
ENCRYPTION_IV: "6f0c77c78a624022"
- ./process-compose.yaml:/running/process-compose.yaml
- ./config:/etc/formance
- ./components/search/benthos:/benthos
- ./components/auth/pkg/web:/app/web
ports:
- "80:80"
- "9090:9090"

nats:
image: nats:2.8.4-alpine
ports:
- 4222:4222
- 6222:6222
- 8222:8222
- "4222:4222"
- "6222:6222"
- "8222:8222"
command: --js

postgres:
Expand All @@ -100,56 +58,6 @@ services:
- postgres_data:/data/postgres
- ./config/postgres:/docker-entrypoint-initdb.d

ledger:
image: "ghcr.io/formancehq/ledger:v1.10.0"
restart: always
depends_on:
postgres:
condition: service_healthy
environment:
NUMARY_STORAGE_DRIVER: "postgres"
NUMARY_STORAGE_POSTGRES_CONN_STRING: "postgresql://formance:formance@postgres/ledger?sslmode=disable"
NUMARY_SERVER_HTTP_BIND_ADDRESS: "0.0.0.0:3068"
NUMARY_PUBLISHER_NATS_ENABLED: "true"
NUMARY_PUBLISHER_NATS_URL: "nats:4222"
NUMARY_PUBLISHER_TOPIC_MAPPING: "*:ledger"
NUMARY_OTEL_METRICS: "true"
NUMARY_OTEL_METRICS_RUNTIME: "true"

wallets:
image: "ghcr.io/formancehq/wallets:v0.4.2"
restart: always
depends_on:
postgres:
condition: service_healthy
environment:
STACK_CLIENT_ID: "wallets"
STACK_CLIENT_SECRET: "wallets"
STACK_URL: "http://localhost"

payments:
image: "ghcr.io/formancehq/payments:latest"
restart: always
depends_on:
postgres:
condition: service_healthy
environment:
POSTGRES_URI: "postgresql://formance:formance@postgres/payments?sslmode=disable"
CONFIG_ENCRYPTION_KEY: "mysuperencryptionkey"
PUBLISHER_NATS_ENABLED: true
PUBLISHER_NATS_CLIENT_ID: payments
PUBLISHER_NATS_URL: nats:4222
PUBLISHER_TOPIC_MAPPING: "*:payments"

payments-migrate:
image: "ghcr.io/formancehq/payments:latest"
command: migrate up
depends_on:
postgres:
condition: service_healthy
environment:
POSTGRES_URI: "postgresql://formance:formance@postgres/payments?sslmode=disable"

opensearch:
image: "opensearchproject/opensearch:2.2.1"
restart: always
Expand All @@ -175,74 +83,3 @@ services:
condition: service_healthy
ports:
- "5601:5601"

search-ingester:
image: "jeffail/benthos:4.12.1"
restart: always
command: "-r /config/resources/*.yaml -t /config/templates/*.yaml -c /config/config.yml --log.level trace streams /config/streams/*.yaml"
depends_on:
opensearch:
condition: service_healthy
search:
condition: service_healthy
volumes:
- ./components/search/benthos:/config
environment:
TOPIC_PREFIX: ""
NATS_URL : nats:4222
BROKER: nats
OPENSEARCH_URL: "http://opensearch:9200"
OPENSEARCH_INDEX: "formance"
OPENSEARCH_TLS_ENABLED: "true"
OPENSEARCH_TLS_SKIP_CERT_VERIFY: "true"
OPENSEARCH_BASIC_AUTH_ENABLED: "false"

search:
image: "ghcr.io/formancehq/search:latest"
restart: always
healthcheck:
test: curl -s -f -k http://127.0.0.1:8080/_healthcheck >/dev/null || exit 1
interval: 30s
timeout: 10s
retries: 5
depends_on:
opensearch:
condition: service_healthy
environment:
OPEN_SEARCH_SCHEME: "http"
OPEN_SEARCH_SERVICE: "opensearch:9200"
ES_INDICES: "formance"

webhooks:
image: "ghcr.io/formancehq/webhooks:v0.6.6"
restart: always
healthcheck:
test: curl -s -f -k http://127.0.0.1:8080/_healthcheck >/dev/null || exit 1
interval: 30s
timeout: 10s
retries: 5
depends_on:
postgres:
condition: service_healthy
environment:
STORAGE_POSTGRES_CONN_STRING: "postgresql://formance:formance@postgres/webhooks?sslmode=disable"

webhooks-worker:
image: "ghcr.io/formancehq/webhooks:v0.6.6"
command: worker
restart: always
healthcheck:
test: curl -s -f -k http://127.0.0.1:8081/_healthcheck >/dev/null || exit 1
interval: 30s
timeout: 10s
retries: 5
depends_on:
postgres:
condition: service_healthy
environment:
STORAGE_POSTGRES_CONN_STRING: "postgresql://formance:formance@postgres/webhooks?sslmode=disable"
KAFKA_TOPICS: "ledger payments"
LOG_LEVEL: "debug"
PUBLISHER_NATS_CLIENT_ID: webhooks
PUBLISHER_NATS_ENABLED: true
PUBLISHER_NATS_URL: nats:4222
Loading

0 comments on commit 9a0b489

Please sign in to comment.