Skip to content
This repository was archived by the owner on Jun 11, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions apps/auth/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ version: '3'

dotenv: [".secrets/oauth.env", ".secrets/env"]

vars:
ImagePrefix: "ghcr.io/kloudlite/platform/apis"

tasks:
run:
cmds:
Expand All @@ -28,10 +31,8 @@ tasks:

docker-build:
vars:
# IMAGE: registry.kloudlite.io/kloudlite/auth:v2
APP: auth
# IMAGE: registry.kloudlite.io/kloudlite/{{.EnvName}}/{{.APP}}-api:{{.Tag}}
IMAGE: ghcr.io/kloudlite/apis/{{.APP}}:{{.Tag}}
IMAGE: "{{.ImagePrefix}}/{{.APP}}:{{.Tag}}"
preconditions:
- sh: '[[ -n "{{.Tag}}" ]]'
msg: 'var Tag must have a value'
Expand All @@ -44,18 +45,11 @@ tasks:

local-build:
preconditions:
- sh: '[ -n "{{.EnvName}}" ]'
msg: 'var EnvName must have a value'
- sh: '[ -n "{{.Tag}}" ]'
msg: 'var Tag must have a value'
vars:
APP: auth
# IMAGE: registry.kloudlite.io/kloudlite/{{.EnvName}}/{{.APP}}-api:{{.Tag}}
IMAGE: ghcr.io/kloudlite/apis/{{.APP}}:{{.Tag}}
env:
CGO_ENABLED: 0
GOOS: linux
GOARCH: amd64
IMAGE: "{{.ImagePrefix}}/{{.APP}}:{{.Tag}}"
silent: true
cmds:
- |+
Expand Down
32 changes: 19 additions & 13 deletions apps/comms/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ version: "3"

dotenv: [".secrets/env"]

vars:
ImagePrefix: ghcr.io/kloudlite/platform/apis


tasks:
run:
env:
Expand All @@ -11,34 +15,36 @@ tasks:
cmds:
- nodemon -e go --signal SIGKILL --exec 'go run -tags dynamic main.go --dev || exit 1'

build:
env:
CGO_ENABLED: 0
# GOOS: linux
# GOARCH: amd64
preconditions:
- sh: '[ -n "{{.Out}}" ]'
msg: var Out must have a value
cmds:
- go build -ldflags="-s -w" -o {{.Out}}
- upx {{.Out}}

docker-build:
vars:
APP: comms
IMAGE: registry.kloudlite.io/kloudlite/{{.EnvName}}/{{.APP}}-api:{{.Tag}}
IMAGE: "{{.ImagePrefix}}/{{.APP}}:{{.Tag}}"
preconditions:
- sh: '[[ -n "{{.Tag}}" ]]'
msg: 'var Tag must have a value'

- sh: '[[ "{{.EnvName}}" == "development" ]] || [[ "{{.EnvName}}" == "staging" ]] || [[ "{{.EnvName}}" == "production" ]]'
msg: 'var EnvName must have one of [development, staging, production] as its value'
cmds:
- docker buildx build -f ./Dockerfile -t {{.IMAGE}} . --build-arg APP={{.APP}} --platform linux/amd64 --build-context project-root=../..
- docker push {{.IMAGE}}

local-build:
vars:
APP: comms
IMAGE: registry.kloudlite.io/kloudlite/{{.EnvName}}/{{.APP}}-api:{{.Tag}}
IMAGE: "{{.ImagePrefix}}/{{.APP}}:{{.Tag}}"
preconditions:
- sh: '[[ -n "{{.Tag}}" ]]'
msg: 'var Tag must have a value'

- sh: '[[ "{{.EnvName}}" == "development" ]] || [[ "{{.EnvName}}" == "staging" ]] || [[ "{{.EnvName}}" == "production" ]]'
msg: 'var EnvName must have one of [development, staging, production] as its value'
env:
CGO_ENABLED: 0
GOOS: linux
GOARCH: amd64
silent: true
cmds:
- |+
Expand All @@ -53,7 +59,7 @@ tasks:
echo "$nDockerfile" | sed "1 i # syntax=docker/dockerfile:1.4" > $tDir/Dockerfile.base

#lineNo=$(cat Dockerfile | grep -i '^FROM' -n | tail -1 | awk -F: '{print $1}')
CGO_ENABLED=0 go build -o $tDir/{{.APP}} .
task build Out="$tDir/{{.APP}}"

cat $tDir/Dockerfile.base | sed "5 i COPY --from=local-builder ./{{.APP}} ./{{.APP}}" > $tDir/Dockerfile
cat $tDir/Dockerfile
Expand Down
13 changes: 7 additions & 6 deletions apps/console/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ version: "3"
dotenv:
- .secrets/env

