Refactor docker CI for speed increases (#6562)

* push to ghcr (#168)

* Update docker.yaml

* Update docker.yaml

* Update docker.yaml

* use matrix to build for the plattforms (faster amd pub)

* try Buildjet

* switch to pyhton 3.9

* Update docker.yaml

* path python manually?

* bump python to 3.11

* Update Dockerfile

* step down vm

* cleanup workflow

* install docker on mac

* and docker compose too

* switch back to linux

* Docker tests (#175)

* push to ghcr (#168)

* Update docker.yaml

* Update docker.yaml

* Update docker.yaml

* use matrix to build for the plattforms (faster amd pub)

* try Buildjet

* switch to pyhton 3.9

* Update docker.yaml

* path python manually?

* bump python to 3.11

* Update Dockerfile

* step down vm

* cleanup workflow

* install docker on mac

* and docker compose too

* switch back to linux

* switch to uv

* fix uv install

* reintroduce checks

* cleanup diff
This commit is contained in:
Matthias Mair 2024-02-26 23:50:44 +01:00 committed by GitHub
parent 75c24fb8f4
commit ea63a03fe4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 11 deletions

View File

@ -25,7 +25,6 @@ on:
- 'master' - 'master'
jobs: jobs:
paths-filter: paths-filter:
name: Filter name: Filter
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -48,10 +47,8 @@ jobs:
- requirements.txt - requirements.txt
- tasks.py - tasks.py
# Build the docker image # Build the docker image
build: build:
runs-on: ubuntu-latest
needs: paths-filter needs: paths-filter
if: needs.paths-filter.outputs.docker == 'true' || github.event_name == 'release' || github.event_name == 'push' if: needs.paths-filter.outputs.docker == 'true' || github.event_name == 'release' || github.event_name == 'push'
permissions: permissions:
@ -60,7 +57,17 @@ jobs:
id-token: write id-token: write
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
python_version: 3.9 python_version: "3.11"
strategy:
matrix:
platform: ["linux/amd64", "linux/arm64"]
include:
- platform: linux/amd64
os: ubuntu-latest
- platform: linux/arm64
os: ubuntu-latest # in the future we can try to use alternative runners here
runs-on: ${{ matrix.os }}
steps: steps:
- name: Check out repo - name: Check out repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # pin@v4.1.1 uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # pin@v4.1.1
@ -77,8 +84,7 @@ jobs:
echo "git_commit_date=$(git show -s --format=%ci)" >> $GITHUB_ENV echo "git_commit_date=$(git show -s --format=%ci)" >> $GITHUB_ENV
- name: Build Docker Image - name: Build Docker Image
# Build the development docker image (using docker-compose.yml) # Build the development docker image (using docker-compose.yml)
run: | run: docker-compose build --no-cache
docker-compose build --no-cache
- name: Update Docker Image - name: Update Docker Image
run: | run: |
docker-compose run inventree-dev-server invoke update docker-compose run inventree-dev-server invoke update
@ -145,12 +151,12 @@ jobs:
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # pin@v5.0.0 uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # pin@v5.0.0
with: with:
context: . context: .
platforms: linux/amd64,linux/arm64 platforms: ${{ matrix.platform }}
push: true push: true
sbom: true sbom: true
provenance: false provenance: false
target: production target: production
tags: ${{ env.docker_tags }} tags: ${{ steps.meta.outputs.tags }}
build-args: | build-args: |
commit_hash=${{ env.git_commit_hash }} commit_hash=${{ env.git_commit_hash }}
commit_date=${{ env.git_commit_date }} commit_date=${{ env.git_commit_date }}

View File

@ -9,7 +9,7 @@
# - Runs InvenTree web server under django development server # - Runs InvenTree web server under django development server
# - Monitors source files for any changes, and live-reloads server # - Monitors source files for any changes, and live-reloads server
ARG base_image=python:3.10-alpine3.18 ARG base_image=python:3.11-alpine3.18
FROM ${base_image} as inventree_base FROM ${base_image} as inventree_base
# Build arguments for this image # Build arguments for this image
@ -46,6 +46,8 @@ ENV INVENTREE_BACKGROUND_WORKERS="4"
ENV INVENTREE_WEB_ADDR=0.0.0.0 ENV INVENTREE_WEB_ADDR=0.0.0.0
ENV INVENTREE_WEB_PORT=8000 ENV INVENTREE_WEB_PORT=8000
ENV VIRTUAL_ENV=/usr/local
LABEL org.label-schema.schema-version="1.0" \ LABEL org.label-schema.schema-version="1.0" \
org.label-schema.build-date=${DATE} \ org.label-schema.build-date=${DATE} \
org.label-schema.vendor="inventree" \ org.label-schema.vendor="inventree" \
@ -90,7 +92,7 @@ FROM inventree_base as prebuild
ENV PATH=/root/.local/bin:$PATH ENV PATH=/root/.local/bin:$PATH
RUN ./install_build_packages.sh --no-cache --virtual .build-deps && \ RUN ./install_build_packages.sh --no-cache --virtual .build-deps && \
pip install --user -r base_requirements.txt -r requirements.txt --no-cache-dir && \ pip install --user uv --no-cache-dir && uv pip install -r base_requirements.txt -r requirements.txt --no-cache && \
apk --purge del .build-deps apk --purge del .build-deps
# Frontend builder image: # Frontend builder image:
@ -135,7 +137,7 @@ EXPOSE 5173
# Install packages required for building python packages # Install packages required for building python packages
RUN ./install_build_packages.sh RUN ./install_build_packages.sh
RUN pip install -r base_requirements.txt --no-cache-dir RUN pip install uv --no-cache-dir && uv pip install -r base_requirements.txt --no-cache
# Install nodejs / npm / yarn # Install nodejs / npm / yarn