-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: updates Dockerfile to comply with GitHub actions guidelines
Signed-off-by: Jennifer Power <[email protected]>
- Loading branch information
Showing
1 changed file
with
60 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,68 @@ | ||
FROM registry.access.redhat.com/ubi8/python-38:1 | ||
FROM python:3.8.1-slim as python-base | ||
|
||
ENV POETRY_NO_INTERACTION=1 | ||
ENV PYTHONUNBUFFERED=1 \ | ||
# prevents python creating .pyc files | ||
PYTHONDONTWRITEBYTECODE=1 \ | ||
\ | ||
# pip | ||
PIP_NO_CACHE_DIR=off \ | ||
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 | ||
PYSETUP_PATH="/trestle-bot" \ | ||
VENV_PATH="/trestle-bot/.venv" | ||
|
||
COPY ./ /trestle-bot | ||
|
||
WORKDIR /trestle-bot | ||
# prepend poetry and venv to path | ||
ENV PATH="$POETRY_HOME/bin:$VENV_PATH/bin:$PATH" | ||
|
||
USER root | ||
FROM python-base as dependencies | ||
RUN apt-get update \ | ||
&& apt-get install --no-install-recommends -y \ | ||
# deps for building python deps | ||
build-essential | ||
|
||
# Install dependencies | ||
RUN python3.8 -m pip install --no-cache-dir --upgrade pipx \ | ||
&& pipx install poetry==1.5.1 \ | ||
&& poetry config virtualenvs.create false \ | ||
&& poetry install --without tests,dev | ||
# install poetry - respects $POETRY_VERSION & $POETRY_HOME | ||
RUN python3.8 -m pip install --upgrade pip \ | ||
&& pip install poetry=="$POETRY_VERSION" | ||
|
||
RUN chown -HR 1001:1001 /trestle-bot \ | ||
&& chown -HR 1001:1001 /opt/app-root/src/ | ||
# Cache runtime deps | ||
WORKDIR $PYSETUP_PATH | ||
COPY ./ $PYSETUP | ||
|
||
USER 1001 | ||
RUN poetry install --without tests,dev | ||
|
||
ENTRYPOINT poetry run trestle-bot \ | ||
--markdown-path="${MARKDOWN_PATH}" \ | ||
--assemble-model="${ASSEMBLE_MODEL}" \ | ||
--ssp-index-path="${SSP_INDEX_PATH}" \ | ||
--commit-message="${COMMIT_MESSAGE}" \ | ||
--branch="${BRANCH}" \ | ||
--patterns="${PATTERNS}" \ | ||
--committer-name="${COMMIT_USER_NAME}" \ | ||
--committer-email="${COMMIT_USER_EMAIL}" \ | ||
--author-name="${AUTHOR_NAME}" \ | ||
--author-email="${AUTHOR_EMAIL}" \ | ||
--working-dir="${WORKING_DIR}" | ||
# final image | ||
FROM python-base as final | ||
|
||
COPY --from=dependencies $PYSETUP_PATH $PYSETUP_PATH | ||
|
||
RUN apt-get update \ | ||
&& apt-get install --no-install-recommends -y git | ||
|
||
ENTRYPOINT [ "/bin/sh", "-c", "python3.8 -m trestlebot \ | ||
--markdown-path=${MARKDOWN_PATH} \ | ||
--assemble-model=${ASSEMBLE_MODEL} \ | ||
--ssp-index-path=${SSP_INDEX_PATH} \ | ||
--commit-message=${COMMIT_MESSAGE} \ | ||
--branch=${BRANCH} \ | ||
--patterns=${PATTERNS} \ | ||
--committer-name=${COMMIT_USER_NAME} \ | ||
--committer-email=${COMMIT_USER_EMAIL} \ | ||
--author-name=${AUTHOR_NAME} \ | ||
--author-email=${AUTHOR_EMAIL} \ | ||
--working-dir=${WORKING_DIR}" ] | ||
|