diff --git a/Dockerfile b/Dockerfile index 5b26e030a9..b75a4aad82 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,8 @@ # 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.8.0 as payments +FROM ghcr.io/formancehq/payments:v0.9.7 as payments +FROM ghcr.io/formancehq/orchestration:v0.1.5 as orchestration 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 @@ -22,6 +23,7 @@ FROM node:18 WORKDIR /tmp COPY --from=builder /usr/bin/process-compose /usr/bin/process-compose COPY --from=gateway /usr/bin/caddy /usr/bin/gateway +COPY --from=orchestration /usr/bin/orchestration /usr/bin/orchestration 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 diff --git a/components/orchestration/Dockerfile b/components/orchestration/Dockerfile index 803f2f120d..56c0c5c8ff 100644 --- a/components/orchestration/Dockerfile +++ b/components/orchestration/Dockerfile @@ -4,7 +4,7 @@ ARG VERSION WORKDIR /src COPY . . WORKDIR /src/components/orchestration -RUN go mod download +RUN --mount=type=cache,mode=0755,target=/go/pkg/mod go mod download RUN GOOS=linux go build -o orchestration \ -ldflags="-X $(cat go.mod |head -1|cut -d \ -f2)/cmd.Version=${VERSION} \ -X $(cat go.mod |head -1|cut -d \ -f2)/cmd.BuildDate=$(date +%s) \ diff --git a/components/orchestration/internal/workflow/activities/activity_ledger_create_transaction.go b/components/orchestration/internal/workflow/activities/activity_ledger_create_transaction.go index 79f339709f..383e85d15e 100644 --- a/components/orchestration/internal/workflow/activities/activity_ledger_create_transaction.go +++ b/components/orchestration/internal/workflow/activities/activity_ledger_create_transaction.go @@ -45,7 +45,7 @@ func createTransactionV1(ctx context.Context, client *formance.Formance, baseURL return nil, fmt.Errorf("error generating URL: %w", err) } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, "PostTransaction", "json") + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, "Data", "json") if err != nil { return nil, fmt.Errorf("error serializing request body: %w", err) } @@ -109,8 +109,8 @@ func createTransactionV1(ctx context.Context, client *formance.Formance, baseURL } type CreateTransactionRequest struct { - Ledger string `json:"ledger"` - Data shared.PostTransaction `json:"data"` + Ledger string `pathParam:"style=simple,explode=false,name=ledger"` + Data shared.PostTransaction `request:"mediaType=application/json"` } func (a Activities) CreateTransaction(ctx context.Context, request CreateTransactionRequest) (*shared.CreateTransactionResponse, error) { @@ -134,9 +134,21 @@ func (a Activities) CreateTransaction(ctx context.Context, request CreateTransac return nil, err } - return &shared.CreateTransactionResponse{ - Data: v.CreateTransactionResponse.Data[0], - }, nil + switch v.StatusCode { + case http.StatusOK: + return &shared.CreateTransactionResponse{ + Data: v.CreateTransactionResponse.Data[0], + }, nil + default: + if v.ErrorResponse != nil { + return nil, temporal.NewApplicationError( + v.ErrorResponse.ErrorMessage, + string(v.ErrorResponse.ErrorCode), + v.ErrorResponse.Details) + } + + return nil, fmt.Errorf("unexpected status code: %d", v.StatusCode) + } } else { response, err := a.client.Ledger. CreateTransaction( diff --git a/config/auth/config.yaml b/config/auth/config.yaml index ac09e9ea13..7c895e9f86 100644 --- a/config/auth/config.yaml +++ b/config/auth/config.yaml @@ -7,6 +7,10 @@ clients: secrets: - wallets name: wallets + - id: orchestration + secrets: + - orchestration + name: orchestration - id: control secrets: - mysupersecret diff --git a/docker-compose.yml b/docker-compose.yml index f8a05f221a..fdb2d6fea2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,6 +5,7 @@ volumes: opensearch_data: services: jaeger: + platform: linux/x86_64 image: jaegertracing/all-in-one:latest ports: - "16686:16686" @@ -39,7 +40,19 @@ services: - "8222:8222" command: --js + temporalite: + container_name: temporalite + build: + dockerfile: tests/integration/temporalite.Dockerfile + context: . + ports: + - 7233:7233 + - 8233:8233 + stdin_open: true + tty: true + postgres: + platform: linux/x86_64 image: "postgres:13-alpine" restart: always healthcheck: @@ -52,13 +65,14 @@ services: environment: POSTGRES_USER: "formance" POSTGRES_PASSWORD: "formance" - POSTGRES_MULTIPLE_DATABASES: "auth,ledger,webhooks,payments" + POSTGRES_MULTIPLE_DATABASES: "auth,ledger,webhooks,payments,orchestration" PGDATA: "/data/postgres" volumes: - postgres_data:/data/postgres - ./config/postgres:/docker-entrypoint-initdb.d opensearch: + platform: linux/x86_64 image: "opensearchproject/opensearch:2.2.1" restart: always environment: @@ -74,6 +88,7 @@ services: - opensearch_data:/usr/share/opensearch/data opensearch-dashboards: + platform: linux/x86_64 image: "opensearchproject/opensearch-dashboards:2.2.1" environment: OPENSEARCH_HOSTS: '["http://opensearch:9200"]' # must be a string with no spaces when specified as an environment variable diff --git a/process-compose.yaml b/process-compose.yaml index ee14cc75f0..b6bf87f7f1 100644 --- a/process-compose.yaml +++ b/process-compose.yaml @@ -82,6 +82,13 @@ processes: environment: - "OTEL_SERVICE_NAME=webhooks" + orchestration: + command: orchestration serve --listen 0.0.0.0:8086 --postgres-dsn postgresql://formance:formance@postgres/orchestration?sslmode=disable --temporal-address temporalite:7233 --stack-url http://localhost --stack-client-id orchestration --stack-client-secret orchestration --worker + availability: + restart: always + environment: + - "OTEL_SERVICE_NAME=orchestration" + benthos: command: benthos -r "/benthos/resources/*.yaml" -t "/benthos/templates/*.yaml" -c /benthos/config.yml --log.level trace streams "/benthos/streams/*.yaml" availability: