Created
June 6, 2022 18:04
-
-
Save icarus44-zer0/495cffc6fb0107b0c84edb809f9ebf23 to your computer and use it in GitHub Desktop.
python:3.8.5-slim-buster- multi-stage - non-root - virtualenv
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
FROM python:3.8.5-slim-buster as base | |
LABEL maintainer="Your Name <[email protected]>" \ | |
version="1.0.0" | |
RUN apt-get update && apt-get install tzdata -y --no-install-recommends | |
ENV TZ="America/Los_Angeles" | |
ENV PIP_NO_CACHE_DIR=1 | |
ENV PIP_DISABLE_PIP_VERSION_CHECK=1 | |
ENV PYTHONDONTWRITEBYTECODE=1 | |
FROM base as builder | |
RUN adduser worker | |
USER worker | |
WORKDIR /home/worker | |
COPY --chown=worker:worker requirements.txt /home/worker/requirements.txt | |
ENV PATH="/home/worker/.local/bin:$PATH" | |
ENV PATH="/home/worker/venv/bin:$PATH" | |
RUN python3 -m pip install --upgrade pip && \ | |
python3 -m pip install --upgrade setuptools && \ | |
python3 -m pip install virtualenv | |
RUN python3 -m venv /home/worker/venv | |
RUN pip install -r requirements.txt | |
FROM base | |
RUN adduser worker | |
USER worker | |
WORKDIR /home/worker | |
COPY --from=builder /home/worker /home/worker | |
COPY --from=builder /home/worker/venv /home/worker/venv | |
COPY --chown=worker:worker . . | |
ENV PATH="/home/worker/venv/bin:$PATH" | |
ENTRYPOINT ["python"] | |
CMD ["src/main.py"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment