-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: more work on optimization proliferation of docker layers
Signed-off-by: Nick Mitchell <[email protected]>
- Loading branch information
Showing
3 changed files
with
40 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,5 @@ | |
/tests | ||
.git | ||
*.log | ||
*~ | ||
*.tar.gz | ||
**/*~ | ||
**/*.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,36 @@ | ||
FROM docker.io/golang:1.22.6-alpine as builder | ||
# download go modules | ||
FROM docker.io/golang:1.22.6-alpine as base | ||
LABEL lunchpail=temp | ||
WORKDIR /init | ||
|
||
ENV CGO_ENABLED=0 | ||
COPY go.* . | ||
RUN go mod download | ||
|
||
COPY go.mod . | ||
COPY go.sum . | ||
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg/mod go mod download -x | ||
|
||
COPY cmd cmd | ||
COPY pkg pkg | ||
COPY charts charts | ||
|
||
# build the CLI | ||
RUN go generate ./... && \ | ||
FROM base as builder | ||
LABEL lunchpail=temp | ||
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg/mod \ | ||
go generate ./... && \ | ||
go generate ./... && \ | ||
go build -ldflags="-s -w" -o lunchpail cmd/main.go && \ | ||
chmod a+rX lunchpail && \ | ||
find . -name '*.tar.gz' -exec rm {} \; | ||
go build -ldflags="-s -w" -o /tmp/lunchpail cmd/main.go && \ | ||
find . -name '*.tar.gz' -exec rm {} \; && \ | ||
chmod a+rX /tmp/lunchpail | ||
|
||
FROM docker.io/alpine:3 | ||
LABEL org.opencontainers.image.source="https://github.com/IBM/lunchpail" | ||
LABEL lunchpail=final org.opencontainers.image.source="https://github.com/IBM/lunchpail" | ||
|
||
RUN adduser -u 2000 lunchpail -G root --disabled-password && echo "lunchpail:lunchpail" | chpasswd && chmod -R g=u /home/lunchpail | ||
ENV HOME=/home/lunchpail | ||
WORKDIR /home/lunchpail | ||
|
||
COPY --from=builder /init/lunchpail /usr/local/bin/lunchpail | ||
COPY --from=builder /tmp/lunchpail /usr/local/bin/lunchpail | ||
|
||
USER lunchpail | ||
CMD ["lunchpail"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters