forked from IBM/lunchpail
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
36 lines (28 loc) · 1.01 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# download go modules
FROM docker.io/golang:1.23.3-alpine as base
LABEL lunchpail=temp
WORKDIR /init
ENV CGO_ENABLED=0
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
# build the CLI
FROM base as builder
LABEL lunchpail=temp
RUN find cmd
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 /tmp/lunchpail cmd/main.go && \
find . -name '*.tar.gz' -exec rm {} \; && \
chmod a+rX /tmp/lunchpail
FROM docker.io/alpine:3
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 /tmp/lunchpail /usr/local/bin/lunchpail
USER lunchpail
CMD ["lunchpail"]