Skip to content

Commit df8524d

Browse files
committed
chore(docker): restructure conditional RUN blocks as heredocs
- Addresses review feedback on #186 - Redo profile-fetch and cache-warm RUN commands as BuildKit heredocs - Added set -e to keep old && failure semantics - proposed heredoc blocks would only report exit status of its last command
1 parent 19d5b4a commit df8524d

1 file changed

Lines changed: 22 additions & 15 deletions

File tree

Dockerfile

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# syntax=docker/dockerfile:1
12
FROM python:3.11-slim
23

34
# git is needed by some dependencies; wget is only used when baking a profile.
@@ -22,24 +23,30 @@ ARG FIVE_SAFES_PROFILE_VERSION=""
2223
ARG EXTRA_PROFILES_PATH=""
2324
ENV EXTRA_PROFILES_PATH=${EXTRA_PROFILES_PATH}
2425
ENV CACHE_PATH=/app/.rocrate-cache
25-
RUN if [ -n "$PROFILES_ARCHIVE_URL" ]; then \
26-
mkdir -p /app/extra-profiles && \
27-
wget -O /tmp/profiles.tar.gz "$PROFILES_ARCHIVE_URL" && \
28-
tar -xzf /tmp/profiles.tar.gz \
29-
-C /app/extra-profiles \
30-
--strip-components=3 \
31-
"rocrate-validator-${FIVE_SAFES_PROFILE_VERSION}/rocrate_validator/profiles/five-safes-crate" && \
32-
rm /tmp/profiles.tar.gz ; \
33-
fi
26+
RUN <<EOF_PROFILES
27+
set -e
28+
if [ -n "$PROFILES_ARCHIVE_URL" ]; then
29+
mkdir -p /app/extra-profiles
30+
wget -O /tmp/profiles.tar.gz "$PROFILES_ARCHIVE_URL"
31+
tar -xzf /tmp/profiles.tar.gz \
32+
-C /app/extra-profiles \
33+
--strip-components=3 \
34+
"rocrate-validator-${FIVE_SAFES_PROFILE_VERSION}/rocrate_validator/profiles/five-safes-crate"
35+
rm /tmp/profiles.tar.gz
36+
fi
37+
EOF_PROFILES
3438

3539
# Pre-populate the HTTP cache so opt-in offline validation
3640
# (VALIDATION_OFFLINE=true) works without network at runtime.
37-
RUN if [ -n "$EXTRA_PROFILES_PATH" ]; then \
38-
rocrate-validator cache warm --all-profiles \
39-
--extra-profiles-path "$EXTRA_PROFILES_PATH" --cache-path "$CACHE_PATH" ; \
40-
else \
41-
rocrate-validator cache warm --all-profiles --cache-path "$CACHE_PATH" ; \
42-
fi
41+
RUN <<EOF_CACHE_WARM
42+
set -e
43+
if [ -n "$EXTRA_PROFILES_PATH" ]; then
44+
rocrate-validator cache warm --all-profiles \
45+
--extra-profiles-path "$EXTRA_PROFILES_PATH" --cache-path "$CACHE_PATH"
46+
else
47+
rocrate-validator cache warm --all-profiles --cache-path "$CACHE_PATH"
48+
fi
49+
EOF_CACHE_WARM
4350

4451
RUN useradd -ms /bin/bash flaskuser
4552
RUN chown -R flaskuser:flaskuser /app

0 commit comments

Comments
 (0)