## Build final updatecli docker image
#  We on purpose release artifacts created by goreleaser
#  located in the dist directory

## Goreleaser requires the "--platform" to handle multi-platform builds
# hadolint ignore=DL3029
FROM --platform=${BUILDPLATFORM} debian:stable-slim

LABEL maintainer="Olivier Vernin <me@olblak.com>, Damien DUPORTAL <damien.duportal@gmail.com>"

# Dynamic labels are defined from the goreleaser configuration ".goreleaser.yaml"
LABEL org.opencontainers.image.authors="Olivier Vernin<me@olblak.com>, Damien DUPORTAL <damien.duportal@gmail.com>"
LABEL org.opencontainers.image.url="https://github.com/updatecli/updatecli/pkgs/container/updatecli"
LABEL org.opencontainers.image.documentation="https://www.updatecli.io/docs/prologue/introduction/"
LABEL org.opencontainers.image.licenses="Apache-2.0"
LABEL org.opencontainers.image.title="Updatecli"
LABEL org.opencontainers.image.description="The gitops automation engine"
LABEL org.opencontainers.image.base.name="ghcr.io/updatecli/updatecli"
LABEL org.opencontainers.image.source https://github.com/updatecli/updatecli

# /tmp is used by updatecli to store git repository so it's better
# to define a volume
VOLUME /tmp

## The latest version of these "generic" package is always required
# hadolint ignore=DL3008
RUN apt-get update && \
    apt-get install --yes --no-install-recommends \
        ca-certificates \
        curl \
        tar \
        unzip \
        wget &&\
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

# Available files only matched against the binaries generated by the builds section
# and packages generated by the nfpms section.
COPY updatecli  /usr/local/bin/updatecli

RUN useradd -d /home/updatecli -U -u 1000 -m updatecli

USER updatecli

WORKDIR /home/updatecli

ENTRYPOINT [ "/usr/local/bin/updatecli" ]
CMD ["help"]
