Skip to content

Commit

Permalink
RPP-5: Metalogix specific compose file (#24)
Browse files Browse the repository at this point in the history
* RPP-5: Metalogix specific compose file

* RPP-5: Metalogix specific compose file
  • Loading branch information
waeljammal committed Jul 4, 2024
1 parent 0d3027e commit de00167
Show file tree
Hide file tree
Showing 6 changed files with 251 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
go install gotest.tools/gotestsum@latest
task test:ci:unit
- name: "Submit Coverage"
run: bash <(curl -Ls https://coverage.codacy.com/get.sh) report --force-coverage-parser go -r bin/unit.cover.out
run: bash <(curl -Ls https://coverage.codacy.com/get.sh) report --api-token ${{ secrets.CODACY_API_TOKEN }} --force-coverage-parser go -r bin/unit.cover.out
env:
CODACY_API_TOKEN: ${{ secrets.CODACY_API_TOKEN }}
CODACY_ORGANIZATION_PROVIDER: gh
Expand Down
51 changes: 51 additions & 0 deletions cmd/app/config/metalogix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: vth-gateway
id: vth-gateway-1

logger:
level: info
mode: dev # or prd

dapr:
http_port: 6012
grpc_port: 6011

database:
dsn: mongodb%3A%2F%2Fmongodb_dev%3A27017%2F%3FreplicaSet%3Drs0%26tls%3Dfalse%26connect%3Ddirect%26retryWrites%3Dtrue%26w%3Dmajority
name: vth-gateway

gateway:
web_dir: /src/cmd/web/dist
backoffice_org: org_hiUmCjtFR7ZgEckN
http:
address: 0.0.0.0
port: 6010
cors:
allow_credentials: true
allow_origins:
- '*'
allow_headers:
- '*'
allow_methods:
- POST
- GET
- PUT
- DELETE
- PATCH
- HEAD
metrics:
address: 0.0.0.0
port: 6015
services: []

auth:
domain: ${AUTH_DOMAIN}
jwt:
auth_domain: https://auth.dev.cloud.azarc.dev
aud: https://verathread.com/api/verify
iss: https://dev-iq3b9wdl.us.auth0.com/
claims: https://verathread.com/claims

# Enabled dapr in embedded mode, to only be used for local development
# in K8S dapr is automatically injected into the pod as a container and this is not required
development:
enabled: false
151 changes: 151 additions & 0 deletions docker-compose-metalogix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
name: gw-dev

services:
##################################################################################
# GLOBAL COMMON SERVICES
##################################################################################

shell-fe:
build:
context: .
dockerfile: "deployment/docker/web/Dockerfile.dev"
networks:
- frontend-network
ports:
- "3000:3000"
environment:
DAPR_PLACEMENT_METADATA_ENABLED: true
NODE_ENV: development
develop:
watch:
- action: sync
path: cmd/web
target: /src

example-fe:
build:
context: .
dockerfile: "example/docker/web/Dockerfile.dev"
networks:
- frontend-network
ports:
- "3001:3001"
environment:
DAPR_PLACEMENT_METADATA_ENABLED: true
NODE_ENV: development
develop:
watch:
- action: sync
path: example/web
target: /src

gateway-dapr:
image: "daprio/daprd:edge"
command: [
"./daprd",
"--app-id", "vth-gateway",
"--app-port", "6010",
"--placement-host-address", "placement:50006", # Dapr's placement service can be reach via the docker DNS entry
"--resources-path", "./dapr",
"--dapr-grpc-port", "6011",
"--dapr-http-port", "6012",
"--config", "dapr/config/config.yaml"
]
volumes:
- "./dapr/:/dapr" # Mount our components folder for the runtime to use. The mounted location must match the --resources-path argument.
depends_on:
- gateway
- placement
network_mode: "service:gateway" # Attach the gateway-dapr service to the gateway network namespace

gateway:
image: ghcr.io/azarc-io/verathread-gateway/gateway-be:v1.51.0
networks:
- frontend-network
environment:
CONFIG_DIR: /config
BASE_CONTEXT: metalogix
DAPRD_BIN_PATH: /src/.data/bin
AUTH_DOMAIN: ${AUTH_DOMAIN}
DAPR_GRPC_PORT: 6011
volumes:
- ./cmd/app/config:/config
ports:
- "6010:6010"
depends_on:
- mongodb_dev

example-dapr:
image: "daprio/daprd:edge"
command: [
"./daprd",
"--app-id", "vth-gateway-example",
"--app-port", "6110",
"--placement-host-address", "placement:50006", # Dapr's placement service can be reach via the docker DNS entry
"--resources-path", "./dapr",
"--dapr-grpc-port", "6111",
"--dapr-http-port", "6112",
"--config", "dapr/config/config.yaml"
]
volumes:
- "./dapr/:/dapr" # Mount our components folder for the runtime to use. The mounted location must match the --resources-path argument.
depends_on:
- example
- placement
network_mode: "service:example" # Attach the gateway-dapr service to the gateway network namespace

example:
image: ghcr.io/azarc-io/verathread-gateway/gateway-be-example:v1.51.0
networks:
- frontend-network
environment:
CONFIG_DIR: /config
BASE_CONTEXT: metalogix
DAPR_GRPC_PORT: 6111
volumes:
- ./example/app/config:/config
ports:
- "6110:6110"
depends_on:
- gateway

mongodb_dev:
image: mongo:latest
container_name: mongodb_dev
environment:
MONGO_APP_DATABASE: vth-gateway
MONGO_REPLICA_HOST: host.docker.internal
MONGO_REPLICA_PORT: 27018
entrypoint: >
/bin/bash -c '
echo "rs.initiate()" > /docker-entrypoint-initdb.d/1-init-replicaset.js &&
echo "db = db.getSiblingDB(process.env[$0]);" > /docker-entrypoint-initdb.d/2-init-db-collection.js &&
echo "db.createCollection($1, { capped: false });" >> /docker-entrypoint-initdb.d/2-init-db-collection.js &&
echo "db.init.insert([{ message: $2 }]);" >> /docker-entrypoint-initdb.d/2-init-db-collection.js &&
/usr/local/bin/docker-entrypoint.sh mongod --replSet rs0 --bind_ip_all --noauth' "'MONGO_APP_DATABASE'" "'init'" "'db initialized successfully'"
networks:
- frontend-network
ports:
- "27018:27017"
volumes:
- ./.data/mongodb:/data/db
- ./.data/mongodb/opt:/opt/keyfile/

placement:
image: "daprio/dapr"
command: [ "./placement", "-port", "50006" ]
networks:
- frontend-network
ports:
- "8080:8080"
- "50006:50006"
environment:
DAPR_PLACEMENT_METADATA_ENABLED: true

networks:
frontend-network:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.16.238.0/24
24 changes: 24 additions & 0 deletions example/app/config/metalogix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: vth-gateway-example
id: vth-gateway-example-1
webDir: web/dist

logger:
level: info
mode: dev # or prd

dapr:
http_port: 6112
grpc_port: 6111

http:
address: 0.0.0.0
port: 6110

registration:
webBaseUrl: http://example:6110
baseWsUrl: ws://example:6110

# Enabled dapr in embedded mode, to only be used for local development
# in K8S dapr is automatically injected into the pod as a container and this is not required
development:
enabled: false
4 changes: 4 additions & 0 deletions example/docker/app/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM alpine:3.20
LABEL authors="waeljammal"
COPY bin/vth-gateway-example /
ENTRYPOINT ["/vth-gateway-example"]
20 changes: 20 additions & 0 deletions taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,26 @@ tasks:
env:
NODE_ENV: development

example:build:
desc: "builds the example backend"
method: none
dir: example
cmds:
- GOOS={{.GOOS}} GOARCH={{.GOARCH}} go build -gcflags="all=-N -l" -o bin/vth-gateway-example app/main.go && chmod 775 bin/vth-gateway-example
vars:
GOOS: '{{default "linux" .GOOS}}'
GOARCH: '{{default "amd64" .GOARCH}}'

example:publish:
desc: "publishes the example backend"
method: none
dir: example
cmds:
- docker build -f docker/app/Dockerfile -t ghcr.io/azarc-io/verathread-gateway/gateway-be-example:${EX_VERSION} .
- docker push ghcr.io/azarc-io/verathread-gateway/gateway-be-example:${EX_VERSION}
env:
EX_VERSION: v1.51.0


##############################################################################
# BUILD
Expand Down

0 comments on commit de00167

Please sign in to comment.