Skip to content

Commit 0032e74

Browse files
authored
Amélioration des perfs docker (#2203)
1 parent 3bf1991 commit 0032e74

3 files changed

Lines changed: 62 additions & 48 deletions

File tree

.github/workflows/ci.yml

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,26 @@ jobs:
7171
steps:
7272
- uses: actions/checkout@v6
7373

74-
- name: Cache Docker images.
75-
uses: AndreKurait/docker-cache@0.6.0
74+
- name: Create .env from .env.dist
75+
run: cp .env.dist .env
76+
77+
- uses: docker/setup-buildx-action@v4
78+
79+
- name: Build images with GHA cache
80+
uses: docker/bake-action@v7
7681
with:
77-
key: |
78-
docker-${{ runner.os }}-${{ hashFiles(
79-
'compose.yml',
80-
'docker/dockerfiles/apachephp/Dockerfile',
81-
'docker/dockerfiles/mysql/Dockerfile',
82-
'docker/dockerfiles/mysqltest/Dockerfile'
83-
) }}
82+
files: |
83+
compose.yml
84+
compose.override.yml-dist
85+
targets: |
86+
apachephp
87+
apachephptest
88+
load: true
89+
set: |
90+
apachephp.cache-from=type=gha,scope=apachephp-full
91+
apachephp.cache-to=type=gha,scope=apachephp-full,mode=max
92+
apachephptest.cache-from=type=gha,scope=apachephp-full
93+
apachephptest.cache-to=type=gha,scope=apachephp-full,mode=max
8494
8595
- name: Delete symfony cache
8696
run: rm -rf var/cache/test
@@ -101,20 +111,30 @@ jobs:
101111
integration:
102112
name: "Integration tests"
103113
runs-on: ubuntu-22.04
114+
env:
115+
APACHEPHPTEST_TARGET: base
104116

105117
steps:
106118
- uses: actions/checkout@v6
107119

108-
- name: Cache Docker images.
109-
uses: AndreKurait/docker-cache@0.6.0
120+
- name: Create .env from .env.dist
121+
run: cp .env.dist .env
122+
123+
- uses: docker/setup-buildx-action@v4
124+
125+
- name: Build images with GHA cache
126+
uses: docker/bake-action@v7
110127
with:
111-
key: |
112-
docker-${{ runner.os }}-${{ hashFiles(
113-
'compose.yml',
114-
'docker/dockerfiles/apachephp/Dockerfile',
115-
'docker/dockerfiles/mysql/Dockerfile',
116-
'docker/dockerfiles/mysqltest/Dockerfile'
117-
) }}
128+
files: |
129+
compose.yml
130+
compose.override.yml-dist
131+
targets: |
132+
apachephptest
133+
dbtest
134+
load: true
135+
set: |
136+
apachephptest.cache-from=type=gha,scope=apachephp-base
137+
apachephptest.cache-to=type=gha,scope=apachephp-base,mode=max
118138
119139
- name: Delete symfony cache
120140
run: rm -rf var/cache/test

compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ services:
2727
apachephp:
2828
build:
2929
context: ./docker/dockerfiles/apachephp
30+
target: ${APACHEPHP_TARGET:-full}
3031
args:
3132
uid: ${CURRENT_UID:-1001}
3233
gid: "1001"
@@ -48,6 +49,7 @@ services:
4849
apachephptest:
4950
build:
5051
context: ./docker/dockerfiles/apachephp
52+
target: ${APACHEPHPTEST_TARGET:-full}
5153
args:
5254
uid: ${CURRENT_UID:-1001}
5355
gid: "1001"
Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,35 @@
1-
FROM php:8.2-apache
1+
FROM php:8.2-apache AS base
22

33
ARG ENABLE_XDEBUG=false
44
ARG uid=1008
55
ARG gid=1008
66

7+
# Download PHP extension installer
8+
ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
9+
710
## Update system
811
RUN apt-get update && \
9-
apt-get upgrade -y && \
10-
apt-get autoremove --purge -y && \
11-
rm -rf /var/lib/apt/lists/* && \
12+
apt-get install -y --no-install-recommends ca-certificates curl && \
1213
# Create user for Apache
1314
groupadd -g ${gid} localUser && \
1415
useradd -l -u ${uid} -g ${gid} -m -s /bin/bash localUser && \
15-
usermod -a -G www-data localUser
16-
17-
RUN if [ "$ENABLE_XDEBUG" = "true" ]; then echo ************ XDEBUG ENABLED **********; \
18-
else echo ------------ XDEBUG DISABLED ==========; fi
19-
20-
RUN curl -sL https://deb.nodesource.com/setup_22.x | bash -
16+
usermod -a -G www-data localUser && \
17+
rm -rf /var/lib/apt/lists/*
2118

22-
# Install required PHP extensions for AFUP website and other management package
23-
RUN apt-get update && \
24-
apt-get install -y --no-install-recommends \
25-
libfreetype6-dev \
26-
libjpeg62-turbo-dev \
27-
libpng-dev \
28-
libzip-dev \
29-
libmcrypt4 \
30-
libicu-dev \
31-
nodejs \
32-
chromium \
33-
&& \
34-
docker-php-ext-configure gd --with-freetype --with-jpeg \
35-
&& \
36-
docker-php-ext-install \
19+
RUN install-php-extensions \
3720
pdo_mysql \
3821
mysqli \
3922
zip \
4023
gd \
4124
intl \
42-
pcntl \
43-
&& \
44-
if [ "$ENABLE_XDEBUG" = "true" ]; then pecl install xdebug-3.4.2 && docker-php-ext-enable xdebug; fi && \
45-
apt-get autoremove --purge -y && \
46-
rm -rf /var/lib/apt/lists/*
25+
pcntl
26+
27+
RUN if [ "$ENABLE_XDEBUG" = "true" ]; then \
28+
echo "************ XDEBUG ENABLED **********" && \
29+
install-php-extensions xdebug-3.4.2; \
30+
else \
31+
echo "------------ XDEBUG DISABLED =========="; \
32+
fi
4733

4834
# Configuration of Apache and PHP
4935
COPY apache.conf /etc/apache2/sites-available/000-default.conf
@@ -58,3 +44,9 @@ RUN sed --in-place "s/User \${APACHE_RUN_USER}/User localUser/" /etc/apache2/apa
5844

5945
# Installing Composer
6046
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
47+
48+
FROM base AS full
49+
50+
RUN curl -sL https://deb.nodesource.com/setup_22.x | bash - && \
51+
apt-get install -y --no-install-recommends nodejs chromium && \
52+
rm -rf /var/lib/apt/lists/*

0 commit comments

Comments
 (0)