diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml new file mode 100644 index 0000000..918ffe2 --- /dev/null +++ b/.github/workflows/build-image.yml @@ -0,0 +1,63 @@ +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'] + +# 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 + + 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/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 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