Skip to content

Commit 43a10fc

Browse files
committed
Added dockerfile and workflow to build Docker image with baked-in profiles when releasing new version of Cratey-Validator
1 parent 998fa39 commit 43a10fc

2 files changed

Lines changed: 79 additions & 0 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Create and publish a Docker image (with profiles)
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
8+
env:
9+
REGISTRY: ghcr.io
10+
IMAGE_NAME: ${{ github.repository }}-profiles
11+
12+
jobs:
13+
build-and-push-image:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
packages: write
18+
attestations: write
19+
id-token: write
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
24+
- name: Log in to the Container registry
25+
uses: docker/login-action@v3
26+
with:
27+
registry: ${{ env.REGISTRY }}
28+
username: ${{ github.actor }}
29+
password: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Extract metadata (tags, labels) for Docker
32+
id: meta
33+
uses: docker/metadata-action@v5
34+
with:
35+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
36+
37+
- name: Build and push Docker image
38+
id: push
39+
uses: docker/build-push-action@v6
40+
with:
41+
context: .
42+
file: ./Dockerfile.profiles
43+
push: true
44+
tags: ${{ steps.meta.outputs.tags }}
45+
labels: ${{ steps.meta.outputs.labels }}
46+
47+
- name: Generate artifact attestation
48+
uses: actions/attest-build-provenance@v2
49+
with:
50+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
51+
subject-digest: ${{ steps.push.outputs.digest }}
52+
push-to-registry: true

Dockerfile.profiles

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
FROM python:3.11-slim
2+
3+
# Install required system packages, including git
4+
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
5+
6+
WORKDIR /app
7+
8+
COPY requirements.txt .
9+
RUN pip install --upgrade pip
10+
RUN pip install --no-cache-dir -r requirements.txt
11+
12+
COPY cratey.py LICENSE /app/
13+
COPY app /app/app
14+
COPY tests/data/rocrate_validator_profiles /app/profiles
15+
16+
RUN useradd -ms /bin/bash flaskuser
17+
RUN chown -R flaskuser:flaskuser /app
18+
19+
ENV PROFILES_PATH=/app/profiles
20+
21+
USER flaskuser
22+
23+
EXPOSE 5000
24+
25+
CMD ["flask", "run", "--host=0.0.0.0"]
26+
27+
LABEL org.opencontainers.image.source="https://github.com/eScienceLab/Cratey-Validator"

0 commit comments

Comments
 (0)