snow/Dockerfile

33 lines
648 B
Docker
Raw Normal View History

2024-05-19 11:53:21 +00:00
# Stage 1: Build Binary
FROM golang:1.22 AS builder
2024-05-15 00:20:23 +00:00
WORKDIR /app
2024-05-19 11:53:21 +00:00
# Download Dependencies
2024-05-15 00:20:23 +00:00
COPY go.mod go.sum ./
2024-05-19 11:53:21 +00:00
RUN --mount=type=cache,target=/root/.cache/go-build \
go mod download
# Setup and Build
2024-05-15 00:27:16 +00:00
COPY . ./
2024-05-19 11:53:21 +00:00
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 --from=busybox /bin /bin
2024-05-29 07:08:16 +00:00
RUN mkdir /app/data
# Copy snow binary and configuration files
COPY --from=builder /snow /app/snow
2024-05-19 11:53:21 +00:00
# Setup user
2024-05-29 07:08:16 +00:00
RUN adduser -D -h /app snow && \
chown -R snow:snow /app
USER snow
2024-05-19 11:53:21 +00:00
2024-05-15 00:20:23 +00:00
EXPOSE 3000
2024-05-19 11:53:21 +00:00
ENTRYPOINT ["/app/snow"]