Skip to content

Commit 16b2b37

Browse files
committed
Added dev build tag.
1 parent 636ab6f commit 16b2b37

File tree

3 files changed

+79
-52
lines changed

3 files changed

+79
-52
lines changed

.github/workflows/build image.yaml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ jobs:
1919
distro:
2020
- Alpine
2121
- Debian
22+
target:
23+
- prod
24+
- dev
25+
exclude:
26+
- distro: Debian
27+
target: dev
2228

2329
steps:
2430
- uses: actions/checkout@v4
@@ -34,15 +40,21 @@ jobs:
3440
run: image=${GITHUB_REPOSITORY,,} && <<<image=${image%-*} tee -a "$GITHUB_ENV"
3541

3642
- name: Build Docker image (${{ matrix.distro }})
37-
run: docker build --tag ${tag=${{ env.registry }}/${{ env.image }}:${distro,,}} - <$distro.Dockerfile
43+
run: <$distro.Dockerfile docker build --target $target -
44+
--tag ${tag=${{ env.registry }}/${{ env.image }}:$([[ $target = dev ]] && echo $target || echo ${distro,,})}
3845
&& <<<tag=$tag tee -a "$GITHUB_ENV"
3946
env:
4047
distro: ${{ matrix.distro }}
48+
target: ${{ matrix.target }}
49+
50+
- name: Validate image
51+
run: docker run --rm ${{ env.tag }} php -m |
52+
grep -Fxq $([[ ${{ matrix.target }} = dev ]] || echo --invert-match) xdebug
4153

4254
- name: Push Docker image (${{ env.tag }})
4355
run: docker push ${{ env.tag }}
4456

4557
- name: Push "latest" tag
4658
run: docker tag "$tag" ${latest=${{ env.registry }}/${{ env.image }}}
4759
&& docker push "$latest"
48-
if: ${{ matrix.distro == 'Alpine' }}
60+
if: matrix.target == 'prod' && matrix.distro == 'Alpine'

Alpine.Dockerfile

Lines changed: 41 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,49 @@
11
# https://hub.docker.com/_/php/tags?name=-fpm-alpine
2-
FROM php:8.4.2-fpm-alpine
2+
FROM php:8.4.2-fpm-alpine AS prod
33

44
RUN \
5-
apk add icu icu-dev jemalloc libxslt libxslt-dev libffi libffi-dev libpq libpq-dev gmp gmp-dev \
6-
&& docker-php-ext-install opcache \
7-
# Number formatting in our own application templates requires intl.
8-
intl \
9-
# symfony/messenger requires PCNTL for graceful shutdown of queue workers.
10-
pcntl \
11-
# Pheanstalk requires sockets extension otherwise it throws SocketException with "Unknown error" (CLUB-250-B6).
12-
sockets \
13-
# lorenzo/pinky requires XSL extension.
14-
xsl \
15-
# amphp/hpack can benefit from FFI extension.
16-
ffi \
17-
# amphp/postgres requires either pecl-pq or ext-pgsql.
18-
pgsql \
19-
# Phinx requires pdo_pgsql extension.
20-
pdo_pgsql \
21-
# xpaw/steamid requires GMP extension.
22-
gmp \
23-
# All dev packages can be removed post-compile, however the main packages cannot.
24-
&& apk del icu-dev libxslt-dev libffi-dev libpq-dev gmp-dev
5+
apk add icu icu-dev jemalloc libxslt libxslt-dev libffi libffi-dev libpq libpq-dev gmp gmp-dev \
6+
&& docker-php-ext-install opcache \
7+
# Number formatting in our own application templates requires intl.
8+
intl \
9+
# symfony/messenger requires PCNTL for graceful shutdown of queue workers.
10+
pcntl \
11+
# Pheanstalk requires sockets extension otherwise it throws SocketException with "Unknown error" (CLUB-250-B6).
12+
sockets \
13+
# lorenzo/pinky requires XSL extension.
14+
xsl \
15+
# amphp/hpack can benefit from FFI extension.
16+
ffi \
17+
# amphp/postgres requires either pecl-pq or ext-pgsql.
18+
pgsql \
19+
# Phinx requires pdo_pgsql extension.
20+
pdo_pgsql \
21+
# xpaw/steamid requires GMP extension.
22+
gmp \
23+
# All dev packages can be removed post-compile, however the main packages cannot.
24+
&& apk del icu-dev libxslt-dev libffi-dev libpq-dev gmp-dev
2525

2626
# Replace the slow musl allocator.
2727
ENV LD_PRELOAD=libjemalloc.so.2
2828

2929
RUN \
30-
# Validate jemalloc preloaded.
31-
ldd `which php` | grep libjemalloc.so.2 && \
32-
# Install Composer.
33-
wget https://raw.githubusercontent.com/composer/getcomposer.org/main/web/installer -qO- |\
34-
php -- --install-dir /usr/local/bin --filename composer
30+
# Validate jemalloc preloaded.
31+
ldd `which php` | grep libjemalloc.so.2 && \
32+
# Install Composer.
33+
wget https://raw.githubusercontent.com/composer/getcomposer.org/main/web/installer -qO- |\
34+
php -- --install-dir /usr/local/bin --filename composer
35+
36+
FROM prod AS dev
37+
38+
RUN \
39+
apk add autoconf gcc libc-dev linux-headers make \
40+
&& pecl install xdebug \
41+
&& docker-php-ext-enable xdebug \
42+
&& apk del autoconf gcc libc-dev linux-headers make
43+
44+
RUN <<-'.'
45+
>>/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini echo -n '
46+
xdebug.mode=debug
47+
xdebug.client_host=host.docker.internal
48+
'
49+
.

Debian.Dockerfile

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
# https://hub.docker.com/_/php/tags
2-
FROM php:8.4.2-fpm
2+
FROM php:8.4.2-fpm AS prod
33

44
RUN apt-get update && \
5-
apt-get --assume-yes install libicu-dev libxslt1.1 libxslt1-dev libffi-dev libpq5 libpq-dev libgmp-dev unzip \
6-
&& docker-php-ext-install opcache \
7-
# Number formatting in our own application templates requires intl.
8-
intl \
9-
# symfony/messenger requires PCNTL for graceful shutdown of queue workers.
10-
pcntl \
11-
# Pheanstalk requires sockets extension otherwise it throws SocketException with "Unknown error" (CLUB-250-B6).
12-
sockets \
13-
# lorenzo/pinky requires XSL extension.
14-
xsl \
15-
# amphp/hpack can benefit from FFI extension.
16-
ffi \
17-
# amphp/postgres requires either pecl-pq or ext-pgsql.
18-
pgsql \
19-
# Phinx requires pdo_pgsql extension.
20-
pdo_pgsql \
21-
# xpaw/steamid requires GMP extension.
22-
gmp \
23-
# All dev packages can be removed post-compile, however the main packages cannot.
24-
&& apt-get --assume-yes purge libicu-dev libxslt1-dev libffi-dev libpq-dev libgmp-dev \
25-
&& apt-get --assume-yes autoremove \
26-
&& rm -rf /var/lib/apt/lists/*
5+
apt-get --assume-yes install libicu-dev libxslt1.1 libxslt1-dev libffi-dev libpq5 libpq-dev libgmp-dev unzip \
6+
&& docker-php-ext-install opcache \
7+
# Number formatting in our own application templates requires intl.
8+
intl \
9+
# symfony/messenger requires PCNTL for graceful shutdown of queue workers.
10+
pcntl \
11+
# Pheanstalk requires sockets extension otherwise it throws SocketException with "Unknown error" (CLUB-250-B6).
12+
sockets \
13+
# lorenzo/pinky requires XSL extension.
14+
xsl \
15+
# amphp/hpack can benefit from FFI extension.
16+
ffi \
17+
# amphp/postgres requires either pecl-pq or ext-pgsql.
18+
pgsql \
19+
# Phinx requires pdo_pgsql extension.
20+
pdo_pgsql \
21+
# xpaw/steamid requires GMP extension.
22+
gmp \
23+
# All dev packages can be removed post-compile, however the main packages cannot.
24+
&& apt-get --assume-yes purge libicu-dev libxslt1-dev libffi-dev libpq-dev libgmp-dev \
25+
&& apt-get --assume-yes autoremove \
26+
&& rm -rf /var/lib/apt/lists/*
2727

2828
# Install Composer.
2929
RUN curl https://raw.githubusercontent.com/composer/getcomposer.org/main/web/installer |\
30-
php -- --install-dir /usr/local/bin --filename composer
30+
php -- --install-dir /usr/local/bin --filename composer

0 commit comments

Comments
 (0)