Create `python-poetry` Docker build scripts

pull/1/head
Joseph Hale 2 years ago
commit 66f895fe6d

@ -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

@ -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.

@ -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

@ -0,0 +1,17 @@
<!--
Copyright (c) 2022 Joseph Hale
This software is released under the MIT License.
https://opensource.org/licenses/MIT
-->
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"
```
Loading…
Cancel
Save