-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
still having python issues.
- Loading branch information
mike dupont
committed
Oct 11, 2023
1 parent
1f598b0
commit 0261e48
Showing
5 changed files
with
50 additions
and
1,277 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
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 |
---|---|---|
|
@@ -4,8 +4,7 @@ | |
# Dockerfile: https://github.com/max-pfeiffer/python-poetry/blob/main/build/Dockerfile | ||
ARG BASE_IMAGE | ||
FROM ${BASE_IMAGE} | ||
RUN apt update | ||
RUN apt install -y git | ||
ARG APPLICATION_SERVER_PORT | ||
|
||
LABEL maintainer="Mike DuPont <[email protected]>" | ||
|
||
|
@@ -17,27 +16,36 @@ ENV PYTHONUNBUFFERED=1 \ | |
POETRY_VIRTUALENVS_IN_PROJECT=true \ | ||
POETRY_CACHE_DIR="/application_root/.cache" \ | ||
VIRTUAL_ENVIRONMENT_PATH="/application_root/.venv" \ | ||
POETRY_HOME="/opt/poetry" | ||
# https://python-poetry.org/docs/#installing-manually | ||
RUN python -m venv ${VIRTUAL_ENVIRONMENT_PATH} | ||
|
||
APPLICATION_SERVER_PORT=$APPLICATION_SERVER_PORT | ||
# Adding the virtual environment to PATH in order to "activate" it. | ||
# https://docs.python.org/3/library/venv.html#how-venvs-work | ||
ENV PATH="$VIRTUAL_ENVIRONMENT_PATH/bin:$PATH" | ||
|
||
# Principle of least privilege: create a new user for running the application | ||
RUN groupadd -g 1001 python_application && \ | ||
useradd -r -u 1001 -g python_application python_application | ||
|
||
# Set the WORKDIR to the application root. | ||
# https://www.uvicorn.org/settings/#development | ||
# https://docs.docker.com/engine/reference/builder/#workdir | ||
WORKDIR ${PYTHONPATH} | ||
RUN chown python_application:python_application ${PYTHONPATH} | ||
|
||
# Create cache directory and set permissions because user 1001 has no home | ||
# and poetry cache directory. | ||
# https://python-poetry.org/docs/configuration/#cache-directory | ||
RUN mkdir ${POETRY_CACHE_DIR} && chown python_application:python_application ${POETRY_CACHE_DIR} | ||
|
||
# Use the unpriveledged user to run the application | ||
USER 1001 | ||
|
||
WORKDIR /opt/ai-ticket | ||
COPY pyproject.toml /opt/ai-ticket/ | ||
COPY setup.cfg /opt/ai-ticket/ | ||
COPY README.md /opt/ai-ticket/ | ||
COPY requirements.txt /opt/ai-ticket/ | ||
COPY ./src/ /opt/ai-ticket/src/ | ||
|
||
RUN ls ${VIRTUAL_ENVIRONMENT_PATH}/bin/activate | ||
RUN pip install /opt/ai-ticket/ && pip install --trusted-host pypi.python.org -r requirements.txt | ||
RUN pip install /opt/ai-ticket/ | ||
|
||
RUN apt update | ||
RUN apt install -y git | ||
RUN pip install --trusted-host pypi.python.org -r requirements.txt |
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
Oops, something went wrong.