From 51d131600e616e42921e63a8e0df37a99d160af2 Mon Sep 17 00:00:00 2001 From: phil Date: Sun, 3 Nov 2024 02:17:02 +0100 Subject: [PATCH 1/2] Build containers from custom registry --- Containerfile | 2 +- Containerfile.deps | 2 +- Containerfile.full_copy | 29 +++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 Containerfile.full_copy diff --git a/Containerfile b/Containerfile index b2cb40f..3273154 100644 --- a/Containerfile +++ b/Containerfile @@ -1,6 +1,6 @@ # Build: podman build -t treetrail-backend-base -f Containerfile.base -FROM localhost/treetrail-backend-deps +FROM tiptop:5000/treetrail-backend-deps ENV PYTHONPATH $UV_PROJECT_ENVIRONMENT/lib/python3.12/site-packages diff --git a/Containerfile.deps b/Containerfile.deps index 665020c..dd111f8 100644 --- a/Containerfile.deps +++ b/Containerfile.deps @@ -1,6 +1,6 @@ # Build: podman build -t treetrail-backend-deps -f Containerfile.deps -FROM localhost/trixie_python +FROM tiptop:5000/trixie_python COPY ./pyproject.toml ./README.md ./uv.lock /_lock/ diff --git a/Containerfile.full_copy b/Containerfile.full_copy new file mode 100644 index 0000000..357a81f --- /dev/null +++ b/Containerfile.full_copy @@ -0,0 +1,29 @@ +FROM localhost/trixie_python + +ENV PYTHONPATH $UV_PROJECT_ENVIRONMENT/lib/python3.12/site-packages +ENV PATH=/app/bin:$PATH + +RUN < Date: Sun, 3 Nov 2024 02:18:01 +0100 Subject: [PATCH 2/2] CI: split workflow in 2 jobs --- .forgejo/workflows/build.yaml | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml index 7c5f54c..56d8d01 100644 --- a/.forgejo/workflows/build.yaml +++ b/.forgejo/workflows/build.yaml @@ -14,7 +14,7 @@ on: type: boolean jobs: - build: + test: runs-on: container container: image: tiptop:5000/treetrail-backend-ci @@ -35,9 +35,32 @@ jobs: - name: Install app with 'uv pip install' run: uv pip install --python=$UV_PROJECT_ENVIRONMENT --no-deps . - - name: Run basic test (API call) + - name: Run tests (API call) run: pytest -s tests/basic.py + build: + runs-on: container + if: ${{ inputs.build }} + container: + image: tiptop:5000/treetrail-backend-ci + volumes: + - "uv_cache:/root/.cache/uv" + - "ca-cert:/etc/containers/certs.d" + steps: + - uses: actions/checkout@v4 + + - name: Install app with 'uv pip install' + run: uv pip install --python=$UV_PROJECT_ENVIRONMENT --no-deps . + + - name: Git unshallow - get all history from Git to get the tag for the computation of the version + if: ${{ inputs.build }} + run: git pull --unshallow + + - name: Get the version from git + if: ${{ inputs.build }} + id: version + run: echo "version=$(git describe --dirty --tags)" >> $GITHUB_OUTPUT + - name: Workaround for bug of podman-login if: ${{ inputs.build }} run: | @@ -57,10 +80,10 @@ jobs: if: ${{ inputs.build }} uses: actions/buildah-build@v1 with: - image: treetrail-backend + image: "treetrail-backend:${{ steps.version.outputs.version }}" #tags: foo # v1 ${{ github.sha }} containerfiles: | - ./Containerfile.for_runner + ./Containerfile - name: Push the image to the registry uses: actions/push-to-registry@v2 @@ -68,4 +91,4 @@ jobs: with: registry: "docker://${{ vars.REGISTRY }}" image: treetrail-backend - tags: latest + tags: ${{ steps.version.outputs.version }}