vars:
ImagePrefix: "ghcr.io/kloudlite/platform/apis"

tasks:
gql:
dir: ./internal/app
Expand All @@ -13,6 +16,8 @@ tasks:
build:
env:
CGO_ENABLED: 0
GOOS: linux
GOARCH: amd64
preconditions:
- sh: '[ -n "{{.Out}}" ]'
msg: var Out must have a value
Expand All @@ -38,7 +43,7 @@ tasks:
docker-build:
vars:
APP: console
IMAGE: registry.kloudlite.io/kloudlite/{{.EnvName}}/{{.APP}}-api:{{.Tag}}
IMAGE: "{{.ImagePrefix}}/{{.APP}}:{{.Tag}}"
preconditions:
- sh: '[[ -n "{{.Tag}}" ]]'
msg: 'var Tag must have a value'
Expand All @@ -58,11 +63,7 @@ tasks:
msg: 'var Tag must have a value'
vars:
APP: console
IMAGE: registry.kloudlite.io/kloudlite/{{.EnvName}}/{{.APP}}-api:{{.Tag}}
env:
CGO_ENABLED: 0
GOOS: linux
GOARCH: amd64
IMAGE: "{{.ImagePrefix}}/{{.APP}}:{{.Tag}}"
silent: true
cmds:
- |+
Expand Down
12 changes: 4 additions & 8 deletions apps/container-registry/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ version: "3"
dotenv:
- .secrets/env

vars:
ImagePrefix: "ghcr.io/kloudlite/platform/apis"

tasks:
gql:
dir: ./internal/app
Expand Down Expand Up @@ -52,17 +55,11 @@ tasks:

local-build:
preconditions:
- sh: '[ -n "{{.EnvName}}" ]'
msg: 'var EnvName must have a value'
- sh: '[ -n "{{.Tag}}" ]'
msg: 'var Tag must have a value'
vars:
APP: container-registry
IMAGE: registry.kloudlite.io/kloudlite/{{.EnvName}}/{{.APP}}-api:{{.Tag}}
env:
CGO_ENABLED: 0
GOOS: linux
GOARCH: amd64
IMAGE: "{{.ImagePrefix}}/{{.APP}}:{{.Tag}}"
silent: true
cmds:
- |+
Expand All @@ -80,7 +77,6 @@ tasks:
cat $tDir/Dockerfile
echo "building application ..."

# CGO_ENABLED=0 go build -o $tDir/{{.APP}} .
task build Out=$tDir/{{.APP}}

docker buildx build -f $tDir/Dockerfile -t {{.IMAGE}} . --build-context local-builder=${tDir}
Expand Down
27 changes: 18 additions & 9 deletions apps/finance/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,26 @@ version: "3"
dotenv:
- .secrets/env

vars:
ImagePrefix: "ghcr.io/kloudlite/platform/apis"

tasks:
gql:
dir: ./internal/app
cmds:
- go run -tags dynamic github.com/99designs/gqlgen generate
- go run github.com/99designs/gqlgen generate

build:
env:
CGO_ENABLED: 0
GOOS: linux
GOARCH: amd64
preconditions:
- sh: '[ -n "{{.Out}}" ]'
msg: var Out must have a value
cmds:
- go build -ldflags="-s -w" -o {{.Out}}
- upx {{.Out}}

run:
dotenv:
Expand All @@ -31,17 +46,11 @@ tasks:

local-build:
preconditions:
- sh: '[ -n "{{.EnvName}}" ]'
msg: 'var EnvName must have a value'
- sh: '[ -n "{{.Tag}}" ]'
msg: 'var Tag must have a value'
vars:
APP: finance
IMAGE: registry.kloudlite.io/kloudlite/{{.EnvName}}/{{.APP}}-api:{{.Tag}}
env:
CGO_ENABLED: 0
GOOS: linux
GOARCH: amd64
IMAGE: "{{.ImagePrefix}}/{{.APP}}:{{.Tag}}"
silent: true
cmds:
- |+
Expand All @@ -60,7 +69,7 @@ tasks:
cat $tDir/Dockerfile.base | sed "5 i COPY --from=local-builder ./{{.APP}} ./finance" > $tDir/Dockerfile
cat $tDir/Dockerfile

CGO_ENABLED=0 go build -o $tDir/{{.APP}} .
task build Out="$tDir/{{.APP}}"

