# Base image Example
# ----------------
#############################################
# Temp image to build the prerequisites
#############################################
FROM registry.access.redhat.com/ubi8/ubi:latest AS builder
RUN groupadd -g 1001 appuser && \
useradd -m -s /sbin/nologin -u 1001 -g appuser appuser
#############################################
# Container Image
#############################################
FROM registry.access.redhat.com/ubi8/ubi-minimal:latest
MAINTAINER Dev4Devs <[email protected]>
# Define Labels
LABEL name="my.dev4devs-com/docker-multi-stages-build-image" \
maintainer="[email protected]" \
vendor="Dev4Devs"
# Define EnvVars
ENV APP=/usr/local/bin/app \
USER_UID=1001 \
USER_NAME=appuser \
USER_HOME=/home/appuser
# Copy group and user created in the builder image
COPY --from=builder /etc/passwd /tmp
COPY --from=builder /etc/group /tmp
# Create the user and group in this image and add permissions
RUN cat /tmp/passwd | grep ${USER_NAME} >> /etc/passwd \
&& cat /tmp/group | grep ${USER_NAME} >> /etc/group \
&& mkdir -p ${USER_HOME} \
&& chown -R ${USER_NAME}:${USER_NAME} ${USER_HOME} \
&& chmod ug+rwx ${USER_HOME} \
&& rm -rf /tmp/passwd \
&& rm -rf /tmp/group
# Use the user created to run the container as rootless
USER ${USER_UID}
# Installs the operator binary
COPY build/_output/bin/${USER_NAME} ${PROXY}
COPY build/bin /usr/local/bin
# This allows the Platform to validate the authority the image
# More info: https://docs.openshift.com/container-platform/3.11/creating_images/guidelines.html#openshift-specific-guidelines
ENTRYPOINT ["/usr/local/bin/entrypoint"]
# Execute the operator
CMD exec ${APP} $@
Last active
September 12, 2019 17:43
-
-
Save camilamacedo86/fcb573d859e6077d39c1982f28642124 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment