Compare commits

...

1 Commits

16 changed files with 153 additions and 38 deletions

View File

@ -15,11 +15,44 @@ clobber:
@rm -f $(KUBECONFIG) @rm -f $(KUBECONFIG)
.PHONY: build SERVICE = "catalog"
build: ORIGIN = "https://barretthousen.com"
docker build --build-arg "service=runner" -t bh/service-runner -f ./src/Dockerfile.service ./src BUILD_INITIATOR = "Development Machine"
docker build --build-arg "service=catalog" -t bh/service-catalog -f ./src/Dockerfile.service ./src VERSION = $(shell git rev-parse --verify --short HEAD)
docker build --build-arg "service=proxy-admin" -t bh/service-proxy-admin -f ./src/Dockerfile.service ./src GIT_REF = $(shell git rev-parse --verify HEAD)
BUILD_DATE := $(shell date +%Y-%m-%d-%T)
.PHONY: build-client-image
build-client-image:
docker build \
--label 'com.barretthousen.service=$(SERVICE)' \
--label 'com.barretthousen.version=$(VERSION)' \
--label 'com.barretthousen.git-ref=$(GIT_REF)' \
--label 'com.barretthousen.build-date=$(BUILD_DATE)' \
--label 'com.barrethousen.builder=$(BUILD_INITIATOR)' \
--build-arg 'origin=$(ORIGIN)' \
-t barretthousen/client-$(SERVICE):$(VERSION) \
-t git.vdhsn.com/barretthousen/client-$(SERVICE):$(VERSION) \
-f ./src/$(SERVICE)/Dockerfile.frontend ./src/$(SERVICE)
docker push git.vdhsn.com/barretthousen/client-$(SERVICE):$(VERSION)
.PHONY: build-backend-image
build-backend-image:
docker build \
--label 'com.barretthousen.service=$(SERVICE)' \
--label 'com.barretthousen.version="$(VERSION)"' \
--label 'com.barretthousen.git-ref="$(GIT_REF)"' \
--label 'com.barretthousen.build-date=$(BUILD_DATE)' \
--label 'com.barrethousen.builder=$(BUILD_INITIATOR)' \
--build-arg "service=$(SERVICE)" \
-t barretthousen/service-$(SERVICE):$(VERSION) \
-t git.vdhsn.com/barretthousen/service-$(SERVICE):$(VERSION) \
-f ./src/Dockerfile.prod-backend ./src
docker push git.vdhsn.com/barretthousen/service-$(SERVICE):$(VERSION)
.PHONY: push-image
push-image:
.PHONY: acceptance-test .PHONY: acceptance-test
acceptance-test: acceptance-test:

View File

