Skip to content

Commit

Permalink
chore: set CGO_ENABLED=0 for the bin and image release
Browse files Browse the repository at this point in the history
Signed-off-by: peefy <xpf6677@163.com>
  • Loading branch information
Peefy committed Oct 14, 2024
1 parent 09d9cf7 commit 617a595
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ before:
# .goreleaser.yml
builds:
- id: default
env:
- CGO_ENABLED=0
main: ./cmd/kcl/main.go
binary: kcl
goos:
Expand All @@ -18,8 +20,6 @@ builds:
goarch:
- amd64
- arm64
flags:
- -tags=rpc
ldflags:
- "-X kcl-lang.io/cli/pkg/version.version={{.Version}}"

Expand Down
7 changes: 2 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ WORKDIR /src
ARG TARGETOS
ARG TARGETARCH

ENV CGO_ENABLED=0

RUN --mount=type=cache,target=/go/pkg --mount=type=cache,target=/root/.cache/go-build GOOS=${TARGETOS} GOARCH=${TARGETARCH} make build

FROM --platform=${BUILDPLATFORM} ubuntu:22.04 AS base
Expand All @@ -20,16 +22,11 @@ ARG TARGETARCH

COPY --from=build /src/bin/kcl /usr/local/bin/kcl
RUN /usr/local/bin/kcl
RUN cp -r /root/go/bin/* /usr/local/bin/
RUN apt-get update && apt-get install make gcc git -y && rm -rf /var/lib/apt/lists/*
# The reason for doing this below is to prevent the
# container from not having write permissions.
ENV KCL_PKG_PATH=/tmp
ENV KCL_CACHE_PATH=/tmp
# In the image, we can generate a runtime in advance to
# avoid writing files in the image
ENV KCL_GO_DISABLE_INSTALL_ARTIFACT=true
ENV KCL_GO_DISABLE_ARTIFACT_IN_PATH=false
# Install the tini
ENV TINI_VERSION v0.19.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-${TARGETARCH} /tini
Expand Down

0 comments on commit 617a595

Please sign in to comment.