Skip to content

Commit 8ee6134

Browse files
{  "message": "Bad credentials",  "documentation_url": "https://docs.github.com/rest",  "status": "401"}{  "message": "Bad credentials",  "documentation_url": "https://docs.github.com/rest",  "status": "401"}
authored andcommitted
ci: harden apt refreshes
1 parent 8578ef7 commit 8ee6134

4 files changed

Lines changed: 31 additions & 5 deletions

File tree

.github/actions/setup/action.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,19 @@ runs:
2424
- name: Install OpenSSH client
2525
shell: bash
2626
run: |
27-
sudo apt-get update
28-
sudo apt-get install -y openssh-client
27+
for attempt in 1 2 3; do
28+
sudo rm -rf /var/lib/apt/lists/*
29+
if sudo apt-get -o Acquire::Retries=3 -o Acquire::By-Hash=force update; then
30+
break
31+
fi
32+
if [[ "$attempt" == "3" ]]; then
33+
echo "apt-get update failed after retries" >&2
34+
exit 1
35+
fi
36+
echo "apt-get update attempt ${attempt} failed; retrying..." >&2
37+
sleep $((attempt * 2))
38+
done
39+
sudo apt-get -o Acquire::Retries=3 install -y openssh-client
2940
- name: Install node-gyp
3041
shell: bash
3142
run: npm install -g node-gyp

packages/api/Dockerfile

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,22 @@ ENV BUN_INSTALL=/opt/bun
99
ENV PATH=/opt/bun/bin:$PATH
1010
WORKDIR /workspace
1111

12-
RUN apt-get update && apt-get install -y --no-install-recommends \
12+
RUN set -eu; \
13+
sed -i 's|http://archive.ubuntu.com/ubuntu|http://azure.archive.ubuntu.com/ubuntu|g' \
14+
/etc/apt/sources.list /etc/apt/sources.list.d/ubuntu.sources 2>/dev/null || true; \
15+
for attempt in 1 2 3; do \
16+
rm -rf /var/lib/apt/lists/*; \
17+
if apt-get -o Acquire::Retries=3 -o Acquire::By-Hash=force update; then \
18+
break; \
19+
fi; \
20+
if [ "$attempt" = "3" ]; then \
21+
echo "apt-get update failed after retries" >&2; \
22+
exit 1; \
23+
fi; \
24+
echo "apt-get update attempt ${attempt} failed; retrying..." >&2; \
25+
sleep $((attempt * 2)); \
26+
done; \
27+
apt-get -o Acquire::Retries=3 install -y --no-install-recommends \
1328
ca-certificates curl git docker.io docker-compose-v2 openssh-client sshpass python3 make g++ unzip \
1429
&& rm -rf /var/lib/apt/lists/*
1530

packages/app/src/lib/core/templates/dockerfile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ENV NVM_DIR=/usr/local/nvm
1111
RUN set -eu; \
1212
for attempt in 1 2 3 4 5; do \
1313
rm -rf /var/lib/apt/lists/*; \
14-
if apt-get -o Acquire::Retries=3 update; then \
14+
if apt-get -o Acquire::Retries=3 -o Acquire::By-Hash=force update; then \
1515
break; \
1616
fi; \
1717
if [ "$attempt" = "5" ]; then \

packages/lib/src/core/templates/dockerfile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ENV NVM_DIR=/usr/local/nvm
1010
RUN set -eu; \
1111
for attempt in 1 2 3 4 5; do \
1212
rm -rf /var/lib/apt/lists/*; \
13-
if apt-get -o Acquire::Retries=3 update; then \
13+
if apt-get -o Acquire::Retries=3 -o Acquire::By-Hash=force update; then \
1414
break; \
1515
fi; \
1616
if [ "$attempt" = "5" ]; then \

0 commit comments

Comments
 (0)