docker buildx build -f $tDir/Dockerfile -t {{.IMAGE}} . --build-context local-builder=${tDir}
docker push {{.IMAGE}}
Expand Down
7 changes: 1 addition & 6 deletions apps/finance/internal/domain/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,9 @@ type domainI struct {
commsClient comms.CommsClient
billablesRepo repos.DbRepo[*AccountBilling]
accountInviteTokenRepo cache.Repo[*AccountInviteToken]
inventoryPath string
stripeCli *stripe.Client
k8sYamlClient *kubectl.YAMLClient
env *Env
// env *Env
}

func (d *domainI) ListAccounts(ctx FinanceContext) ([]*Account, error) {
Expand Down Expand Up @@ -550,7 +549,6 @@ func fxDomain(
consoleClient console.ConsoleClient,
containerRegistryClient container_registry.ContainerRegistryClient,
authClient auth.AuthClient,
env *Env,
commsClient comms.CommsClient,
accountInviteTokenRepo cache.Repo[*AccountInviteToken],
// stripeCli *stripe.Client,
Expand All @@ -565,9 +563,6 @@ func fxDomain(
accountRepo: accountRepo,
commsClient: commsClient,
accountInviteTokenRepo: accountInviteTokenRepo,
inventoryPath: env.InventoryPath,
env: env,
// stripeCli: stripeCli,
k8sYamlClient: k8sYamlClient,
}
}
20 changes: 9 additions & 11 deletions apps/finance/internal/domain/main.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
package domain

import (
"go.uber.org/fx"
"kloudlite.io/pkg/config"
"go.uber.org/fx"
)

type Env struct {
InventoryPath string `env:"INVENTORY_PATH"`
CurrClusterConfigNS string `env:"CURR_CLUSTER_CONFIG_NAMESPACE" required:"true"`
CurrClusterConfigName string `env:"CURR_CLUSTER_CONFIG_NAME" required:"true"`
CurrClusterConfigClusterIdKey string `env:"CURR_CLUSTER_CONFIG_CLUSTER_ID_KEY" required:"true"`
}

// type Env struct {
// InventoryPath string `env:"INVENTORY_PATH"`
// CurrClusterConfigNS string `env:"CURR_CLUSTER_CONFIG_NAMESPACE" required:"true"`
// CurrClusterConfigName string `env:"CURR_CLUSTER_CONFIG_NAME" required:"true"`
// CurrClusterConfigClusterIdKey string `env:"CURR_CLUSTER_CONFIG_CLUSTER_ID_KEY" required:"true"`
// }
var Module = fx.Module("domain",
fx.Provide(fxDomain),
config.EnvFx[Env](),
fx.Provide(fxDomain),
// config.EnvFx[Env](),
)
7 changes: 4 additions & 3 deletions apps/gateway/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@ version: 3
dotenv:
- "./.secrets/env"

vars:
ImagePrefix: ghcr.io/kloudlite/platform/apis

tasks:
dev:
interactive: true
cmds:
- npm start
docker-build:
vars:
Image: registry.kloudlite.io/kloudlite/{{.EnvName}}/gateway-api:{{.Tag}}
Image: "{{.ImagePrefix}}/gateway:{{.Tag}}"
preconditions:
- sh: test -n '{{.EnvName}}'
msg: 'var EnvName must be defined'
- sh: test -n '{{.Tag}}'
msg: 'var Tag must be defined'
cmds:
Expand Down
17 changes: 2 additions & 15 deletions apps/gateway/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,8 @@ const useEnv = (key) => {
return v
};

// const cfgMap = yaml.load(await fs.readFile(useEnv("SUPERGRAPH_CONFIG"), 'utf8'));
const cfgMap = {
serviceList: [
{ name: 'auth-api', url: 'http://auth-api.kl-core.svc.cluster.local/query' },
{ name: 'infra-api', url: 'http://infra-api.kl-core.svc.cluster.local/query' },
{ name: 'console-api', url: 'http://console-api.kl-core.svc.cluster.local/query' },
{ name: 'finance-api', url: 'http://finance-api.kl-core.svc.cluster.local/query' },
{ name: 'message-office-api', url: 'http://message-office-api.kl-core.svc.cluster.local/query' },
]
}
const cfgMap = yaml.load(await fs.readFile(useEnv("SUPERGRAPH_CONFIG"), 'utf8'));

// const supergraphSdl = (
// await fs.readFile(useEnv('SUPERGRAPH_CONFIG'), 'utf8')
// ).toString();
//
class CustomDataSource extends RemoteGraphQLDataSource {
// eslint-disable-next-line class-methods-use-this
willSendRequest({ request, context }) {
Expand Down Expand Up @@ -77,7 +64,7 @@ const server = new ApolloServer({
const app = express()
await server.start()

app.get("/health", (req, res) => {
app.get("/healthz", (req, res) => {
return res.sendStatus(200);
})

Expand Down
Loading