Skip to content

Commit

Permalink
chore: normalizes and improves readability for container files (#83)
Browse files Browse the repository at this point in the history
* chore: updates integration directory to workflows under tests

Integration is not very precise for the types of tests.
Updates to workflows to reflect that this should test each model path.

Signed-off-by: Jennifer Power <[email protected]>

* chore: removes some extra comments in the Containerfile and moves poetry envs

Some of the comments are explained by the code so removes to make this more
readable. The poetry environment variables should not be in the base because
poetry is not installed in the final image.

Signed-off-by: Jennifer Power <[email protected]>

---------

Signed-off-by: Jennifer Power <[email protected]>
  • Loading branch information
jpower432 authored Nov 30, 2023
1 parent 7b1ae49 commit 70c8950
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 26 deletions.
41 changes: 16 additions & 25 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,18 @@
FROM registry.access.redhat.com/ubi8/ubi-minimal:latest as python-base

ENV PYTHONUNBUFFERED=1 \
# prevents python creating .pyc files
PYTHONDONTWRITEBYTECODE=1 \
\
# pip
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
\
# poetry
# https://python-poetry.org/docs/configuration/#using-environment-variables
POETRY_VERSION=1.5.1 \
# make poetry install to this location
POETRY_HOME="/opt/poetry" \
# make poetry create the virtual environment in the project's root
# it gets named `.venv`
POETRY_VIRTUALENVS_IN_PROJECT=true \
# do not ask any interactive question
POETRY_NO_INTERACTION=1 \
\
# paths
# this is where our requirements + virtual environment will live
# Paths for the virtual environment and working directory
PYSETUP_PATH="/trestle-bot" \
VENV_PATH="/trestle-bot/.venv"

LABEL maintainer="Red Hat Product Security" \
summary="Trestle Bot"


# prepend poetry and venv to path
ENV PATH="$POETRY_HOME/bin:$VENV_PATH/bin:$PATH"
# Ensure we use the virtualenv
ENV PATH="$VENV_PATH/bin:$PATH"

RUN microdnf update -y \
&& microdnf install -y python3.9 git \
Expand All @@ -40,28 +23,36 @@ RUN microdnf update -y \

FROM python-base as dependencies

# install poetry - respects $POETRY_VERSION & $POETRY_HOME
ARG POETRY_VERSION=1.5.1

# https://python-poetry.org/docs/configuration/#using-environment-variables
ENV POETRY_HOME="/opt/poetry" \
POETRY_VIRTUALENVS_IN_PROJECT=true \
POETRY_NO_INTERACTION=1

ENV PATH="$POETRY_HOME/bin:$PATH"

# install poetry - respects $POETRY_HOME
RUN python3.9 -m pip install --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir poetry=="$POETRY_VERSION"

# Cache runtime deps
WORKDIR "/build"
COPY . "/build"

# Install runtime deps and install the project in non-editable mode.
RUN python -m venv $VENV_PATH && \
RUN python3.9 -m venv $VENV_PATH && \
. $VENV_PATH/bin/activate && \
poetry install --without tests,dev --no-root && \
poetry build -f wheel -n && \
pip install --no-cache-dir --no-deps dist/*.whl && \
rm -rf dist *.egg-info

# final image

FROM python-base as final

COPY --from=dependencies $PYSETUP_PATH $PYSETUP_PATH

# Add wrappers for entrypoints that provide support the actions
# Add wrappers for entrypoints that provide support for the actions
COPY ./actions/autosync/auto-sync-entrypoint.sh /
COPY ./actions/rules-transform/rules-transform-entrypoint.sh /
COPY ./actions/create-cd/create-cd-entrypoint.sh /
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""Integration tests between different types of tasks classes."""
"""Tests that validate workflow outcomes by model type."""

0 comments on commit 70c8950

Please sign in to comment.