Skip to content

Commit 66fcc57

Browse files
committed
build(dockerfile): add retry function
1 parent 24cb060 commit 66fcc57

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

Dockerfile

+11-6
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,17 @@ RUN apt-get update && apt-get install -y \
1313
git \
1414
cmake \
1515
llvm \
16-
libclang-dev \
17-
&& add-apt-repository ppa:ondrej/php -y \
18-
&& apt-get update
16+
libclang-dev
1917

20-
# Install PHP 8.0,8.1,8.3
21-
RUN apt-get install -y php8.0 php8.0-cli php8.0-common php8.0-dev php8.1 php8.1-cli php8.1-common php8.1-dev php8.2 php8.2-cli php8.2-common php8.2-dev php8.3 php8.3-cli php8.3-common php8.3-dev
18+
# Function to retry commands
19+
RUN echo 'retry() { for i in $(seq 1 5); do $@ && return 0 || sleep 15; done; return 1; }' >> ~/.bashrc
20+
21+
# Install PHP 8.0, 8.1, 8.2, 8.3 using retry logic
22+
RUN . ~/.bashrc && retry add-apt-repository ppa:ondrej/php -y && apt-get update && apt-get install -y \
23+
php8.0 php8.0-cli php8.0-common php8.0-dev \
24+
php8.1 php8.1-cli php8.1-common php8.1-dev \
25+
php8.2 php8.2-cli php8.2-common php8.2-dev \
26+
php8.3 php8.3-cli php8.3-common php8.3-dev
2227

2328
# Create a non-root user and switch to it
2429
RUN useradd -m dockeruser
@@ -32,4 +37,4 @@ RUN cargo install cross
3237

3338
# Verify installations
3439
RUN php -v
35-
RUN php-config --version
40+
RUN php-config --version

0 commit comments

Comments
 (0)