-
Notifications
You must be signed in to change notification settings - Fork 0
Added dockerfile and workflow to build Docker image with baked-in profiles #136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| name: Create and publish a Docker image (with profiles) | ||
|
|
||
| on: | ||
| release: | ||
| types: [published] | ||
| workflow_dispatch: | ||
|
|
||
| env: | ||
| REGISTRY: ghcr.io | ||
| IMAGE_NAME: ${{ github.repository }}-profiles | ||
|
|
||
| jobs: | ||
| build-and-push-image: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
| attestations: write | ||
| id-token: write | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Log in to the Container registry | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: ${{ env.REGISTRY }} | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Extract metadata (tags, labels) for Docker | ||
| id: meta | ||
| uses: docker/metadata-action@v5 | ||
| with: | ||
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
|
|
||
| - name: Build and push Docker image | ||
| id: push | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| context: . | ||
| file: ./Dockerfile.profiles | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file could be named more clearerly - e.g. |
||
| push: true | ||
| tags: ${{ steps.meta.outputs.tags }} | ||
| labels: ${{ steps.meta.outputs.labels }} | ||
|
|
||
| - 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 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| FROM python:3.11-slim | ||
|
|
||
| # Install required system packages, including git | ||
| RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| COPY requirements.txt . | ||
| RUN pip install --upgrade pip | ||
| RUN pip install --no-cache-dir -r requirements.txt | ||
|
|
||
| COPY cratey.py LICENSE /app/ | ||
| COPY app /app/app | ||
| COPY tests/data/rocrate_validator_profiles /app/profiles | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't copy over all the rocrate validator profiles into the test directory. Also we shouldn't rely on these being up-to-date. What we need here is to pull a couple of our local rocrate-validator code (use a tagged release, download the zip file, e.g.: https://github.com/eScienceLab/rocrate-validator/releases/tag/five-safes-0.7.3-beta), copy across the five-safes profiles directory (only - don't copy any other profiles), then delete the remaining zip file and code. |
||
|
|
||
| RUN useradd -ms /bin/bash flaskuser | ||
| RUN chown -R flaskuser:flaskuser /app | ||
|
|
||
| ENV PROFILES_PATH=/app/profiles | ||
|
|
||
| USER flaskuser | ||
|
|
||
| EXPOSE 5000 | ||
|
|
||
| CMD ["flask", "run", "--host=0.0.0.0"] | ||
|
|
||
| LABEL org.opencontainers.image.source="https://github.com/eScienceLab/Cratey-Validator" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have a more precise image name here? E.g.,
fivesafes-profileThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh sorry, I forgot to enter an actual name...!