ARG UBI_IMAGE

FROM ${UBI_IMAGE} as ubi

RUN microdnf update

# At runtime, apiserver generate certificates in /code directory
# hence, provide RW permission for user 1001
RUN mkdir /code
RUN rm -rf /tmp
RUN mkdir /tmp

FROM scratch
COPY  --from=ubi /code /code
COPY  --from=ubi /tmp /tmp
COPY  --from=ubi /lib /lib
COPY  --from=ubi /lib64 /lib64

ADD  bin/apiserver-amd64 /code/apiserver
ADD  bin/filecheck-amd64 /code/filecheck

WORKDIR /code

ENTRYPOINT ["./apiserver"]
