FROM golang:1-alpine AS build WORKDIR /src COPY go.mod go.sum ./ RUN go mod download COPY . . ARG VERSION=dev RUN CGO_ENABLED=0 go build -trimpath -ldflags "-s -w -X main.version=${VERSION}" -o /out/canon ./cmd/canon FROM alpine:3 RUN apk add --no-cache ca-certificates tzdata su-exec \ && mkdir -p /data /backups COPY --from=build /out/canon /usr/local/bin/canon COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh RUN chmod 755 /usr/local/bin/docker-entrypoint.sh # The entrypoint starts as root only to set ownership, then runs Canon as # PUID:PGID. ENV CANON_DATA_DIR=/data \ CANON_PORT=4242 \ PUID=1000 \ PGID=1000 \ UMASK=022 VOLUME /data /backups EXPOSE 4242 HEALTHCHECK --interval=30s --timeout=3s --start-period=5s \ CMD wget -qO- http://127.0.0.1:${CANON_PORT}/healthz >/dev/null || exit 1 ENTRYPOINT ["docker-entrypoint.sh"]