Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/dstockhammer/docker-python-poetry

Docker image with Python + Poetry
https://github.com/dstockhammer/docker-python-poetry

docker poetry python

Last synced: about 2 months ago
JSON representation

Docker image with Python + Poetry

Awesome Lists containing this project

README

        

# docker-python-poetry

Docker image containing [Python](https://www.python.org) + [Poetry](https://python-poetry.org).

[![Docker Image Version (latest semver)](https://img.shields.io/docker/v/dstockhammer/python-poetry?sort=semver)](https://hub.docker.com/r/dstockhammer/python-poetry)
[![GitHub last commit](https://img.shields.io/github/last-commit/dstockhammer/docker-python-poetry)](https://github.com/dstockhammer/docker-python-poetry/commits/main)

## Usage

```dockerfile
FROM dstockhammer/python-poetry:3.11 AS builder

WORKDIR /app

ENV POETRY_VIRTUALENVS_IN_PROJECT=1 \
POETRY_VIRTUALENVS_OPTIONS_ALWAYS_COPY=1 \
POETRY_VIRTUALENVS_OPTIONS_NO_PIP=1 \
POETRY_VIRTUALENVS_OPTIONS_NO_SETUPTOOLS=1

COPY pyproject.toml poetry.lock ./
RUN poetry install --only=main --no-root --no-ansi --no-interaction

FROM python:3.11-slim

WORKDIR /app

ENV PYTHONFAULTHANDLER=1 \
PYTHONHASHSEED=random \
PYTHONUNBUFFERED=1

RUN addgroup app --gid 1000 \
&& adduser app --home /app --uid 1000 --gid 1000 --disabled-login --disabled-password

COPY --from=builder /app/.venv ./.venv
COPY src ./src

USER 1000

ENTRYPOINT [ "/app/.venv/bin/python" ]
```