From 66f895fe6dd187ac7ddd7e43c028ff0d9f53229e Mon Sep 17 00:00:00 2001 From: Joseph Hale Date: Tue, 31 May 2022 13:18:42 -0700 Subject: [PATCH] Create `python-poetry` Docker build scripts --- Dockerfile | 38 ++++++++++++++++++++++++++++++++++++++ LICENSE | 21 +++++++++++++++++++++ Makefile | 16 ++++++++++++++++ README.md | 17 +++++++++++++++++ 4 files changed, 92 insertions(+) create mode 100644 Dockerfile create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 README.md diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6ee68d5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,38 @@ +# Copyright (c) 2022 Joseph Hale +# +# This software is released under the MIT License. +# https://opensource.org/licenses/MIT + + +ARG PYTHON_IMAGE_TAG=3.8.13-slim + +############################################################################### +# POETRY BASE IMAGE - Provides environment variables for poetry +############################################################################### +FROM python:${PYTHON_IMAGE_TAG} AS python-poetry-base +ARG POETRY_VERSION=1.1.13 + +ENV POETRY_VERSION=${POETRY_VERSION} +ENV POETRY_HOME="/opt/poetry" +ENV POETRY_VIRTUALENVS_IN_PROJECT=true +ENV POETRY_NO_INTERACTION=1 + +ENV PATH="$POETRY_HOME/bin:$PATH" + + +############################################################################### +# POETRY BUILDER IMAGE - Installs Poetry and dependencies +############################################################################### +FROM python-poetry-base AS python-poetry-builder +RUN apt-get update \ + && apt-get install --no-install-recommends --assume-yes curl +# Install Poetry via the official installer: https://python-poetry.org/docs/master/#installing-with-the-official-installer +# This script respects $POETRY_VERSION & $POETRY_HOME +RUN curl -sSL https://install.python-poetry.org | python3 - + + +############################################################################### +# POETRY RUNTIME IMAGE - Copies the poetry installation into a smaller image +############################################################################### +FROM python-poetry-base AS python-poetry +COPY --from=python-poetry-builder $POETRY_HOME $POETRY_HOME \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b25503b --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 Joseph Hale + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..cc60aaa --- /dev/null +++ b/Makefile @@ -0,0 +1,16 @@ +# Copyright (c) 2022 Joseph Hale +# +# This software is released under the MIT License. +# https://opensource.org/licenses/MIT + +POETRY_VERSION=1.1.13 +PYTHON_IMAGE_TAG=3.8.13-slim +build: + docker build \ + --build-arg POETRY_VERSION=$(POETRY_VERSION) \ + --build-arg PYTHON_IMAGE_TAG=$(PYTHON_IMAGE_TAG) \ + --tag jhale1805/python-poetry:$(POETRY_VERSION)-py$(PYTHON_IMAGE_TAG) \ + . + +run: + docker run --rm --name poetry poetry poetry --version \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..6d72bf7 --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ + + +A robust, configurable `python-poetry` Docker image. + + +## Build +You can build this `python-poetry` image yourself using any version of Poetry +and Python. + +```bash +make build POETRY_VERSION="1.1.13" PYTHON_IMAGE_TAG="3.8.13-slim" +```