#!BuildTag: harbor/harbor-registryctl:%%PKG_VERSION%%
#!BuildTag: harbor/harbor-registryctl:%%PKG_VERSION%%-rev%%IMAGE_REVISION%%
#!BuildTag: harbor/harbor-registryctl:%%PKG_VERSION%%-rev%%IMAGE_REVISION%%-build%RELEASE%

FROM suse/sle15:15.2

# labelprefix=com.suse.registry
PREFIXEDLABEL org.opencontainers.image.title="SUSE private registry, Harbor registryctl container"
PREFIXEDLABEL org.opencontainers.image.description="Harbor registryctl container image for SUSE private registry"
PREFIXEDLABEL org.opencontainers.image.created="%BUILDTIME%"
PREFIXEDLABEL org.opencontainers.image.vendor="SUSE LLC"
PREFIXEDLABEL org.opencontainers.image.url="https://www.suse.com/products/"
PREFIXEDLABEL org.opencontainers.image.version="%%PKG_VERSION%%-rev%%IMAGE_REVISION%%-build%RELEASE%"
PREFIXEDLABEL org.openbuildservice.disturl="%DISTURL%"
PREFIXEDLABEL org.opensuse.reference="registry.suse.com/harbor/harbor-registryctl:%%PKG_VERSION%%-rev%%IMAGE_REVISION%%-build%RELEASE%" 

COPY ./entrypoint.sh /usr/local/bin/entrypoint.sh

#======================================
# Create the registry_DO_NOT_USE_GC symlink needed
# by the harbor registryctl component (see 
# https://github.com/goharbor/harbor/issues/11606)
#--------------------------------------
RUN ln -s /usr/bin/registry /usr/bin/registry_DO_NOT_USE_GC

RUN groupadd -r -g 10001 registry \
  && useradd -r -g registry -d /var/lib/registry -s /sbin/nologin -m -l -c "user for Harbor registry" -u 10001 registry \
  && chmod +x /usr/local/bin/entrypoint.sh
RUN zypper --non-interactive in harbor-registryctl gosu

VOLUME /var/lib/docker-registry
WORKDIR /var/lib/harbor
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
