Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
70691a95
Unverified
Commit
70691a95
authored
Jun 27, 2023
by
Derek Nola
Committed by
GitHub
Jun 27, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Faster K3s Binary Build Option (#7805)
* Add local build option Signed-off-by:
Derek Nola
<
derek.nola@suse.com
>
parent
2215870d
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
88 additions
and
6 deletions
+88
-6
.dockerignore
.dockerignore
+2
-0
Dockerfile.local
Dockerfile.local
+71
-0
Makefile
Makefile
+7
-0
binary_size_check.sh
scripts/binary_size_check.sh
+3
-2
validate
scripts/validate
+5
-4
No files found.
.dockerignore
View file @
70691a95
...
@@ -5,3 +5,4 @@
...
@@ -5,3 +5,4 @@
./.cache
./.cache
./.dapper
./.dapper
./.trash-cache
./.trash-cache
./.git/objects/pack
\ No newline at end of file
Dockerfile.local
0 → 100644
View file @
70691a95
ARG GOLANG=golang:1.20.4-alpine3.18
FROM ${GOLANG} as infra
ARG http_proxy=$http_proxy
ARG https_proxy=$https_proxy
ARG no_proxy=$no_proxy
ENV http_proxy=$http_proxy
ENV https_proxy=$https_proxy
ENV no_proxy=$no_proxy
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 python3 py3-pip 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 \
&& \
if [ "$(go env GOARCH)" = "amd64" ]; then \
apk -U --no-cache add mingw-w64-gcc; \
fi
RUN python3 -m pip install awscli
# this works for both go 1.17 and 1.18
RUN GOPROXY=direct go install golang.org/x/tools/cmd/goimports@gopls/v0.11.0
RUN rm -rf /go/src /go/pkg
RUN if [ "$(go env GOARCH)" = "amd64" ]; then \
curl -sL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.51.2; \
fi
ARG SELINUX=true
ENV SELINUX $SELINUX
ENV STATIC_BUILD true
ENV SRC_DIR=/go/src/github.com/k3s-io/k3s
WORKDIR ${SRC_DIR}/
FROM infra as build
ARG SKIP_VALIDATE
COPY ./scripts/ ./scripts
COPY ./go.mod ./go.sum ./main.go ./
COPY ./manifests ./manifests
RUN mkdir -p bin dist
RUN --mount=type=cache,id=gomod,target=/go/pkg/mod \
./scripts/download
COPY ./cmd ./cmd
COPY ./pkg ./pkg
COPY ./tests ./tests
COPY ./.git ./.git
RUN --mount=type=cache,id=gomod,target=/go/pkg/mod \
--mount=type=cache,id=gobuild,target=/root/.cache/go-build \
./scripts/build
COPY ./contrib ./contrib
RUN --mount=type=cache,id=gomod,target=/go/pkg/mod \
--mount=type=cache,id=gobuild,target=/root/.cache/go-build \
./scripts/package-cli
RUN ./scripts/binary_size_check.sh
FROM scratch as result
ENV SRC_DIR=/go/src/github.com/k3s-io/k3s
COPY --from=build ${SRC_DIR}/dist /dist
COPY --from=build ${SRC_DIR}/bin /bin
COPY --from=build ${SRC_DIR}/build/out /build/out
COPY --from=build ${SRC_DIR}/build/static /build/static
COPY --from=build ${SRC_DIR}/pkg/static /pkg/static
COPY --from=build ${SRC_DIR}/pkg/deploy /pkg/deploy
\ No newline at end of file
Makefile
View file @
70691a95
...
@@ -37,3 +37,9 @@ image-scan:
...
@@ -37,3 +37,9 @@ image-scan:
format
:
format
:
gofmt
-s
-l
-w
$(GO_FILES)
gofmt
-s
-l
-w
$(GO_FILES)
goimports
-w
$(GO_FILES)
goimports
-w
$(GO_FILES)
.PHONY
:
local
local
:
DOCKER_BUILDKIT
=
1 docker build
\
--build-arg
=
"REPO TAG GITHUB_TOKEN GOLANG GOCOVER DEBUG"
\
-t
k3s-local
-f
Dockerfile.local
--output
=
.
.
\ No newline at end of file
scripts/binary_size_check.sh
View file @
70691a95
...
@@ -2,12 +2,13 @@
...
@@ -2,12 +2,13 @@
set
-e
set
-e
GO
=
${
GO
-go
}
ARCH
=
${
ARCH
:-$(
"
${
GO
}
"
env
GOARCH
)}
if
[
"
${
DEBUG
}
"
=
1
]
;
then
if
[
"
${
DEBUG
}
"
=
1
]
;
then
set
-x
set
-x
fi
fi
.
./scripts/version.sh
# Try to keep the K3s binary under 70 megabytes.
# Try to keep the K3s binary under 70 megabytes.
# "64M ought to be enough for anybody"
# "64M ought to be enough for anybody"
MAX_BINARY_MB
=
70
MAX_BINARY_MB
=
70
...
...
scripts/validate
View file @
70691a95
#!/bin/bash
#!/bin/bash
set
-e
set
-e
if
[
-n
"
$SKIP_VALIDATE
"
]
;
then
echo
Skipping validation
exit
fi
cd
$(
dirname
$0
)
/..
cd
$(
dirname
$0
)
/..
echo
Running: go mod tidy
echo
Running: go mod tidy
...
@@ -9,10 +14,6 @@ go mod tidy
...
@@ -9,10 +14,6 @@ go mod tidy
echo
Running: go generate
echo
Running: go generate
go generate
go generate
if
[
-n
"
$SKIP_VALIDATE
"
]
;
then
echo
Skipping validation
exit
fi
echo
Running validation
echo
Running validation
.
./scripts/version.sh
.
./scripts/version.sh
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment