Merge pull request #22 from solaris765/master

FEAT: added user to build
This commit is contained in:
Pierre Zemb 2019-11-12 08:42:51 +01:00 committed by GitHub
commit 08d27145aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,10 +2,18 @@
FROM golang:latest as builder
WORKDIR /go/src/github.com/PierreZ/goStatic
COPY . .
RUN CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -tags netgo -installsuffix netgo
RUN mkdir ./bin && \
CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -tags netgo -installsuffix netgo -o ./bin/goStatic && \
mkdir ./bin/etc && \
ID=$(shuf -i 100-9999 -n 1) && \
echo $ID && \
echo "appuser:x:$ID:$ID::/sbin/nologin:/bin/false" > ./bin/etc/passwd && \
echo "appgroup:x:$ID:appuser" > ./bin/etc/group
# stage 1
FROM scratch
WORKDIR /
COPY --from=builder /go/src/github.com/PierreZ/goStatic/goStatic .
COPY --from=builder /go/src/github.com/PierreZ/goStatic/bin/ .
USER appuser
ENTRYPOINT ["/goStatic"]