Skip to content

Commit 0b340ce

Browse files
committed
chore(docker): consolidate Dockerfiles and tidy up compose
1 parent 3289a9a commit 0b340ce

5 files changed

Lines changed: 33 additions & 45 deletions

File tree

.github/workflows/build-with-profiles.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,11 @@ jobs:
3939
uses: docker/build-push-action@v6
4040
with:
4141
context: .
42-
file: ./Dockerfile.fivesafes-profile
4342
push: true
43+
# Bake the five-safes profile into the shared Dockerfile via build args.
44+
build-args: |
45+
FIVE_SAFES_PROFILE_VERSION=five-safes-0.7.4-beta
46+
PROFILES_ARCHIVE_URL=https://github.com/eScienceLab/rocrate-validator/archive/refs/tags/five-safes-0.7.4-beta.tar.gz
4447
tags: ${{ steps.meta.outputs.tags }}
4548
labels: ${{ steps.meta.outputs.labels }}
4649

Dockerfile

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM python:3.11-slim
22

3-
# Install required system packages, including git
4-
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
3+
# git is needed by some dependencies; wget is only used when baking a profile.
4+
RUN apt-get update && apt-get install -y git wget && rm -rf /var/lib/apt/lists/*
55

66
WORKDIR /app
77

@@ -12,6 +12,22 @@ RUN pip install --no-cache-dir -r requirements.txt
1212
COPY cratey.py LICENSE /app/
1313
COPY app /app/app
1414

15+
# Optionally bake an extra RO-Crate profile into the validator's bundled
16+
# profiles directory. A plain build leaves PROFILES_ARCHIVE_URL empty and skips
17+
# this entirely; the "with profiles" image build passes these as --build-arg.
18+
# Baked profiles are then found automatically (no PROFILES_PATH needed).
19+
ARG PROFILES_ARCHIVE_URL=""
20+
ARG FIVE_SAFES_PROFILE_VERSION=""
21+
ARG PY_VER=3.11
22+
RUN if [ -n "$PROFILES_ARCHIVE_URL" ]; then \
23+
wget -O /tmp/profiles.tar.gz "$PROFILES_ARCHIVE_URL" && \
24+
tar -xzf /tmp/profiles.tar.gz \
25+
-C "/usr/local/lib/python${PY_VER}/site-packages/rocrate_validator/profiles/" \
26+
--strip-components=3 \
27+
"rocrate-validator-${FIVE_SAFES_PROFILE_VERSION}/rocrate_validator/profiles/five-safes-crate" && \
28+
rm /tmp/profiles.tar.gz ; \
29+
fi
30+
1531
RUN useradd -ms /bin/bash flaskuser
1632
RUN chown -R flaskuser:flaskuser /app
1733

@@ -21,4 +37,5 @@ EXPOSE 5000
2137

2238
CMD ["flask", "run", "--host=0.0.0.0"]
2339

24-
LABEL org.opencontainers.image.source="https://github.com/eScienceLab/Cratey-Validator"
40+
LABEL org.opencontainers.image.source="https://github.com/eScienceLab/Cratey-Validator"
41+
LABEL org.cratey.five-safes-profile-version="${FIVE_SAFES_PROFILE_VERSION}"

Dockerfile.fivesafes-profile

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

docker-compose-develop.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
version: '3.8'
1+
# Development stack: builds the app image locally from ./Dockerfile and mounts
2+
# the custom RO-Crate profiles into both the flask and worker containers. Use
3+
# this when working on the service itself; use docker-compose.yml to run the
4+
# published image.
25

36
services:
47
flask:

docker-compose.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
version: '3.8'
1+
# Default stack, using the published image (ghcr.io/.../cratey-validator).
2+
# For running the service. Object storage is opt-in: set STORAGE_ENABLED=true
3+
# and start the "objectstore" profile (docker compose --profile objectstore up).
4+
# For local development against a freshly built image, use
5+
# docker-compose-develop.yml instead.
26

37
services:
48
flask:

0 commit comments

Comments
 (0)