Skip to content
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
8 changes: 6 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ jobs:
CGO_ENABLED: "0"
GOOS: linux
GOARCH: amd64
run: go build -o coder-k8s ./
run: |
mkdir -p linux/amd64
go build -o linux/amd64/coder-k8s ./

- name: Build and load image
if: github.event_name != 'pull_request'
Expand Down Expand Up @@ -425,7 +427,9 @@ jobs:
CGO_ENABLED: "0"
GOOS: linux
GOARCH: amd64
run: go build -o coder-k8s ./
run: |
mkdir -p linux/amd64
go build -o linux/amd64/coder-k8s ./

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0
with:
distribution: goreleaser
version: latest
version: "~> v2"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52 changes: 31 additions & 21 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
version: 2

project_name: coder-k8s

before:
Expand All @@ -19,31 +21,39 @@ builds:

archives:
- id: default
format: tar.gz
formats: [tar.gz]
files:
- none*
- LICENSE
- README.md

dockers:
dockers_v2:
- id: coder-k8s-image
image_templates:
- "ghcr.io/coder/coder-k8s:{{ .Version }}"
- "ghcr.io/coder/coder-k8s:latest"
dockerfile: Dockerfile.goreleaser
use: buildx
build_flag_templates:
- "--pull"
- "--platform=linux/amd64"
- "--label=org.opencontainers.image.created={{ .Date }}"
- "--label=org.opencontainers.image.source=https://github.com/coder/coder-k8s"
- "--label=org.opencontainers.image.url=https://coder.github.io/coder-k8s/"
- "--label=org.opencontainers.image.documentation=https://coder.github.io/coder-k8s/"
- "--label=org.opencontainers.image.title=coder-k8s"
- "--label=org.opencontainers.image.description=Kubernetes operator for Coder"
- "--label=org.opencontainers.image.version={{ .Version }}"
- "--label=org.opencontainers.image.revision={{ .FullCommit }}"
- "--label=org.opencontainers.image.vendor=Coder"
- "--label=org.opencontainers.image.licenses=Apache-2.0"
- "--label=org.opencontainers.image.authors=Coder"
ids:
- coder-k8s
images:
- ghcr.io/coder/coder-k8s
tags:
- "{{ .Version }}"
- latest
platforms:
- linux/amd64
sbom: false
labels:
org.opencontainers.image.created: "{{ .Date }}"
org.opencontainers.image.source: https://github.com/coder/coder-k8s
org.opencontainers.image.url: https://coder.github.io/coder-k8s/
org.opencontainers.image.documentation: https://coder.github.io/coder-k8s/
org.opencontainers.image.title: coder-k8s
org.opencontainers.image.description: Kubernetes operator for Coder
org.opencontainers.image.version: "{{ .Version }}"
org.opencontainers.image.revision: "{{ .FullCommit }}"
org.opencontainers.image.vendor: Coder
org.opencontainers.image.licenses: Apache-2.0
org.opencontainers.image.authors: Coder
flags:
- "--pull=true"
- "--provenance=false"

changelog:
use: github
4 changes: 3 additions & 1 deletion Dockerfile.goreleaser
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM gcr.io/distroless/static:nonroot

ARG TARGETPLATFORM

ENTRYPOINT ["/coder-k8s"]
COPY coder-k8s /coder-k8s
COPY $TARGETPLATFORM/coder-k8s /coder-k8s
USER nonroot:nonroot
17 changes: 16 additions & 1 deletion hack/kind-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,22 @@ build_binary() {
fi
fi

GOFLAGS=-mod=vendor CGO_ENABLED=0 GOOS=linux GOARCH="${resolved_goarch}" go build -o coder-k8s ./
local resolved_goarm=""
local target_platform="linux/${resolved_goarch}"
if [[ "${resolved_goarch}" == "arm" ]]; then
resolved_goarm="${GOARM:-}"
if [[ -z "${resolved_goarm}" ]]; then
resolved_goarm="$(go env GOARM)"
if [[ -z "${resolved_goarm}" ]]; then
echo "assertion failed: go env GOARM returned an empty value for GOARCH=arm" >&2
exit 1
fi
fi
target_platform="linux/arm/v${resolved_goarm}"
fi

mkdir -p "${target_platform}"
GOFLAGS=-mod=vendor CGO_ENABLED=0 GOOS=linux GOARCH="${resolved_goarch}" GOARM="${resolved_goarm}" go build -o "${target_platform}/coder-k8s" ./
}

build_and_load_image() {
Expand Down