Skip to content

Commit

Permalink
chore: add skaffold
Browse files Browse the repository at this point in the history
  • Loading branch information
WitoDelnat committed Oct 22, 2024
1 parent 068d044 commit 7e51736
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
LICENSE
README.md
Makefile
build
docs
assets
config
choco
test
test
skaffold.yaml
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ movie.mp4
/dist
.vscode


build/_local/values.dev.yaml
46 changes: 46 additions & 0 deletions build/_local/agent-server.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
###################################
## Build
###################################
FROM --platform=$BUILDPLATFORM golang:1.23-alpine AS builder

ARG TARGETOS
ARG TARGETARCH
ARG GOMODCACHE="/root/.cache/go-build"
ARG GOCACHE="/go/pkg"
ARG SKAFFOLD_GO_GCFLAGS

RUN apk --no-cache --update add ca-certificates && (rm -rf /var/cache/apk/* || 0)

WORKDIR /app
COPY . .
RUN --mount=type=cache,target="$GOMODCACHE" \
--mount=type=cache,target="$GOCACHE" \
GOOS=$TARGETOS \
GOARCH=$TARGETARCH \
CGO_ENABLED=0 \
go build -gcflags="${SKAFFOLD_GO_GCFLAGS}" -o build/_local/agent-server cmd/api-server/main.go

###################################
## Debug
###################################
FROM golang:1.23-alpine AS debug

ENV GOTRACEBACK=all
RUN go install github.com/go-delve/delve/cmd/[email protected]

COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /app/build/_local/agent-server /testkube/

ENTRYPOINT ["/go/bin/dlv", "exec", "--headless", "--continue", "--accept-multiclient", "--listen=:56268", "--api-version=2", "/testkube/agent-server"]

###################################
## Distribution
###################################
FROM scratch AS dist

COPY LICENSE /testkube/
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /app/build/_local/cloud-api /testkube/

EXPOSE 8080
ENTRYPOINT ["/testkube/agent-server"]
12 changes: 12 additions & 0 deletions build/_local/values.dev.tpl.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
testkube-dashboard:
enabled: false
mongodb:
enabled: false
testkube-api:
cloud:
url: testkube-enterprise-api:8089
tls:
enabled: false
existingSecret:
name: testkube-default-agent-token
key: agent-token
24 changes: 24 additions & 0 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
variable "GOCACHE" {
default = "/go/pkg"
}
variable "GOMODCACHE" {
default = "/root/.cache/go-build"
}

group "default" {
targets = ["agent-server"]
}

target "agent-server-meta" {
tags = ["kubeshop/tk-agent-server:dev"]
}
target "agent-server" {
inherits = ["agent-server-meta"]
context="."
dockerfile = "build/_local/agent-server.Dockerfile"
platforms = ["linux/arm64"]
args = {
GOCACHE = "${GOCACHE}"
GOMODCACHE = "${GOMODCACHE}"
}
}
36 changes: 36 additions & 0 deletions skaffold.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: skaffold/v4beta11
kind: Config
metadata:
name: testkube-agent
build:
artifacts:
- image: docker.io/testkube-agent-server
context: .
custom:
buildCommand: GOCACHE="$(go env GOCACHE)" GOMODCACHE="$(go env GOMODCACHE)" docker buildx bake --set agent-server.tags="$IMAGE" --set agent-server.target="debug" agent-server
dependencies:
dockerfile:
path: build/_local/agent-server.Dockerfile
deploy:
helm:
# see https://skaffold.dev/docs/renderers/helm/#skaffoldyaml-configuration
releases:
- name: testkube-agent
repo: https://kubeshop.github.io/helm-charts
remoteChart: testkube
# Alternative: Local chart - useful for when you are actively making changes to the chart.
# chartPath: /Users/you/code/helm-charts/charts/testkube-api
upgradeOnChange: true
skipBuildDependencies: true # This implies that you need to build dependencies yourself when you make local chart changes!
namespace: tk-dev
wait: true
createNamespace: true
valuesFiles: ['build/_local/values.dev.yaml'] # IMPORTANT: You will have to copy the values.dev.tpl.yaml template to get started!
setValueTemplates:
testkube-api.image.registry: '{{.IMAGE_DOMAIN_docker_io_testkube_agent_server}}'
testkube-api.image.repository: '{{.IMAGE_REPO_NO_DOMAIN_docker_io_testkube_agent_server}}'
testkube-api.image.tag: '{{.IMAGE_TAG_docker_io_testkube_agent_server}}@{{.IMAGE_DIGEST_docker_io_testkube_agent_server}}'
flags:
upgrade: ["--no-hooks"]
statusCheckDeadlineSeconds: 300
tolerateFailuresUntilDeadline: true

0 comments on commit 7e51736

Please sign in to comment.