forked from praetorian-inc/gokart
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[praetorian-incGH-48] Reduce docker image size.
- Loading branch information
Showing
3 changed files
with
54 additions
and
10 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 |
---|---|---|
@@ -1,8 +1,18 @@ | ||
# syntax=docker/dockerfile:1 | ||
|
||
FROM golang:1.16-alpine | ||
FROM golang:1.17.0-alpine3.14 as builder | ||
WORKDIR /app | ||
COPY . /app/ | ||
RUN go build -o /gokart | ||
RUN CGO_ENABLED=0 go build -o /gokart && \ | ||
adduser -D -g '' gokart | ||
|
||
ENTRYPOINT [ "/gokart" ] | ||
FROM alpine:3.14.2 | ||
ENV HOME=/opt/gokart | ||
ENV BIN=/opt/gokart/bin | ||
ENV PATH=${BIN}:${PATH} | ||
COPY --from=builder /etc/passwd /etc/passwd | ||
COPY --from=builder /gokart ${BIN}/ | ||
RUN mkdir -p ${BIN} && \ | ||
echo -e "#!/bin/sh -e\nexec \"\$@\"" > ${BIN}/entrypoint.sh && \ | ||
chmod +x ${BIN}/entrypoint.sh | ||
USER gokart | ||
ENTRYPOINT ["entrypoint.sh"] | ||
CMD ["gokart"] |
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
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