Skip to content

Commit 7177c78

Browse files
authored
Merge pull request #60 from Dstack-TEE/ingress-repro
ingress: Fix reproducible issue on github codespaces
2 parents 44a7726 + 662bd4a commit 7177c78

File tree

2 files changed

+37
-7
lines changed

2 files changed

+37
-7
lines changed

custom-domain/dstack-ingress/Dockerfile

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
FROM nginx@sha256:b6653fca400812e81569f9be762ae315db685bc30b12ddcdc8616c63a227d3ca
22

3-
COPY pinned-packages.txt /tmp/
4-
5-
RUN set -e; \
3+
RUN --mount=type=bind,source=pinned-packages.txt,target=/tmp/pinned-packages.txt,ro \
4+
set -e; \
65
# Create a sources.list file pointing to a specific snapshot
76
echo 'deb [check-valid-until=no] https://snapshot.debian.org/archive/debian/20250411T024939Z bookworm main' > /etc/apt/sources.list && \
87
echo 'deb [check-valid-until=no] https://snapshot.debian.org/archive/debian-security/20250411T024939Z bookworm-security main' >> /etc/apt/sources.list && \
@@ -28,7 +27,7 @@ RUN set -e; \
2827
curl \
2928
jq \
3029
coreutils && \
31-
rm -rf /var/lib/apt/lists/* /var/log/* /var/cache/ldconfig/aux-cache /tmp/pinned-packages.txt
30+
rm -rf /var/lib/apt/lists/* /var/log/* /var/cache/ldconfig/aux-cache
3231

3332
RUN mkdir -p \
3433
/etc/letsencrypt \
@@ -37,11 +36,29 @@ RUN mkdir -p \
3736
/etc/nginx/conf.d \
3837
/var/log/nginx
3938

40-
COPY ./scripts /scripts/
41-
RUN chmod +x /scripts/*.sh /scripts/*.py
39+
# Install scripts with deterministic permissions via bind mount
40+
RUN --mount=type=bind,source=scripts,target=/tmp/scripts,ro \
41+
/bin/bash -o pipefail -c 'set -euo pipefail; \
42+
rm -rf /scripts && mkdir -p /scripts && chmod 755 /scripts && \
43+
cd /tmp/scripts && \
44+
find . -type d -print0 | while IFS= read -r -d "" dir; do \
45+
rel="${dir#./}"; \
46+
[[ -z "$rel" ]] && continue; \
47+
install -d -m 755 "/scripts/$rel"; \
48+
done && \
49+
find . -type f -print0 | while IFS= read -r -d "" file; do \
50+
rel="${file#./}"; \
51+
perm=644; \
52+
case "$rel" in \
53+
*.sh) perm=755 ;; \
54+
*.py) case "$rel" in */*) perm=644 ;; *) perm=755 ;; esac ;; \
55+
esac; \
56+
install -m "$perm" "$file" "/scripts/$rel"; \
57+
done'
58+
4259
ENV PATH="/scripts:$PATH"
4360
ENV PYTHONPATH="/scripts"
44-
COPY .GIT_REV /etc/
61+
COPY --chmod=666 .GIT_REV /etc/
4562

4663
ENTRYPOINT ["/scripts/entrypoint.sh"]
4764
CMD ["nginx", "-g", "daemon off;"]

custom-domain/dstack-ingress/build-image.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,19 @@ while [[ $# -gt 0 ]]; do
2222
;;
2323
esac
2424
done
25+
26+
require_command() {
27+
local cmd="$1"
28+
if ! command -v "$cmd" >/dev/null 2>&1; then
29+
echo "Error: required command '$cmd' not found in PATH" >&2
30+
exit 1
31+
fi
32+
}
33+
34+
for required in docker skopeo jq git; do
35+
require_command "$required"
36+
done
37+
2538
# Check if buildkit_20 already exists before creating it
2639
if ! docker buildx inspect buildkit_20 &>/dev/null; then
2740
docker buildx create --use --driver-opt image=moby/buildkit:v0.20.2 --name buildkit_20

0 commit comments

Comments
 (0)