Skip to content

Commit

Permalink
feat: add orchestration to docker compose (#489)
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-nicolas authored Aug 18, 2023
1 parent 9b0d3fb commit 04788d1
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 9 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion components/orchestration/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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) {
Expand All @@ -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(
Expand Down
4 changes: 4 additions & 0 deletions config/auth/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ clients:
secrets:
- wallets
name: wallets
- id: orchestration
secrets:
- orchestration
name: orchestration
- id: control
secrets:
- mysupersecret
Expand Down
17 changes: 16 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ volumes:
opensearch_data:
services:
jaeger:
platform: linux/x86_64
image: jaegertracing/all-in-one:latest
ports:
- "16686:16686"
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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
Expand Down
7 changes: 7 additions & 0 deletions process-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

1 comment on commit 04788d1

@vercel
Copy link

@vercel vercel bot commented on 04788d1 Aug 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.