We are using docker containers for dev (dev container) & pipeline (gitlab CI).
Both cases use a base image of python:3.12-slim
. The dev container is defined as:
FROM python:3.12-slim
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
RUN apt-get update &&
apt-get upgrade -y &&
...
WORKDIR /app
# not recommended in docs to install poetry globally but as this is a VM this is fine
RUN pip install poetry &&
# no need for venv in dev container
poetry config virtualenvs.create false &&
poetry install
COPY . /app
Running python --version
from inside the dev container returns Python 3.12.3
.
The pipeline setup is set up as:
lint:
image: python:3.12-slim
stage: test
tags:
- docker
before_script:
- apt-get update
- apt-get upgrade -y
- pip3 install poetry
- poetry config virtualenvs.create false
- poetry install --without dev
script:
- pylint --version
- pylint app --verbose
- pylint tests --verbose
- black --version
- black . --check --verbose
- isort --version
- isort . --check --verbose
allow_failure: true
rules:
- if: $CI_COMMIT_BRANCH == "main"
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_PIPELINE_SOURCE == "web"
The pipeline however will fail on poetry install
due to:
The currently activated Python version 3.12.0 is not supported by the project (3.12.3).
Looking into the Dockerfile for this image it appears 3.12.3 is correct. How could it be that the pipeline is grabbing an older python version?
Thanks