diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml index 9a89535..cab333f 100644 --- a/.github/workflows/builds.yml +++ b/.github/workflows/builds.yml @@ -95,31 +95,51 @@ jobs: run: | docker build . --rm --target base \ --build-arg LINUX_VERSION="$LINUX_VERSION" \ + --build-arg POETRY_VERSION="$POETRY_VERSION" \ --build-arg PYTHON_VERSION="$PYTHON_VERSION" \ --cache-from python:"$PYTHON_VERSION$LINUX_TAG" \ -t ghcr.io/br3ndonland/inboard:base"$LINUX_TAG" docker build . --rm --target starlette \ --build-arg LINUX_VERSION="$LINUX_VERSION" \ + --build-arg POETRY_VERSION="$POETRY_VERSION" \ --build-arg PYTHON_VERSION="$PYTHON_VERSION" \ -t ghcr.io/br3ndonland/inboard:starlette"$LINUX_TAG" docker build . --rm --target fastapi \ --build-arg LINUX_VERSION="$LINUX_VERSION" \ + --build-arg POETRY_VERSION="$POETRY_VERSION" \ --build-arg PYTHON_VERSION="$PYTHON_VERSION" \ -t ghcr.io/br3ndonland/inboard:fastapi"$LINUX_TAG" - name: Run Docker containers for testing run: | - docker run -d -p 80:80 \ + docker run -d -p 80:80 --name inboard-base \ -e "BASIC_AUTH_USERNAME=test_user" \ -e "BASIC_AUTH_PASSWORD=r4ndom_bUt_memorable" \ ghcr.io/br3ndonland/inboard:base"$LINUX_TAG" - docker run -d -p 81:80 \ + docker run -d -p 81:80 --name inboard-starlette \ -e "BASIC_AUTH_USERNAME=test_user" \ -e "BASIC_AUTH_PASSWORD=r4ndom_bUt_memorable" \ ghcr.io/br3ndonland/inboard:starlette"$LINUX_TAG" - docker run -d -p 82:80 \ + docker run -d -p 82:80 --name inboard-fastapi \ -e "BASIC_AUTH_USERNAME=test_user" \ -e "BASIC_AUTH_PASSWORD=r4ndom_bUt_memorable" \ ghcr.io/br3ndonland/inboard:fastapi"$LINUX_TAG" + - name: Test Poetry version in Docker containers + run: | + test_poetry_version_in_docker() { + echo "The POETRY_VERSION environment variable is set to $POETRY_VERSION." + local poetry_version_in_docker + for container_name in "$@"; do + poetry_version_in_docker=$(docker exec "$container_name" poetry -V) + if [ -n "$poetry_version_in_docker" ]; then + echo "Docker container $container_name has $poetry_version_in_docker." + fi + case $poetry_version_in_docker in + *$POETRY_VERSION*) echo "Poetry versions match for $container_name." ;; + *) echo "Poetry version test failed for $container_name." && return 1 ;; + esac + done + } + test_poetry_version_in_docker inboard-base inboard-starlette inboard-fastapi - name: Smoke test Docker containers run: | handle_error_code() { diff --git a/Dockerfile b/Dockerfile index 68f4f35..070c97f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,12 +6,12 @@ LABEL org.opencontainers.image.licenses="MIT" LABEL org.opencontainers.image.source="https://github.com/br3ndonland/inboard" LABEL org.opencontainers.image.title="inboard" LABEL org.opencontainers.image.url="https://github.com/br3ndonland/inboard/pkgs/container/inboard" -ARG LINUX_VERSION -ENV APP_MODULE=inboard.app.main_base:app LINUX_VERSION=$LINUX_VERSION PATH=/opt/poetry/bin:$PATH POETRY_HOME=/opt/poetry POETRY_VIRTUALENVS_CREATE=false PYTHONPATH=/app +ARG LINUX_VERSION POETRY_VERSION=1.1.7 +ENV APP_MODULE=inboard.app.main_base:app LINUX_VERSION=$LINUX_VERSION PATH=/opt/poetry/bin:$PATH POETRY_HOME=/opt/poetry POETRY_VERSION=$POETRY_VERSION POETRY_VIRTUALENVS_CREATE=false PYTHONPATH=/app COPY poetry.lock pyproject.toml /app/ WORKDIR /app/ RUN sh -c 'if [ "$LINUX_VERSION" = "slim" ]; then apt-get update -qy && apt-get install -qy --no-install-recommends gcc libc-dev make wget; fi' && \ - wget -qO get-poetry.py https://raw.githubusercontent.com/python-poetry/poetry/HEAD/get-poetry.py && \ + wget -qO get-poetry.py "https://raw.githubusercontent.com/python-poetry/poetry/$POETRY_VERSION/get-poetry.py" && \ sh -c '. /etc/os-release; if [ "$ID" = "alpine" ]; then apk add --no-cache --virtual .build-deps gcc libc-dev make; fi' && \ python get-poetry.py -y && poetry install --no-dev --no-interaction --no-root && \ sh -c 'if [ "$LINUX_VERSION" = "slim" ]; then apt-get purge --auto-remove -qy gcc libc-dev make wget; fi' && \