Created
May 17, 2024 07:47
-
-
Save jagedn/5c386aaca02d3c3bfe8bf49e4e46ad37 to your computer and use it in GitHub Desktop.
`DOCKER_BUILDKIT=1 docker build --target=runtime -t myapp .`
This file contains hidden or 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.10.12 as builder | |
RUN pip install poetry==1.4.2 | |
ENV POETRY_NO_INTERACTION=1 \ | |
POETRY_VIRTUALENVS_IN_PROJECT=1 \ | |
POETRY_VIRTUALENVS_CREATE=1 \ | |
POETRY_CACHE_DIR=/tmp/poetry_cache | |
WORKDIR /app | |
COPY pyproject.toml poetry.lock ./ | |
RUN touch README.md | |
RUN --mount=type=cache,target=$POETRY_CACHE_DIR poetry install --without dev --no-root | |
FROM python:3.10.12 as runtime | |
ENV VIRTUAL_ENV=/app/.venv \ | |
PATH="/app/.venv/bin:$PATH" | |
ENV PYTHONPATH=/src | |
COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV} | |
RUN pip install pysqlite3-binary | |
COPY src ./src | |
COPY .env . | |
ENTRYPOINT ["python", "-m", "src.main"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment