From 3756242bd757436ea618d05ec2344f491c9c0f3b Mon Sep 17 00:00:00 2001 From: salomaestro Date: Mon, 24 Feb 2025 20:24:00 +0100 Subject: [PATCH 1/4] Remove docker directory and modify and update dockerfile With this new update it will always ensure the newest packages from pyproject.toml is used inside the container --- Dockerfile | 16 +++++++++++ docker/Dockerfile | 7 ----- docker/createdocker.sh | 6 ---- docker/requirements.txt | 61 ----------------------------------------- 4 files changed, 16 insertions(+), 74 deletions(-) create mode 100644 Dockerfile delete mode 100644 docker/Dockerfile delete mode 100644 docker/createdocker.sh delete mode 100644 docker/requirements.txt diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7b46685 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM --platform=linux/amd64 ghcr.io/astral-sh/uv:debian + +# Set a temporary working directory (will be switched in the kubectl job anyways...) +WORKDIR /temp + +# Copy the pyproject file to the working directory to ensure exact versions +COPY pyproject.toml . + +# Make a empty venv +RUN uv venv + +# Install all dependencies from the pyproject file +RUN uv add pyproject.toml + +# Set the path to the venv +ENV PATH="/temp/.venv/bin:${PATH}" diff --git a/docker/Dockerfile b/docker/Dockerfile deleted file mode 100644 index dc6f5ea..0000000 --- a/docker/Dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -FROM pytorch/pytorch:2.4.1-cuda11.8-cudnn9-runtime -WORKDIR /tmp/ -COPY requirements.txt . -RUN apt-get update -RUN pip install -r requirements.txt -RUN apt-get install ffmpeg libsm6 libxext6 -y git -RUN pip install ftfy regex tqdm diff --git a/docker/createdocker.sh b/docker/createdocker.sh deleted file mode 100644 index fbe7cd4..0000000 --- a/docker/createdocker.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -sudo chmod 666 /var/run/docker.sock - -docker build docker -t seilmast/colabexam:latest -docker push seilmast/colabexam:latest \ No newline at end of file diff --git a/docker/requirements.txt b/docker/requirements.txt deleted file mode 100644 index 31fc1ca..0000000 --- a/docker/requirements.txt +++ /dev/null @@ -1,61 +0,0 @@ -annotated-types==0.7.0 -asttokens==3.0.0 -certifi==2024.12.14 -charset-normalizer==3.4.1 -click==8.1.8 -comm==0.2.2 -debugpy==1.8.12 -decorator==5.1.1 -docker-pycreds==0.4.0 -executing==2.2.0 -filelock==3.13.1 -fsspec==2024.6.1 -gitdb==4.0.12 -GitPython==3.1.44 -h5py==3.12.1 -idna==3.10 -iniconfig==2.0.0 -ipykernel==6.29.5 -ipython==8.31.0 -jedi==0.19.2 -Jinja2==3.1.4 -jupyter_client==8.6.3 -jupyter_core==5.7.2 -MarkupSafe==2.1.5 -matplotlib-inline==0.1.7 -mpmath==1.3.0 -nest-asyncio==1.6.0 -networkx==3.3 -numpy==2.1.2 -packaging==24.2 -parso==0.8.4 -pexpect==4.9.0 -pillow==11.0.0 -platformdirs==4.3.6 -pluggy==1.5.0 -prompt_toolkit==3.0.50 -protobuf==5.29.3 -psutil==6.1.1 -ptyprocess==0.7.0 -pure_eval==0.2.3 -pydantic==2.10.6 -pydantic_core==2.27.2 -Pygments==2.19.1 -pytest==8.3.4 -python-dateutil==2.9.0.post0 -PyYAML==6.0.2 -pyzmq==26.2.1 -requests==2.32.3 -scipy==1.15.1 -sentry-sdk==2.20.0 -setproctitle==1.3.4 -six==1.17.0 -smmap==5.0.2 -stack-data==0.6.3 -sympy==1.13.1 -tornado==6.4.2 -traitlets==5.14.3 -typing_extensions==4.12.2 -urllib3==2.3.0 -wandb==0.19.5 -wcwidth==0.2.13 From 57f8c22a3dee4449d8c204579a066d1b4d857cf2 Mon Sep 17 00:00:00 2001 From: salomaestro Date: Mon, 24 Feb 2025 20:24:12 +0100 Subject: [PATCH 2/4] Workflow for automatically building and pushin dockerfile --- .github/workflows/build-image.yml | 65 +++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .github/workflows/build-image.yml diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml new file mode 100644 index 0000000..9f988df --- /dev/null +++ b/.github/workflows/build-image.yml @@ -0,0 +1,65 @@ +name: Create and publish a Docker image + +# Configures this workflow to run every time a change is pushed to the branch called `main`. +on: + push: + branches: ['main'] + pull_request: + branches: ['main'] + +# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds. +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu. +jobs: + build-and-push-image: + runs-on: ubuntu-latest + # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job. + permissions: + contents: read + packages: write + attestations: write + id-token: write + # + steps: + - name: Checkout repository + uses: actions/checkout@v4 + # Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here. + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + # This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels. + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=sha + # This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages. + # It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see [Usage](https://github.com/docker/build-push-action#usage) in the README of the `docker/build-push-action` repository. + # It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step. + - name: Build and push Docker image + id: push + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + # This step generates an artifact attestation for the image, which is an unforgeable statement about where and how it was built. It increases supply chain security for people who consume the image. For more information, see [Using artifact attestations to establish provenance for builds](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds). + - name: Generate artifact attestation + uses: actions/attest-build-provenance@v2 + with: + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} + subject-digest: ${{ steps.push.outputs.digest }} + push-to-registry: true + + From 970255809fd297af3241bcf574dbea7a2e5e50c1 Mon Sep 17 00:00:00 2001 From: salomaestro Date: Mon, 24 Feb 2025 20:50:18 +0100 Subject: [PATCH 3/4] Only build upon push to main branch, not PR Just had to have it there to test that it would work before pushing to main :) --- .github/workflows/build-image.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index 9f988df..918ffe2 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -4,8 +4,6 @@ name: Create and publish a Docker image on: push: branches: ['main'] - pull_request: - branches: ['main'] # Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds. env: From 30a75637dd56cc851ca07d60e89c882390f788f1 Mon Sep 17 00:00:00 2001 From: salomaestro Date: Mon, 24 Feb 2025 20:54:56 +0100 Subject: [PATCH 4/4] Update badges in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 86b7dbe..cb01735 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![test-badge](https://github.com/SFI-Visual-Intelligence/Collaborative-Coding-Exam/actions/workflows/test.yml/badge.svg) ![format](https://github.com/SFI-Visual-Intelligence/Collaborative-Coding-Exam/actions/workflows/format.yml/badge.svg) ![sphinx](https://github.com/SFI-Visual-Intelligence/Collaborative-Coding-Exam/actions/workflows/sphinx.yml/badge.svg) +![test-badge](https://github.com/SFI-Visual-Intelligence/Collaborative-Coding-Exam/actions/workflows/test.yml/badge.svg) ![format](https://github.com/SFI-Visual-Intelligence/Collaborative-Coding-Exam/actions/workflows/format.yml/badge.svg) ![sphinx](https://github.com/SFI-Visual-Intelligence/Collaborative-Coding-Exam/actions/workflows/sphinx.yml/badge.svg) ![build-image](https://github.com/SFI-Visual-Intelligence/Collaborative-Coding-Exam/actions/workflows/build-image.yml/badge.svg) # Collaborative-Coding-Exam Repository for final evaluation in the FYS-8805 Reproducible Research and Collaborative coding course