This repository has been archived on 2025-08-23. You can view files and clone it, but cannot push or open issues or pull requests.
Files
GreenCoast/Dockerfile
Dani e2651456da Fixed up the .gitignore
More push to move towards a deployment stage
2025-08-21 20:57:23 -04:00

39 lines
1.2 KiB
Docker

# syntax=docker/dockerfile:1.7
########################
# builder
########################
FROM --platform=$BUILDPLATFORM golang:1.22-bookworm AS build
ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT
WORKDIR /src
COPY go.mod ./
RUN --mount=type=cache,target=/root/.cache/go-build \
go mod download && go mod verify
# Copy the rest and tidy (creates go.sum if missing)
COPY . .
RUN --mount=type=cache,target=/root/.cache/go-build go mod tidy
ENV CGO_ENABLED=0
RUN --mount=type=cache,target=/root/.cache/go-build \
if [ "${TARGETARCH}${TARGETVARIANT}" = "armv6" ]; then export GOARM=6; fi && \
if [ "${TARGETARCH}${TARGETVARIANT}" = "armv7" ]; then export GOARM=7; fi && \
GOOS=$TARGETOS GOARCH=$TARGETARCH go build -trimpath -ldflags="-s -w" \
-o /out/greencoast-shard ./cmd/shard
########################
# runtime
########################
FROM gcr.io/distroless/base-debian12:nonroot
WORKDIR /app
COPY --from=build /out/greencoast-shard /app/greencoast-shard
COPY configs/shard.sample.yaml /app/shard.yaml
COPY client /app/client
VOLUME ["/var/lib/greencoast"]
EXPOSE 8080 8081 8443 9443
USER nonroot:nonroot
ENTRYPOINT ["/app/greencoast-shard","--config","/app/shard.yaml"]