16 lines
618 B
Docker
16 lines
618 B
Docker
# syntax=docker/dockerfile:1
|
|
FROM golang:1.27.2-alpine AS build
|
|
WORKDIR /app
|
|
COPY go.mod go.sum ./
|
|
RUN --mount=type=cache,target=/go/pkg/mod go mod download
|
|
COPY . .
|
|
RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build CGO_ENABLED=0 go build -trimpath -o /out/api ./cmd/api
|
|
|
|
FROM alpine:3.23 AS runtime
|
|
RUN apk add --no-cache ca-certificates && adduser -D -u 10001 app
|
|
COPY --from=build /out/api /usr/local/bin/api
|
|
USER app
|
|
EXPOSE 8080
|
|
HEALTHCHECK --interval=5s --timeout=3s --start-period=5s --retries=5 CMD wget -q -O /dev/null http://127.0.0.1:8080/health || exit 1
|
|
CMD ["api"]
|