Update Dockerfile

This commit is contained in:
2vb 2024-05-19 11:53:21 +00:00
parent 9deca27ca7
commit 72b20f9c49

View File

@ -1,8 +1,29 @@
FROM golang:1.22 # Stage 1: Build Binary
FROM golang:1.22 AS builder
WORKDIR /app WORKDIR /app
# Download Dependencies
COPY go.mod go.sum ./ COPY go.mod go.sum ./
RUN go mod download RUN --mount=type=cache,target=/root/.cache/go-build \
go mod download
# Setup and Build
COPY . ./ COPY . ./
RUN CGO_ENABLED=0 GOOS=linux go build -o /snow RUN --mount=type=bind \
CGO_ENABLED=0 GOOS=linux go build -o /snow
# Stage 2: Deploy Binary
FROM busybox:1.36-glibc as busybox
FROM gcr.io/distroless/base AS deploy
WORKDIR /app
# Copy binaries from Busybox
COPY --from=busybox /bin /bin
# Setup user
RUN adduser -D -h /app snow
RUN chown snow /app
COPY --from=builder --chown=snow --chmod=700 /snow /app/snow
EXPOSE 3000 EXPOSE 3000
CMD ["/snow"] ENTRYPOINT ["/app/snow"]