From dd0ae5c74f1e226e9b0dcd82e77cb3d3e45a1ad9 Mon Sep 17 00:00:00 2001 From: Tom Tuffin Date: Fri, 11 Aug 2023 15:55:12 +0200 Subject: [PATCH] refactor: changes to container image to reduce size Reduces the overall size from ~2gb to ~500mb - Use CentOS stream dev image - Switch from ansible to ansible-core --- Dockerfile | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 97babe0ce..291841ef9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,21 @@ -FROM registry.access.redhat.com/ubi8/python-39 +FROM quay.io/centos/centos:stream9-development ARG USER_ID=${USER_ID:-1001} +ARG APP_DIR=${APP_DIR:-/app} ARG DEVEL_COLLECTION_LIBRARY=0 -WORKDIR $HOME USER 0 -RUN dnf install -y java-17-openjdk-devel +RUN useradd -u $USER_ID -d $APP_DIR appuser +WORKDIR $APP_DIR +COPY . $WORKDIR +RUN chown -R $USER_ID $APP_DIR +RUN dnf install -y java-17-openjdk-devel python3-pip + +USER $USER_ID ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk +ENV PATH="${PATH}:$APP_DIR/.local/bin" RUN pip install -U pip \ - && pip install ansible \ + && pip install ansible-core \ ansible-runner \ jmespath \ asyncio \ @@ -21,8 +28,4 @@ RUN pip install -U pip \ RUN bash -c "if [ $DEVEL_COLLECTION_LIBRARY -ne 0 ]; then \ ansible-galaxy collection install git+https://github.com/ansible/event-driven-ansible.git --force; fi" -COPY . $WORKDIR -RUN chown -R $USER_ID ./ - -USER $USER_ID RUN pip install .