diff --git a/Dockerfile b/Dockerfile index 91880ac..2e19da3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,23 @@ -FROM python:3.9 +FROM ubuntu:jammy AS python-builder + +RUN apt-get update && \ + apt-get install -y python3 python3-venv && \ + rm -rf /var/lib/apt/lists/* + +RUN python3 -m venv /venv && \ + /venv/bin/pip install -U pip setuptools + +COPY requirements.txt /app/requirements.txt +RUN /venv/bin/pip install --no-deps --requirement /app/requirements.txt + +COPY . /app +RUN /venv/bin/pip install --no-deps /app + + +FROM ubuntu:jammy + +# Don't buffer stdout and stderr as it breaks realtime logging +ENV PYTHONUNBUFFERED 1 # Create the user that will be used to run the app ENV APP_UID 1001 @@ -14,24 +33,12 @@ RUN groupadd --gid $APP_GID $APP_GROUP && \ --uid $APP_UID \ $APP_USER -# Install tini, which we will use to marshal the processes RUN apt-get update && \ - apt-get install -y tini && \ + apt-get install -y ca-certificates python3 tini && \ rm -rf /var/lib/apt/lists/* -# Don't buffer stdout and stderr as it breaks realtime logging -ENV PYTHONUNBUFFERED 1 - -# Install dependencies -# Doing this separately by copying only the requirements file enables better use of the build cache -COPY ./requirements.txt /application/ -RUN pip install --no-deps --requirement /application/requirements.txt - -# Install the application -COPY . /application -RUN pip install --no-deps -e /application +COPY --from=python-builder /venv /venv -# By default, run the operator using kopf USER $APP_UID ENTRYPOINT ["tini", "-g", "--"] -CMD ["kopf", "run", "--module", "capi_janitor.openstack.operator", "--all-namespaces"] +CMD ["/venv/bin/kopf", "run", "--module", "capi_janitor.openstack.operator", "--all-namespaces"] diff --git a/requirements.txt b/requirements.txt index 041bdd8..015c2cf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,7 +6,7 @@ attrs==23.1.0 certifi==2023.7.22 charset-normalizer==3.2.0 click==8.1.6 -easykube @ git+https://github.com/stackhpc/easykube.git@28208e4d07fab1eb74a21b05de102142fb1fc4ad +easykube==0.1.1 exceptiongroup==1.1.2 frozenlist==1.4.0 h11==0.14.0