-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
26 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,12 +1,28 @@ | ||
FROM golang:1.17 AS builder | ||
WORKDIR /source | ||
COPY go.mod . | ||
COPY go.sum . | ||
ARG GO_VERSION=1.17 | ||
|
||
## Build container | ||
FROM golang:${GO_VERSION}-alpine AS builder | ||
|
||
RUN mkdir /user && \ | ||
echo 'nobody:x:65534:65534:nobody:/:' > /user/passwd && \ | ||
echo 'nobody:x:65534:' > /user/group | ||
|
||
RUN apk add --no-cache ca-certificates git zip | ||
|
||
WORKDIR /src | ||
|
||
COPY ./go.mod ./go.sum ./ | ||
RUN go mod download | ||
COPY . . | ||
RUN CGO_ENABLED=0 GOOS=linux go build -a -o teledock ./cmd/teledock/main.go | ||
|
||
FROM scratch | ||
WORKDIR /bot/ | ||
COPY --from=builder /source/teledock . | ||
CMD ["./teledock"] | ||
COPY ./ ./ | ||
RUN CGO_ENABLED=0 go build -installsuffix 'static' -o /teledock /src/cmd/teledock | ||
|
||
## Final container | ||
FROM scratch AS final | ||
|
||
COPY --from=builder /user/group /user/passwd /etc/ | ||
COPY --from=builder /teledock /teledock | ||
|
||
USER 65534:65534 | ||
|
||
ENTRYPOINT ["/teledock"] |