Skip to content

Instantly share code, notes, and snippets.

@jagedn
Created May 17, 2024 07:47
Show Gist options
  • Save jagedn/5c386aaca02d3c3bfe8bf49e4e46ad37 to your computer and use it in GitHub Desktop.
Save jagedn/5c386aaca02d3c3bfe8bf49e4e46ad37 to your computer and use it in GitHub Desktop.
`DOCKER_BUILDKIT=1 docker build --target=runtime -t myapp .`
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