Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Use Poetry across the board and cache package managers in Docker
Patryk Zawadzki1f50e3ff678a
diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfileindex 441198e903..0afa2e9850 100644--- a/.devcontainer/Dockerfile+++ b/.devcontainer/Dockerfile@@ -22,5 +22,7 @@ RUN echo 'image/webp webp' >> /etc/mime.typesRUN echo 'image/avif avif' >> /etc/mime.typesWORKDIR /app-COPY requirements_dev.txt /tmp/pip-tmp/-RUN pip --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements_dev.txt+RUN pip install poetry==1.5.0+RUN poetry config virtualenvs.create false+COPY poetry.lock pyproject.toml /app/+RUN poetry install --no-rootdiff --git a/.github/workflows/publish-containers.yml b/.github/workflows/publish-containers.ymlindex da9cba0f80..599b9c1b71 100644--- a/.github/workflows/publish-containers.yml+++ b/.github/workflows/publish-containers.yml@@ -44,20 +44,6 @@ jobs:id: buildxuses: docker/setup-buildx-action@v3- - name: Cache Docker layers- uses: actions/cache@v3- # This condition is a temporary fix until- # https://github.com/docker/buildx/issues/1044 is resolved, as it- # prevents usage of image registry.- # Due to limitation of local cache size we are skipping main branch and- # prioritize local cache for other branches e.g 3.x.- if: github.ref != 'refs/heads/main'- with:- path: /tmp/.buildx-cache- key: ${{ runner.os }}-buildx-${{ hashFiles('requirements_dev.txt') }}- restore-keys: |- ${{ runner.os }}-buildx--- name: Login to GitHub Container Registryuses: docker/login-action@v3with:@@ -70,9 +56,9 @@ jobs:uses: docker/build-push-action@v5with:builder: ${{ steps.buildx.outputs.name }}- cache-from: type=local,src=/tmp/.buildx-cache- cache-to: type=local,dest=/tmp/.buildx-cache- context: ./+ cache-from: type=gha+ cache-to: type=gha,mode=max+ context: .labels: ${{ steps.meta.outputs.labels }}platforms: linux/amd64,linux/arm64push: ${{ github.event_name != 'pull_request' }}diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.ymlindex 99284263be..8bc0d7257e 100644--- a/.github/workflows/pytest.yml+++ b/.github/workflows/pytest.yml@@ -6,7 +6,6 @@ on:paths:- "**.py"- Dockerfile- - requirements_dev.txt- "saleor/**"- ".github/workflows/pytest.yml"- pyproject.toml@@ -18,7 +17,6 @@ on:paths:- "**.py"- Dockerfile- - requirements_dev.txt- "saleor/**"- ".github/workflows/pytest.yml"- pyproject.tomldiff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex d1c56aa429..c1247aa3f4 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -34,13 +34,7 @@ These files should be updated by running `poetry export --without-hashes -f requ## Coding styleSaleor uses various tools to maintain a common coding style and help with development.-To install all the development tools, run the following commands:--```shell-python -m pip install -r requirements_dev.txt-```--or use `poetry`:+To install all the development tools, use [Poetry](https://python-poetry.org):```shellpoetry installdiff --git a/Dockerfile b/Dockerfileindex 8bdaeb14e8..ceb20f5d77 100644--- a/Dockerfile+++ b/Dockerfile@@ -8,9 +8,11 @@ RUN apt-get -y update \&& rm -rf /var/lib/apt/lists/*# Install Python dependencies-COPY requirements_dev.txt /app/WORKDIR /app-RUN pip install -r requirements_dev.txt+RUN --mount=type=cache,mode=0755,target=/root/.cache/pip pip install poetry==1.5.0+RUN poetry config virtualenvs.create false+COPY poetry.lock pyproject.toml /app/+RUN --mount=type=cache,mode=0755,target=/root/.cache/pypoetry poetry install --no-root### Final imageFROM python:3.9-slimdiff --git a/saleor/settings.py b/saleor/settings.pyindex 09602f8d9b..c67362612e 100644--- a/saleor/settings.py+++ b/saleor/settings.py@@ -291,7 +291,7 @@ if ENABLE_DEBUG_TOOLBAR:except ImportError as exc:msg = (f"{exc} -- Install the missing dependencies by "- f"running `pip install -r requirements_dev.txt`"+ f"running `poetry install --no-root`")warnings.warn(msg)else: