Skip to content

Commit 3cf172e

Browse files
committed
Fix deterministic issue
1 parent 2fafcfb commit 3cf172e

File tree

7 files changed

+218
-131
lines changed

7 files changed

+218
-131
lines changed

custom-domain/dstack-ingress/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
/CLAUDE.md
33
/test/
44
__pycache__
5+
/oci.tar

custom-domain/dstack-ingress/Dockerfile

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ RUN set -e; \
88
echo 'deb [check-valid-until=no] https://snapshot.debian.org/archive/debian-security/20250411T024939Z bookworm-security main' >> /etc/apt/sources.list && \
99
echo 'Acquire::Check-Valid-Until "false";' > /etc/apt/apt.conf.d/10no-check-valid-until && \
1010
# Create preferences file to pin all packages
11+
rm -rf /etc/apt/sources.list.d/debian.sources && \
1112
mkdir -p /etc/apt/preferences.d && \
1213
cat /tmp/pinned-packages.txt | while read line; do \
1314
pkg=$(echo $line | cut -d= -f1); \
@@ -36,17 +37,6 @@ RUN mkdir -p \
3637
/etc/nginx/conf.d \
3738
/var/log/nginx
3839

39-
# Set up Python virtual environment and install certbot
40-
RUN set -e; \
41-
python3 -m venv --system-site-packages /opt/app-venv && \
42-
. /opt/app-venv/bin/activate && \
43-
pip install --upgrade pip && \
44-
pip install certbot requests && \
45-
# Create symlinks for system-wide access
46-
ln -sf /opt/app-venv/bin/certbot /usr/local/bin/certbot && \
47-
# Ensure the virtual environment is always activated for scripts
48-
echo 'source /opt/app-venv/bin/activate' > /etc/profile.d/app-venv.sh
49-
5040
COPY ./scripts /scripts/
5141
RUN chmod +x /scripts/*.sh /scripts/*.py
5242
ENV PATH="/scripts:$PATH"
@@ -55,4 +45,3 @@ COPY .GIT_REV /etc/
5545

5646
ENTRYPOINT ["/scripts/entrypoint.sh"]
5747
CMD ["nginx", "-g", "daemon off;"]
58-
Lines changed: 63 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,71 @@
11
#!/bin/bash
2-
NAME=$1
3-
if [ -z "$NAME" ]; then
4-
echo "Usage: $0 <name>[:<tag>]"
5-
exit 1
6-
fi
2+
3+
# Parse command line arguments
4+
PUSH=false
5+
REPO=""
6+
7+
while [[ $# -gt 0 ]]; do
8+
case $1 in
9+
--push)
10+
PUSH=true
11+
REPO="$2"
12+
if [ -z "$REPO" ]; then
13+
echo "Error: --push requires a repository argument"
14+
echo "Usage: $0 [--push <repo>[:<tag>]]"
15+
exit 1
16+
fi
17+
shift 2
18+
;;
19+
*)
20+
echo "Usage: $0 [--push <repo>[:<tag>]]"
21+
exit 1
22+
;;
23+
esac
24+
done
725
# Check if buildkit_20 already exists before creating it
826
if ! docker buildx inspect buildkit_20 &>/dev/null; then
927
docker buildx create --use --driver-opt image=moby/buildkit:v0.20.2 --name buildkit_20
1028
fi
1129
touch pinned-packages.txt
1230
git rev-parse HEAD > .GIT_REV
13-
docker buildx build --builder buildkit_20 --no-cache --build-arg SOURCE_DATE_EPOCH="0" --output type=docker,name="$NAME",rewrite-timestamp=true .
14-
docker run --rm --entrypoint bash "$NAME" -c "dpkg -l | grep '^ii' |awk '{print \$2\"=\"\$3}' | sort" > pinned-packages.txt
31+
TEMP_TAG="dstack-ingress-temp:$(date +%s)"
32+
docker buildx build --builder buildkit_20 --no-cache --build-arg SOURCE_DATE_EPOCH="0" \
33+
--output type=oci,dest=./oci.tar,rewrite-timestamp=true \
34+
--output type=docker,name="$TEMP_TAG" .
35+
36+
if [ "$?" -ne 0 ]; then
37+
echo "Build failed"
38+
rm .GIT_REV
39+
exit 1
40+
fi
41+
42+
echo "Build completed, manifest digest:"
43+
echo ""
44+
skopeo inspect oci-archive:./oci.tar | jq .Digest
45+
echo ""
46+
47+
if [ "$PUSH" = true ]; then
48+
echo "Pushing image to $REPO..."
49+
skopeo copy --insecure-policy oci-archive:./oci.tar docker://"$REPO"
50+
echo "Image pushed successfully to $REPO"
51+
else
52+
echo "To push the image to a registry, run:"
53+
echo ""
54+
echo " $0 --push <repo>[:<tag>]"
55+
echo ""
56+
echo "Or use skopeo directly:"
57+
echo ""
58+
echo " skopeo copy --insecure-policy oci-archive:./oci.tar docker://<repo>[:<tag>]"
59+
fi
60+
echo ""
61+
62+
# Extract package information from the built image
63+
echo "Extracting package information from built image: $TEMP_TAG"
64+
docker run --rm --entrypoint bash "$TEMP_TAG" -c "dpkg -l | grep '^ii' | awk '{print \$2\"=\"\$3}' | sort" > pinned-packages.txt
65+
66+
echo "Package information extracted to pinned-packages.txt ($(wc -l < pinned-packages.txt) packages)"
67+
68+
# Clean up the temporary image from Docker daemon
69+
docker rmi "$TEMP_TAG" 2>/dev/null || true
70+
1571
rm .GIT_REV

custom-domain/dstack-ingress/pinned-packages.txt

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ adduser=3.134
22
apt=2.6.1
33
base-files=12.4+deb12u10
44
base-passwd=3.6.1
5-
bash=5.2.15-2+b8
5+
bash=5.2.15-2+b7
66
bsdutils=1:2.38.1-5+deb12u3
77
ca-certificates=20230311
8-
certbot=2.1.0-4
98
coreutils=9.1-1
109
curl=7.88.1-10+deb12u12
1110
dash=0.5.12-2
@@ -97,8 +96,8 @@ libpcre2-8-0:amd64=10.42-1
9796
libpng16-16:amd64=1.6.39-2
9897
libpsl5:amd64=0.21.2-1
9998
libpython3-stdlib:amd64=3.11.2-1+b1
100-
libpython3.11-minimal:amd64=3.11.2-6+deb12u6
101-
libpython3.11-stdlib:amd64=3.11.2-6+deb12u6
99+
libpython3.11-minimal:amd64=3.11.2-6+deb12u5
100+
libpython3.11-stdlib:amd64=3.11.2-6+deb12u5
102101
librav1e0:amd64=0.5.1-6
103102
libreadline8:amd64=8.2-1.3
104103
librtmp1:amd64=2.4+20151223.gitfa8646d.1-2+b2
@@ -113,7 +112,7 @@ libsmartcols1:amd64=2.38.1-5+deb12u3
113112
libsqlite3-0:amd64=3.40.1-2+deb12u1
114113
libss2:amd64=1.47.0-2
115114
libssh2-1:amd64=1.10.0-3+b1
116-
libssl3:amd64=3.0.16-1~deb12u1
115+
libssl3:amd64=3.0.15-1~deb12u1
117116
libstdc++6:amd64=12.2.0-14
118117
libsvtav1enc1:amd64=1.4.1+dfsg-1
119118
libsystemd0:amd64=252.36-1~deb12u1
@@ -140,7 +139,6 @@ libyuv0:amd64=0.0~git20230123.b2528b0-1
140139
libzstd1:amd64=1.5.4+dfsg2-5
141140
login=1:4.13+dfsg1-1+b1
142141
logsave=1.47.0-2
143-
lsb-release=12.0-1
144142
mawk=1.3.4.20200120-3.1
145143
media-types=10.0.0
146144
mount=2.38.1-5+deb12u3
@@ -151,40 +149,28 @@ nginx-module-image-filter=1.27.4-1~bookworm
151149
nginx-module-njs=1.27.4+0.8.9-1~bookworm
152150
nginx-module-xslt=1.27.4-1~bookworm
153151
nginx=1.27.4-1~bookworm
154-
openssl=3.0.16-1~deb12u1
152+
openssl=3.0.15-1~deb12u1
155153
passwd=1:4.13+dfsg1-1+b1
156154
perl-base=5.36.0-7+deb12u1
157-
python3-acme=2.1.0-1
158-
python3-certbot=2.1.0-4
159155
python3-certifi=2022.9.24-1
160-
python3-cffi-backend:amd64=1.15.1-5+b1
161156
python3-chardet=5.1.0+dfsg-2
162157
python3-charset-normalizer=3.0.1-2
163-
python3-configargparse=1.5.3-1
164-
python3-configobj=5.0.8-1
165-
python3-cryptography=38.0.4-3+deb12u1
166-
python3-distro=1.8.0-1
167158
python3-distutils=3.11.2-3
168159
python3-idna=3.3-1+deb12u1
169-
python3-josepy=1.13.0-1
170160
python3-lib2to3=3.11.2-3
171161
python3-minimal=3.11.2-1+b1
172-
python3-openssl=23.0.0-1
173-
python3-parsedatetime=2.6-3
174162
python3-pip-whl=23.0.1+dfsg-1
175163
python3-pip=23.0.1+dfsg-1
176164
python3-pkg-resources=66.1.1-1+deb12u1
177165
python3-requests=2.28.1+dfsg-1
178-
python3-rfc3339=1.1-4
179166
python3-setuptools-whl=66.1.1-1+deb12u1
180167
python3-setuptools=66.1.1-1+deb12u1
181168
python3-six=1.16.0-4
182-
python3-tz=2022.7.1-4
183169
python3-urllib3=1.26.12-1+deb12u1
184170
python3-wheel=0.38.4-2
185-
python3.11-minimal=3.11.2-6+deb12u6
186-
python3.11-venv=3.11.2-6+deb12u6
187-
python3.11=3.11.2-6+deb12u6
171+
python3.11-minimal=3.11.2-6+deb12u5
172+
python3.11-venv=3.11.2-6+deb12u5
173+
python3.11=3.11.2-6+deb12u5
188174
python3=3.11.2-1+b1
189175
readline-common=8.2-1.3
190176
sed=4.9-1

0 commit comments

Comments
 (0)