Skip to content

Commit

Permalink
Merge pull request #1 from max-pfeiffer/feature/multiple_poetry_versions
Browse files Browse the repository at this point in the history
Feature/multiple poetry versions
  • Loading branch information
max-pfeiffer authored Oct 10, 2022
2 parents 185e041 + adc8b24 commit 00644b8
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 36 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Install Poetry
uses: abatilo/[email protected]
with:
poetry-version: 1.1.11
poetry-version: 1.1.15
- name: Install dependencies
run: |
poetry config virtualenvs.in-project true
Expand Down Expand Up @@ -43,7 +43,7 @@ jobs:
- name: Install Poetry
uses: abatilo/[email protected]
with:
poetry-version: 1.1.11
poetry-version: 1.1.15
- name: Install dependencies
run: |
poetry config virtualenvs.in-project true
Expand Down Expand Up @@ -78,7 +78,7 @@ jobs:
- name: Install Poetry
uses: abatilo/[email protected]
with:
poetry-version: 1.1.11
poetry-version: 1.1.15
- name: Install dependencies
run: |
poetry config virtualenvs.in-project true
Expand Down
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,10 @@ repos:
rev: 22.10.0
hooks:
- id: black
- repo: local
hooks:
- id: pylint
name: pylint
entry: pylint
language: system
types: [python]
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
[![codecov](https://codecov.io/gh/max-pfeiffer/python-poetry/branch/main/graph/badge.svg?token=WQI2SJJLZN)](https://codecov.io/gh/max-pfeiffer/uvicorn-poetry)
![pipeline workflow](https://github.com/max-pfeiffer/python-poetry/actions/workflows/pipeline.yml/badge.svg)
# python-poetry
A Python Docker image with Poetry installed and ready to use.
A Python Docker image with [Poetry](https://python-poetry.org/) installed and
ready to use. You can use this image as base image for your own application
which uses [Poetry](https://python-poetry.org/) for dependency management.

## Docker Image Features
1. Poetry versions:
2. v1.1.15
3. v1.2.2
3. Python versions:
4. v3.7
5. v3.8
6. v3.9
5. v3.10
5 changes: 2 additions & 3 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# References: using official Python images
# https://hub.docker.com/_/python
ARG OFFICIAL_PYTHON_IMAGE
ARG IMAGE_POETRY_VERSION
ARG APPLICATION_SERVER_PORT
FROM ${OFFICIAL_PYTHON_IMAGE}
ARG POETRY_VERSION

LABEL maintainer="Max Pfeiffer <[email protected]>"

Expand All @@ -18,7 +17,7 @@ LABEL maintainer="Max Pfeiffer <[email protected]>"
ENV PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
POETRY_VERSION=${IMAGE_POETRY_VERSION} \
POETRY_VERSION=${POETRY_VERSION} \
POETRY_HOME="/opt/poetry"

ENV PATH="$POETRY_HOME/bin:$PATH"
Expand Down
80 changes: 64 additions & 16 deletions build/constants.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,73 @@
PYTHON_POETRY_IMAGE_NAME: str = "pfeiffermax/python-poetry"
TARGET_ARCHITECTURES: list[str] = [
"python3.9.14-bullseye-poetry1.2.1",
"python3.9.14-slim-bullseye-poetry1.2.1",
"python3.10.7-bullseye-poetry1.2.1",
"python3.10.7-slim-bullseye-poetry1.2.1",
"poetry1.1.15-python3.7.14-bullseye",
"poetry1.1.15-python3.7.14-slim-bullseye",
"poetry1.1.15-python3.8.14-bullseye",
"poetry1.1.15-python3.8.14-slim-bullseye",
"poetry1.1.15-python3.9.14-bullseye",
"poetry1.1.15-python3.9.14-slim-bullseye",
"poetry1.1.15-python3.10.7-bullseye",
"poetry1.1.15-python3.10.7-slim-bullseye",
"poetry1.2.2-python3.7.14-bullseye",
"poetry1.2.2-python3.7.14-slim-bullseye",
"poetry1.2.2-python3.8.14-bullseye",
"poetry1.2.2-python3.8.14-slim-bullseye",
"poetry1.2.2-python3.9.14-bullseye",
"poetry1.2.2-python3.9.14-slim-bullseye",
"poetry1.2.2-python3.10.7-bullseye",
"poetry1.2.2-python3.10.7-slim-bullseye",
]
BASE_IMAGES: dict = {
TARGET_ARCHITECTURES[0]: "python:3.9.14-bullseye",
TARGET_ARCHITECTURES[1]: "python:3.9.14-slim-bullseye",
TARGET_ARCHITECTURES[2]: "python:3.10.7-bullseye",
TARGET_ARCHITECTURES[3]: "python:3.10.7-slim-bullseye",
TARGET_ARCHITECTURES[0]: "python:3.7.14-bullseye",
TARGET_ARCHITECTURES[1]: "python:3.7.14-slim-bullseye",
TARGET_ARCHITECTURES[2]: "python:3.8.14-bullseye",
TARGET_ARCHITECTURES[3]: "python:3.8.14-slim-bullseye",
TARGET_ARCHITECTURES[4]: "python:3.9.14-bullseye",
TARGET_ARCHITECTURES[5]: "python:3.9.14-slim-bullseye",
TARGET_ARCHITECTURES[6]: "python:3.10.7-bullseye",
TARGET_ARCHITECTURES[7]: "python:3.10.7-slim-bullseye",
TARGET_ARCHITECTURES[8]: "python:3.7.14-bullseye",
TARGET_ARCHITECTURES[9]: "python:3.7.14-slim-bullseye",
TARGET_ARCHITECTURES[10]: "python:3.8.14-bullseye",
TARGET_ARCHITECTURES[11]: "python:3.8.14-slim-bullseye",
TARGET_ARCHITECTURES[12]: "python:3.9.14-bullseye",
TARGET_ARCHITECTURES[13]: "python:3.9.14-slim-bullseye",
TARGET_ARCHITECTURES[14]: "python:3.10.7-bullseye",
TARGET_ARCHITECTURES[15]: "python:3.10.7-slim-bullseye",
}
PYTHON_VERSIONS: dict = {
TARGET_ARCHITECTURES[0]: "3.9.14",
TARGET_ARCHITECTURES[1]: "3.9.14",
TARGET_ARCHITECTURES[2]: "3.10.7",
TARGET_ARCHITECTURES[3]: "3.10.7",
TARGET_ARCHITECTURES[0]: "3.7.14",
TARGET_ARCHITECTURES[1]: "3.7.14",
TARGET_ARCHITECTURES[2]: "3.8.14",
TARGET_ARCHITECTURES[3]: "3.8.14",
TARGET_ARCHITECTURES[4]: "3.9.14",
TARGET_ARCHITECTURES[5]: "3.9.14",
TARGET_ARCHITECTURES[6]: "3.10.7",
TARGET_ARCHITECTURES[7]: "3.10.7",
TARGET_ARCHITECTURES[8]: "3.7.14",
TARGET_ARCHITECTURES[9]: "3.7.14",
TARGET_ARCHITECTURES[10]: "3.8.14",
TARGET_ARCHITECTURES[11]: "3.8.14",
TARGET_ARCHITECTURES[12]: "3.9.14",
TARGET_ARCHITECTURES[13]: "3.9.14",
TARGET_ARCHITECTURES[14]: "3.10.7",
TARGET_ARCHITECTURES[15]: "3.10.7",
}
POETRY_VERSIONS: dict = {
TARGET_ARCHITECTURES[0]: "1.2.1",
TARGET_ARCHITECTURES[1]: "1.2.1",
TARGET_ARCHITECTURES[2]: "1.2.1",
TARGET_ARCHITECTURES[3]: "1.2.1",
TARGET_ARCHITECTURES[0]: "1.1.15",
TARGET_ARCHITECTURES[1]: "1.1.15",
TARGET_ARCHITECTURES[2]: "1.1.15",
TARGET_ARCHITECTURES[3]: "1.1.15",
TARGET_ARCHITECTURES[4]: "1.1.15",
TARGET_ARCHITECTURES[5]: "1.1.15",
TARGET_ARCHITECTURES[6]: "1.1.15",
TARGET_ARCHITECTURES[7]: "1.1.15",
TARGET_ARCHITECTURES[8]: "1.2.2",
TARGET_ARCHITECTURES[9]: "1.2.2",
TARGET_ARCHITECTURES[10]: "1.2.2",
TARGET_ARCHITECTURES[11]: "1.2.2",
TARGET_ARCHITECTURES[12]: "1.2.2",
TARGET_ARCHITECTURES[13]: "1.2.2",
TARGET_ARCHITECTURES[14]: "1.2.2",
TARGET_ARCHITECTURES[15]: "1.2.2",
}
2 changes: 1 addition & 1 deletion build/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def build(self, target_architecture: str, version: str = None) -> Image:

buildargs: dict[str, str] = {
"OFFICIAL_PYTHON_IMAGE": BASE_IMAGES[target_architecture],
"IMAGE_POETRY_VERSION": POETRY_VERSIONS[target_architecture],
"POETRY_VERSION": POETRY_VERSIONS[target_architecture],
}
tag: str = f"{self.image_name}:{self.version_tag}-{target_architecture}"

Expand Down
16 changes: 8 additions & 8 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ python = "3.9.*"
python-dotenv = "0.21.0"

[tool.poetry.dev-dependencies]
pylint = "2.15.3"
pylint = "2.15.4"
pytest = "7.1.3"
pytest-cov = "4.0.0"
coverage = "6.5.0"
docker = "6.0.0"
requests = "2.28.1"
black = "22.10.0"
pre-commit = "2.20.0"
semver = "2.13.0"
Expand Down
2 changes: 1 addition & 1 deletion tests/configuration/test_poetry_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ def test_poetry_configuration(
poetry_version: str = POETRY_VERSIONS[
image_tag_components.target_architecture
]
assert f"Poetry (version {poetry_version})" in output.decode("utf-8")
assert poetry_version in output.decode("utf-8")
2 changes: 1 addition & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def create_from_tag(cls, tag: str):
target_architecture_index = [
index
for index, tag_part in enumerate(image_tag_parts)
if tag_part.startswith("python")
if tag_part.startswith("poetry")
][0]

version: str = "-".join(image_tag_parts[:target_architecture_index])
Expand Down

0 comments on commit 00644b8

Please sign in to comment.