go-performance/Dockerfile
2024-07-11 14:12:22 -05:00

25 lines
696 B
Docker

# Build Container
####
FROM golang:alpine AS builder
COPY . /go/src/app
WORKDIR /go/src/app
RUN apk add --no-cache git && \
git config --global --add safe.directory /go/src/app && \
addgroup -S -g 1000 app && \
adduser --disabled-password -G app --gecos "application account" --home "/home/app" --shell "/sbin/nologin" --no-create-home --uid 1000 app && \
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -tags timetzdata -o go-webserver ./
# Step 3 - Running Container
####
FROM scratch
COPY --from=builder /etc/passwd /etc/group /etc/
COPY --from=builder --chown=app:app /go/src/app/go-webserver /app/go-webserver
USER app:app
WORKDIR /app/
ENTRYPOINT ["/app/go-webserver"]