Skip to content

Commit 5a50a07

Browse files
authored
Merge pull request #107 from SFI-Visual-Intelligence/docker-prune
Docker updates!
2 parents 3911669 + 30a7563 commit 5a50a07

File tree

6 files changed

+80
-75
lines changed

6 files changed

+80
-75
lines changed

.github/workflows/build-image.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Create and publish a Docker image
2+
3+
# Configures this workflow to run every time a change is pushed to the branch called `main`.
4+
on:
5+
push:
6+
branches: ['main']
7+
8+
# 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.
9+
env:
10+
REGISTRY: ghcr.io
11+
IMAGE_NAME: ${{ github.repository }}
12+
13+
# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
14+
jobs:
15+
build-and-push-image:
16+
runs-on: ubuntu-latest
17+
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
18+
permissions:
19+
contents: read
20+
packages: write
21+
attestations: write
22+
id-token: write
23+
#
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
# 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.
28+
- name: Log in to the Container registry
29+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
30+
with:
31+
registry: ${{ env.REGISTRY }}
32+
username: ${{ github.actor }}
33+
password: ${{ secrets.GITHUB_TOKEN }}
34+
# 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.
35+
- name: Extract metadata (tags, labels) for Docker
36+
id: meta
37+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
38+
with:
39+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
40+
tags: |
41+
type=ref,event=branch
42+
type=sha
43+
# 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.
44+
# 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.
45+
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
46+
- name: Build and push Docker image
47+
id: push
48+
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
49+
with:
50+
context: .
51+
push: true
52+
tags: ${{ steps.meta.outputs.tags }}
53+
labels: ${{ steps.meta.outputs.labels }}
54+
55+
# 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).
56+
- name: Generate artifact attestation
57+
uses: actions/attest-build-provenance@v2
58+
with:
59+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
60+
subject-digest: ${{ steps.push.outputs.digest }}
61+
push-to-registry: true
62+
63+

Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM --platform=linux/amd64 ghcr.io/astral-sh/uv:debian
2+
3+
# Set a temporary working directory (will be switched in the kubectl job anyways...)
4+
WORKDIR /temp
5+
6+
# Copy the pyproject file to the working directory to ensure exact versions
7+
COPY pyproject.toml .
8+
9+
# Make a empty venv
10+
RUN uv venv
11+
12+
# Install all dependencies from the pyproject file
13+
RUN uv add pyproject.toml
14+
15+
# Set the path to the venv
16+
ENV PATH="/temp/.venv/bin:${PATH}"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
![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)
1+
![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)
22

33
# Collaborative-Coding-Exam
44
Repository for final evaluation in the FYS-8805 Reproducible Research and Collaborative coding course

docker/Dockerfile

Lines changed: 0 additions & 7 deletions
This file was deleted.

docker/createdocker.sh

Lines changed: 0 additions & 6 deletions
This file was deleted.

docker/requirements.txt

Lines changed: 0 additions & 61 deletions
This file was deleted.

0 commit comments

Comments
 (0)