@ -16,21 +16,22 @@ helm_repo('grafana', 'https://grafana.github.io/helm-charts', labels=["9-repos"]
helm_resource( helm_resource(
'ingress', 'ingress',
'traefik/traefik', 'traefik/traefik',
namespace='barretthousen-local',
flags=[ flags=[
'--set', 'logs.access.enabled=true' '--set', 'logs.access.enabled=true'
], ],
resource_deps=['traefik'],
port_forwards=[ port_forwards=[
port_forward(8000, 8000, name='Barretthousen'), port_forward(8000, 8000, name='Barretthousen'),
port_forward(9000, 9000, name='Traefik', link_path='/dashboard/#/') port_forward(9000, 9000, name='Traefik', link_path='/dashboard/#/')
], ],
resource_deps=['traefik'],
labels=["1-ingress"] labels=["1-ingress"]
) )
helm_resource( helm_resource(
'postgres', 'postgres',
'bitnami/postgresql', 'bitnami/postgresql',
resource_deps=['bitnami'], namespace='barretthousen-local',
flags=[ flags=[
'--set', 'fullnameOverride=bh-db', '--set', 'fullnameOverride=bh-db',
'--set', 'auth.enablePostgresUser=true', '--set', 'auth.enablePostgresUser=true',
@ -39,6 +40,7 @@ helm_resource(
], ],
port_forwards=[ port_forwards=[
port_forward(5432, 5432, name='BH DB')], port_forward(5432, 5432, name='BH DB')],
resource_deps=['bitnami'],
labels=["9-data"]) labels=["9-data"])
@ -48,7 +50,8 @@ def bh_backend_service(service="", port_forwards=[], migrateDB=False, devMode=Tr
'{}-go-compile'.format(service), '{}-go-compile'.format(service),
'CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -gcflags "all=-N -l" -o .bin/{}-debug ./src/{}'.format(service, service), 'CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -gcflags "all=-N -l" -o .bin/{}-debug ./src/{}'.format(service, service),
deps=['./src/{}'.format(service), './src/lib'], deps=['./src/{}'.format(service), './src/lib'],
resource_deps=deps resource_deps=deps,
labels=['3-compilation']
) )
entry_cmd = [ entry_cmd = [
@ -93,7 +96,7 @@ def bh_backend_service(service="", port_forwards=[], migrateDB=False, devMode=Tr
) )
k8s_resource( k8s_resource(
workload='local-{}'.format(service), workload='{}-local'.format(service),
port_forwards=port_forwards, port_forwards=port_forwards,
labels=labels, labels=labels,
resource_deps=deps, resource_deps=deps,
@ -124,7 +127,7 @@ docker_build(
target='development' target='development'
) )
k8s_resource( k8s_resource(
workload='local-web-client', workload='web-client-local',
port_forwards=['8080:80'], port_forwards=['8080:80'],
labels=['2-services'], labels=['2-services'],
resource_deps=['ingress'] resource_deps=['ingress']
@ -153,6 +156,11 @@ k8s_yaml(
kustomize("./env/local") kustomize("./env/local")
) )
k8s_resource(
workload='runner-sync-local',
labels='2-services'
)
k8s_resource( k8s_resource(
workload='ingress', workload='ingress',
labels='1-ingress', labels='1-ingress',

View File

@ -14,7 +14,8 @@ spec:
spec: spec:
containers: containers:
- name: catalog - name: catalog
image: barretthousen/service-catalog image: barretthousen/service-catalog:prod
imagePullPolicy: Always
ports: ports:
- containerPort: 5001 - containerPort: 5001
name: grpc name: grpc

View File

@ -1,4 +1,5 @@
resources: resources:
- ./namespace.yaml
- ./catalog-deployment.yaml - ./catalog-deployment.yaml
- ./runner-deployment.yaml - ./runner-deployment.yaml
- ./proxy-admin-deployment.yaml - ./proxy-admin-deployment.yaml

10
env/base/namespace.yaml vendored Normal file
View File

@ -0,0 +1,10 @@
apiVersion: v1
kind: Namespace
metadata:
name: barretthousen
annotations:
description: |
environment for barretthousen
labels:
name: barretthousen
app: barretthousen

View File

@ -13,7 +13,8 @@ spec:
spec: spec:
containers: containers:
- name: proxy-admin - name: proxy-admin
image: barretthousen/service-proxy-admin image: barretthousen/service-proxy-admin:prod
imagePullPolicy: Always
ports: ports:
- containerPort: 80 - containerPort: 80
name: http name: http
@ -51,4 +52,4 @@ data:
log_level: 2 log_level: 2
port: 80 port: 80
endpoints: endpoints:
runner: local-runner:5001 runner: runner-local:5001

View File

@ -13,7 +13,8 @@ spec:
spec: spec:
containers: containers:
- name: proxy-client - name: proxy-client
image: barretthousen/service-proxy-client image: barretthousen/service-proxy-client:prod
imagePullPolicy: Always
ports: ports:
- containerPort: 80 - containerPort: 80
name: http name: http

View File

@ -14,9 +14,8 @@ spec:
spec: spec:
containers: containers:
- name: runner - name: runner
image: barretthousen/service-runner image: barretthousen/service-runner:prod
tty: true imagePullPolicy: Always
stdin: true
ports: ports:
- containerPort: 5001 - containerPort: 5001
name: grpc name: grpc

View File

@ -3,7 +3,7 @@ kind: CronJob
metadata: metadata:
name: runner-sync name: runner-sync
spec: spec:
schedule: "* * * * *" schedule: "*/2 * * * *"
jobTemplate: jobTemplate:
spec: spec:
template: template:
@ -13,12 +13,12 @@ spec:
spec: spec:
restartPolicy: OnFailure restartPolicy: OnFailure
containers: containers:
- name: sync-runner - name: runner-curl
image: curlimages/curl:latest image: curlimages/curl:latest
command: command:
[ [
"curl", "curl",
"http://local-proxy-admin/api/v1/sync", "http://proxy-admin-local/api/v1/sync",
'-d=''{"target":"liveauctioneers"}''', '-d=''{"target":"liveauctioneers"}''',
"-vvvv", "-vvvv",
] ]

View File

@ -13,7 +13,8 @@ spec:
spec: spec:
containers: containers:
- name: web-client - name: web-client
image: barretthousen/service-web-client image: barretthousen/service-web-client:prod
imagePullPolicy: Always
stdin: true stdin: true
tty: true tty: true
ports: ports:

View File

@ -4,11 +4,8 @@ resources:
commonLabels: commonLabels:
environment: beta environment: beta
namePrefix: beta- nameSuffix: -beta
namespace: barretthousen-beta
# patchesStrategicMerge:
# - debug-catalog.yaml
# - debug-runner.yaml
patches: patches:
- target: - target:
@ -18,6 +15,7 @@ patches:
- op: replace - op: replace
path: /spec/rules/0/host path: /spec/rules/0/host
value: admin.beta.barretthousen.com value: admin.beta.barretthousen.com
- target: - target:
kind: Ingress kind: Ingress
name: web name: web
@ -25,3 +23,43 @@ patches:
- op: replace - op: replace
path: /spec/rules/0/host path: /spec/rules/0/host
value: beta.barretthousen.com value: beta.barretthousen.com
- target:
kind: Deployment
name: catalog
patch: |-
- op: replace
path: /spec/template/spec/containers/0/image
value: git.vdhsn.com/barretthousen/service-catalog:beta
- target:
kind: Deployment
name: runner
patch: |-
- op: replace
path: /spec/template/spec/containers/0/image
value: git.vdhsn.com/barretthousen/service-runner:beta
- target:
kind: Deployment
name: proxy-admin
patch: |-
- op: replace
path: /spec/template/spec/containers/0/image
value: git.vdhsn.com/barretthousen/service-proxy-admin:beta
- target:
kind: Deployment
name: proxy-client
patch: |-
- op: replace
path: /spec/template/spec/containers/0/image
value: git.vdhsn.com/barretthousen/service-proxy-client:beta
- target:
kind: Deployment
name: web-client
patch: |-
- op: replace
path: /spec/template/spec/containers/0/image
value: git.vdhsn.com/barretthousen/client-web-client:beta

View File

@ -4,13 +4,21 @@ resources:
commonLabels: commonLabels:
environment: local environment: local
namePrefix: local- nameSuffix: -local
namespace: barretthousen-local
patchesStrategicMerge: patchesStrategicMerge:
- debug-catalog.yaml - debug-catalog.yaml
- debug-runner.yaml - debug-runner.yaml
patches: patches:
- target:
kind: CronJob
name: runner-sync
patch: |-
- op: replace
path: /spec/schedule
value: "* * * * *"
- target: - target:
kind: Ingress kind: Ingress
name: admin name: admin

View File

@ -1,4 +1,4 @@
FROM golang:1.19-alpine as builder FROM golang:1.19 as builder
ARG service ARG service
@ -7,11 +7,12 @@ RUN go install github.com/kyleconroy/sqlc/cmd/sqlc@latest
COPY . /go/src COPY . /go/src
WORKDIR /go/src/${service} WORKDIR /go/src/
RUN /go/bin/sqlc generate -f /go/src/sqlc.yaml RUN /go/bin/sqlc generate -f /go/src/sqlc.yaml
RUN /go/bin/buf mod update /go/src/src \ RUN /go/bin/buf mod update /go/src && /go/bin/buf generate
&& /go/bin/buf generate
WORKDIR /go/src/${service}
RUN go mod tidy \ RUN go mod tidy \
&& CGO_ENABLED=0 go build -v -gcflags="-trimpath=$(go env GOPATH)" -asmflags="-trimpath=$(go env GOPATH)" -o /opt/${service} /go/src/${service} && CGO_ENABLED=0 go build -v -gcflags="-trimpath=$(go env GOPATH)" -asmflags="-trimpath=$(go env GOPATH)" -o /opt/${service} /go/src/${service}
@ -24,4 +25,4 @@ COPY --from=builder /opt/${service} /opt/${service}
ENV SERVICE=${SERVICE} ENV SERVICE=${SERVICE}
ENTRYPOINT ['/opt/${SERVICE}'] ENTRYPOINT ["/opt/${SERVICE}"]

View File

@ -42,7 +42,7 @@ func main() {
flag.Parse() flag.Parse()
kernel.Run(context.Background(), &runnerApp{ kernel.Run(context.Background(), &runnerApp{
CatalogEndpoint: "local-catalog:5001", CatalogEndpoint: "catalog-local:5001",
LogLevel: kernel.LevelTrace, LogLevel: kernel.LevelTrace,
Port: 5001, Port: 5001,
}) })

View File

@ -23,20 +23,33 @@ WORKDIR /opt/web-client
COPY --from=development /opt/web-client . COPY --from=development /opt/web-client .
RUN npm build \ RUN npm run build \
&& cp -rv /opt/web-client/package.json /opt/web-client/build \ && cp -rv /opt/web-client/package.json /opt/web-client/build \
&& cp -rv /opt/web-client/package-lock.json /opt/web-client/build && cp -rv /opt/web-client/package-lock.json /opt/web-client/build
FROM node:lts AS production FROM node:lts AS production
LABEL com.barretthousen.service="web-client"
LABEL com.barretthousen.tags="frontend,public"
LABEL com.barretthousen.release-date="2023-05-01"
LABEL com.barretthousen.version="alpha-0.0.1"
LABEL com.barretthousen.git-ref="000000000000000000000000000000000000000000000000"
ARG origin=https://barretthousen.com
ENV ENV=production
ENV PROTOCOL_HEADER=x-forwarded-proto
ENV HOST_HEADER=x-forwarded-host
ENV ADDRESS_HEADER=True-Client-IP
ENV ORIGIN=${origin}
WORKDIR /opt WORKDIR /opt
COPY --from=build /var/web-client/build/* /opt/web-client COPY --from=build /opt/web-client/build/* /opt/web-client
ENV PORT 80 ENV PORT 80
EXPOSE 80 EXPOSE 80
ENTRYPOINT ['node'] ENTRYPOINT ["node", "web-client"]
CMD ['web-client']

View File

@ -2,7 +2,7 @@ import { browser } from '$app/environment';
import type { PageLoad } from './$types'; import type { PageLoad } from './$types';
// TODO: change to env var // TODO: change to env var
const API_HOST = `${browser ? '': 'http://local-proxy-client.default'}/api/v1`; const API_HOST = `${browser ? '': 'http://proxy-client-local.default'}/api/v1`;
interface SearchPageData { interface SearchPageData {
page: number page: number