# syntax=docker/dockerfile:1.19.0
# This file is generated by Dofigen v2.8.0
# See https://github.com/lenra-io/dofigen

# builder
FROM golang@sha256:51a7c389a5ddaf82f527191a1e9bff9928655130a44e4975dd1d7e0acf59f1ae AS builder
ARG TARGETARCH
ARG TARGETOS
LABEL \
    org.opencontainers.image.base.digest="sha256:51a7c389a5ddaf82f527191a1e9bff9928655130a44e4975dd1d7e0acf59f1ae" \
    org.opencontainers.image.base.name="docker.io/golang:1.26-alpine" \
    org.opencontainers.image.stage="builder"
ENV \
    CGO_ENABLED="0" \
    TZ="UTC"
WORKDIR /go/src/app
COPY \
    --link \
    "." "."
RUN <<EOF
apk add --no-cache tzdata
go mod download
GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -trimpath -ldflags "-s -w" -o private-location ./cmd/server
EOF

# runtime
FROM alpine@sha256:ce64758a109eb420d874a118f87920e625e12d3634e03b4a5573fd9f6e5d3507 AS runtime
LABEL \
    io.dofigen.version="2.8.0" \
    org.opencontainers.image.authors="OpenStatus Team" \
    org.opencontainers.image.base.digest="sha256:ce64758a109eb420d874a118f87920e625e12d3634e03b4a5573fd9f6e5d3507" \
    org.opencontainers.image.base.name="docker.io/alpine:3.21" \
    org.opencontainers.image.description="Private location orchestrator for OpenStatus" \
    org.opencontainers.image.source="https://github.com/openstatusHQ/openstatus" \
    org.opencontainers.image.title="OpenStatus Private Location" \
    org.opencontainers.image.vendor="OpenStatus"
ENV \
    TZ="UTC" \
    USER="1000" \
    GIN_MODE="release"
WORKDIR /opt/bin
COPY \
    --from=builder \
    --chown=1000:1000 \
    --link \
    "/etc/ssl/certs/ca-certificates.crt" "/etc/ssl/certs/"
COPY \
    --from=builder \
    --chown=1000:1000 \
    --link \
    "/usr/share/zoneinfo" "/usr/share/zoneinfo"
COPY \
    --from=builder \
    --chown=1000:1000 \
    --link \
    "/go/src/app/private-location" "/opt/bin/private-location"
USER 1000:1000
EXPOSE 8080
HEALTHCHECK \
    --interval=15s \
    --timeout=10s \
    --start-period=30s \
    --retries=3 \
    CMD wget --spider -q http://localhost:8080/health || exit 1
CMD ["/opt/bin/private-location"]
