Skip to content
Draft
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
4 changes: 2 additions & 2 deletions .github/workflows/build-k3s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile.local
file: ./Dockerfile
target: result
# Defined actions like this don't ingest GITHUB_ENV, so use outputs
# and manual set the build arguments
Expand All @@ -92,7 +92,7 @@ jobs:
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile.local
file: ./Dockerfile
target: result
build-args: |
GIT_TAG=${{ steps.git_vars.outputs.git_tag }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/trivy-trigger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:

- name: Build And Save K3s Image
run: |
make local-image
make image
make tag-image-latest
docker save -o k3s.tar rancher/k3s:latest

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,5 @@ go install golang.org/x/tools/cmd/goimports@latest
then run:

```
make format
make validate
```
2 changes: 1 addition & 1 deletion Dockerfile.local → Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ FROM ${GOLANG} AS infra
RUN apk -U --no-cache add bash git gcc musl-dev docker vim less file curl wget ca-certificates jq linux-headers \
zlib-dev tar zip squashfs-tools npm coreutils openssl-dev libffi-dev libseccomp libseccomp-dev \
libseccomp-static make libuv-static sqlite-dev sqlite-static libselinux libselinux-dev zlib-dev zlib-static \
zstd pigz alpine-sdk binutils-gold btrfs-progs-dev btrfs-progs-static gawk yq pipx \
zstd pigz alpine-sdk binutils-gold btrfs-progs-dev btrfs-progs-static gawk yq pipx aws-cli \
&& \
if [ "$(go env GOARCH)" = "amd64" ]; then \
apk -U --no-cache add mingw-w64-gcc; \
Expand Down
59 changes: 0 additions & 59 deletions Dockerfile.dapper

This file was deleted.

50 changes: 22 additions & 28 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,6 @@ TARGETS := $(shell ls scripts | grep -v \\.sh)
GO_FILES ?= $$(find . -name '*.go')
SHELL := /bin/bash


.dapper:
@echo Downloading dapper
@curl -sL https://releases.rancher.com/dapper/v0.6.0/dapper-$$(uname -s)-$$(uname -m) > .dapper.tmp
@@chmod +x .dapper.tmp
@./.dapper.tmp -v
@mv .dapper.tmp .dapper

.PHONY: docker.sock
docker.sock:
while ! docker version 1>/dev/null; do sleep 1; done

$(TARGETS): .dapper docker.sock
./.dapper $@

.PHONY: deps
deps:
go mod tidy
Expand All @@ -26,7 +11,8 @@ release:

.DEFAULT_GOAL := ci

.PHONY: $(TARGETS)
.PHONY: ci
ci: binary image airgap

build/data:
mkdir -p $@
Expand All @@ -44,16 +30,16 @@ format:
goimports -w $(GO_FILES)


.PHONY: local-validate
local-validate:
.PHONY: validate
validate:
DOCKER_BUILDKIT=1 docker build \
--build-arg="SKIP_VALIDATE=$(SKIP_VALIDATE)" \
--build-arg="DEBUG=$(DEBUG)" \
--progress=plain \
-f Dockerfile.local --target=validate .
-f Dockerfile --target=validate .

.PHONY: local-binary
local-binary:
.PHONY: binary
binary:
@echo "INFO: Building K3s binaries and assets..."
. ./scripts/git_version.sh && \
DOCKER_BUILDKIT=1 docker build \
Expand All @@ -64,17 +50,25 @@ local-binary:
--build-arg="GOCOVER=$(GOCOVER)" \
--build-arg="GOOS=$(GOOS)" \
--build-arg="DEBUG=$(DEBUG)" \
-f Dockerfile.local --target=result --output=. .
-f Dockerfile --target=result --output=. .

.PHONY: local-image
local-image: local-binary
.PHONY: image
image: binary
@echo "INFO: Building K3s image..."
./scripts/package-image

.PHONY: local-airgap
local-airgap:
.PHONY: airgap
airgap:
@echo "INFO: Building K3s airgap tarball..."
./scripts/package-airgap

.PHONY: local-ci
local-ci: local-binary local-image local-airgap
BRANCH := $(shell git rev-parse --abbrev-ref HEAD | sed 's/\//-/g')
in-docker-%: ## Advanced: wraps any script in Docker environment, for example: in-docker-package-cli
mkdir -p ./bin/ ./dist ./build
docker buildx build -t k3s:$(BRANCH) --target infra - < Dockerfile
docker run --privileged --rm --network host \
-v $${PWD}:/go/src/github.com/k3s-io/k3s -v /var/run/docker.sock:/var/run/docker.sock -v /tmp:/tmp -v k3s-pkg:/go/pkg -v k3s-cache:/root/.cache/go-build \
-e GODEBUG -e CI -e GOCOVER -e REPO -e TAG -e GITHUB_ACTION_TAG -e KUBERNETES_VERSION -e IMAGE_NAME -e AWS_SECRET_ACCESS_KEY -e AWS_ACCESS_KEY_ID \
-e DOCKER_PASSWORD -e DOCKER_USERNAME -e GH_TOKEN -e SKIP_VALIDATE -e SKIP_IMAGE -e SKIP_AIRGAP -e GITHUB_TOKEN \
-e GIT_CONFIG_COUNT=1 -e GIT_CONFIG_KEY_0=safe.directory -e GIT_CONFIG_VALUE_0=/go/src/github.com/k3s-io/k3s \
k3s:$(BRANCH) ./scripts/$*
2 changes: 1 addition & 1 deletion scripts/clean
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

cd $(dirname $0)/..

rm -rf dist bin build k3s hyperkube kubectl
rm -rf dist bin build k3s kubectl ./pkg/deploy/embed/* ./pkg/static/embed/* ./pkg/data/embed/*
Copy link
Member

@brandond brandond Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't do this. there are .empty files in the embed directories that must exist, otherwise go:embed will fail go vet if you don't have all the embedded stuff pre-staged by make download

Maybe just do git clean -xffd to remove all untracked files?

Loading