Skip to content

Commit

Permalink
RPP-4: Fix environment issues (#21)
Browse files Browse the repository at this point in the history
* RPP-4: Update docs

* RPP-4: Fix env

* RPP-4: Fix env

* RPP-4: Fix env

* RPP-4: Fix env

* RPP-4: Update docs
  • Loading branch information
waeljammal committed Jul 3, 2024
1 parent 4edcccb commit 4b6a25f
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 22 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ jobs:
run: task test:fe
- name: "Build"
run: task build:fe
env:
ENV_MODE: qa1
- name: "Build Docker"
run: task docker:build:multi
env:
Expand Down
2 changes: 2 additions & 0 deletions cmd/web/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PUBLIC_API_BASE_URL="http://localhost:6010/graphql"
PUBLIC_API_BASE_WS_URL="http://localhost:6010/graphql"
2 changes: 2 additions & 0 deletions cmd/web/.env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PUBLIC_API_BASE_URL="http://localhost:6010/graphql"
PUBLIC_API_BASE_WS_URL="ws://localhost:6010/graphql"
2 changes: 2 additions & 0 deletions cmd/web/.env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PUBLIC_API_BASE_URL=http://localhost:6010/graphql
PUBLIC_API_BASE_WS_URL="ws://localhost:6010/graphql"
2 changes: 2 additions & 0 deletions cmd/web/.env.qa1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PUBLIC_API_BASE_URL=https://qa-gateway-1.dev.cloud.azarc.dev/graphql
PUBLIC_API_BASE_WS_URL=wss://qa-gateway-1.dev.cloud.azarc.dev/graphql
2 changes: 2 additions & 0 deletions cmd/web/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ dist/
.vscode/*
!.vscode/extensions.json
.idea

!.env
7 changes: 5 additions & 2 deletions cmd/web/src/bootstrap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ import {BrowserRouter} from "react-router-dom";
import { WebSocketLink } from "@apollo/client/link/ws";
import {getMainDefinition} from "@apollo/client/utilities";

console.log('env', process.env.NODE_ENV)
console.log('uri', import.meta.env.PUBLIC_API_BASE_URL)

const httpLink = createHttpLink({
// You should use an absolute URL here
uri: 'http://localhost:6010/graphql',
uri: import.meta.env.PUBLIC_API_BASE_URL,
})

const wsLink = new WebSocketLink({
uri: "ws://localhost:6010/graphql",
uri: import.meta.env.PUBLIC_API_BASE_WS_URL,
options: {
reconnect: true
}
Expand Down
4 changes: 3 additions & 1 deletion docker-compose-dev.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
services:
name: gw-dev

services:
##################################################################################
# GLOBAL COMMON SERVICES
##################################################################################
Expand Down
48 changes: 31 additions & 17 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,43 @@
# GLOBAL COMMON SERVICES
##################################################################################

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:
- gw-network
ports:
- "27018:27017"
volumes:
- ./.data/mongodb:/data/db
- ./.data/mongodb/opt:/opt/keyfile/

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

nats:
image: nats:2.10.14-alpine3.19
container_name: nats
command: -c /etc/nats/nats.conf
ports:
- "4222:4222" # client port
- "6222:6222" # cluster port
- "8222:8222" # monitoring port
volumes:
- ./script/compose/nats.conf:/etc/nats/nats.conf
- ./.data/nats:/data

zipkin:
container_name: zipkin
image: openzipkin/zipkin-slim
ports:
- "9411:9411"
networks:
gw-network:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.16.238.0/24
1 change: 1 addition & 0 deletions docs/docs/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ It enables the following capabilities for other Azarc mono repo based projects:
* [x] Federated Subscriptions
- [x] Statically configured routes
- [x] Dynamic routes
- [ ] Healthiness & Push changes to UI
- [ ] Nats based registration
- [x] GraphQL based registration
- [x] Dapr Cluster based registration
5 changes: 5 additions & 0 deletions docs/docs/compose.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
You can begin working on this project using docker compose without the need to have `golang` and `node` installed on your
machine.

!!! info

Please note that the first time you start the environment it could take a few minutes for the entire stack
to become stable and healthy.

### Requirements

- [Docker](https://www.docker.com/get-started/)
Expand Down
7 changes: 5 additions & 2 deletions taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ tasks:
desc: "starts the front end in dev mode with hmr support"
dir: cmd/web
cmds:
- yarn build:watch
- yarn dev
env:
NODE_ENV: development

Expand Down Expand Up @@ -109,7 +109,10 @@ tasks:
desc: "builds the frontend for production"
dir: cmd/web
cmds:
- yarn build
- echo "building for environment ${ENV_MODE}"
- yarn build --env-mode ${ENV_MODE}
env:
ENV_MODE: production

##############################################################################
# DOCKER
Expand Down

0 comments on commit 4b6a25f

Please sign in to comment.