Skip to content

Commit 284da01

Browse files
Merge branch 'main' into galexie
2 parents c67bb69 + aa327d5 commit 284da01

File tree

4 files changed

+56
-11
lines changed

4 files changed

+56
-11
lines changed

.github/workflows/internal-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ on:
3939
cache_id:
4040
description: "A value insert into cache keys to namespace cache usage, or invalidate it by incrementing"
4141
type: "string"
42-
default: 18
42+
default: 19
4343
cache_prefix:
4444
description: "A prefix added to all cache keys generated by this workflow"
4545
type: "string"

Dockerfile

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,13 @@ COPY --from=stellar-xdr-builder /usr/local/cargo/bin/stellar-xdr /stellar-xdr
4141
FROM ubuntu:24.04 AS stellar-core-builder
4242

4343
ENV DEBIAN_FRONTEND=noninteractive
44-
RUN apt-get update && \
44+
COPY apt-retry /usr/local/bin/
45+
RUN apt-retry sh -c 'apt-get update && \
4546
apt-get -y install iproute2 procps lsb-release \
4647
git build-essential pkg-config autoconf automake libtool \
4748
bison flex sed perl libpq-dev parallel \
4849
clang-20 libc++abi-20-dev libc++-20-dev \
49-
postgresql curl jq
50+
postgresql curl jq'
5051

5152
ARG CORE_REPO
5253
ARG CORE_REF
@@ -97,7 +98,8 @@ ENV RUSTUP_HOME=/rust/.rust
9798
ENV PATH="/usr/local/go/bin:$CARGO_HOME/bin:${PATH}"
9899
ENV DEBIAN_FRONTEND=noninteractive
99100

100-
RUN apt-get update && apt-get install -y build-essential jq && apt-get clean
101+
COPY apt-retry /usr/local/bin/
102+
RUN apt-retry sh -c 'apt-get update && apt-get install -y build-essential jq' && apt-get clean
101103
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $RUST_TOOLCHAIN_VERSION
102104

103105
RUN make build-stellar-rpc
@@ -111,7 +113,8 @@ COPY --from=stellar-rpc-builder /go/src/github.com/stellar/stellar-rpc/stellar-r
111113
FROM golang:1.24-trixie AS stellar-horizon-builder
112114

113115
ENV DEBIAN_FRONTEND=noninteractive
114-
RUN apt-get update && apt-get -y install jq
116+
COPY apt-retry /usr/local/bin/
117+
RUN apt-retry sh -c 'apt-get update && apt-get -y install jq'
115118

116119
ARG HORIZON_REPO
117120
ARG HORIZON_REF
@@ -135,7 +138,8 @@ COPY --from=stellar-horizon-builder /stellar-horizon /stellar-horizon
135138
FROM golang:1.24-trixie AS stellar-friendbot-builder
136139

137140
ENV DEBIAN_FRONTEND=noninteractive
138-
RUN apt-get update && apt-get -y install jq
141+
COPY apt-retry /usr/local/bin/
142+
RUN apt-retry sh -c 'apt-get update && apt-get -y install jq'
139143

140144
ARG FRIENDBOT_REPO
141145
ARG FRIENDBOT_REF
@@ -226,6 +230,7 @@ EXPOSE 8100
226230
EXPOSE 11625
227231
EXPOSE 11626
228232

233+
COPY apt-retry /usr/local/bin/
229234
ADD dependencies /
230235
RUN /dependencies
231236

apt-retry

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
# Retry wrapper for apt commands to handle transient mirror failures.
5+
# Uses decorrelated jitter: delay = rand(base, 3 * prev_delay), capped at max_delay
6+
# Usage: apt-retry apt-get update && apt-retry apt-get install -y <packages>
7+
8+
RED='\033[0;31m'
9+
NC='\033[0m' # No Color
10+
11+
max_attempts=5
12+
base_delay=2
13+
max_delay=20
14+
15+
# Decorrelated jitter: random value between base_delay and 3 * previous delay, capped
16+
next_delay() {
17+
local prev=$1
18+
local range=$((3 * prev - base_delay + 1))
19+
local next=$((base_delay + RANDOM % range))
20+
if [ $next -gt $max_delay ]; then
21+
next=$max_delay
22+
fi
23+
echo $next
24+
}
25+
26+
delay=$base_delay
27+
attempt=1
28+
29+
while [ $attempt -le $max_attempts ]; do
30+
if "$@"; then
31+
exit 0
32+
fi
33+
if [ $attempt -lt $max_attempts ]; then
34+
echo -e "${RED}apt command failed (attempt $attempt/$max_attempts), retrying in ${delay}s...${NC}"
35+
sleep $delay
36+
fi
37+
attempt=$((attempt + 1))
38+
delay=$(next_delay $delay)
39+
done
40+
41+
echo -e "${RED}apt command failed after $max_attempts attempts${NC}"
42+
exit 1

dependencies

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,17 @@ set -e
55
export DEBIAN_FRONTEND=noninteractive
66

77
# Add PostgreSQL APT repository for PostgreSQL 14
8-
apt-get update
9-
apt-get install -y curl ca-certificates lsb-release
8+
apt-retry sh -c 'apt-get update && apt-get install -y curl ca-certificates lsb-release'
109
install -d /usr/share/postgresql-common/pgdg
1110
curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc
1211
. /etc/os-release
1312
sh -c "echo 'deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt ${VERSION_CODENAME}-pgdg main' > /etc/apt/sources.list.d/pgdg.list"
1413

15-
apt-get update
16-
apt-get install -y curl apt-transport-https \
14+
apt-retry sh -c 'apt-get update && apt-get install -y curl apt-transport-https \
1715
postgresql-client-14 postgresql-14 postgresql-contrib \
1816
sudo supervisor psmisc \
1917
nginx rsync jq golang-github-pelletier-go-toml netcat-openbsd \
20-
libunwind8 sqlite3 libc++abi1-20 libc++1-20
18+
libunwind8 sqlite3 libc++abi1-20 libc++1-20'
2119
apt-get clean
2220
rm -rf /var/lib/apt/lists/*
2321

0 commit comments

Comments
 (0)