Skip to content

Commit 75abe31

Browse files
committed
Upgrade to php 8.3
1 parent 5015c89 commit 75abe31

File tree

4 files changed

+121
-47
lines changed

4 files changed

+121
-47
lines changed

Dockerfile

Lines changed: 78 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,85 @@
1-
FROM ubuntu:20.04
1+
# -----------------------------------------------------------------------------
2+
# Base image & PHP version
3+
# -----------------------------------------------------------------------------
4+
FROM ubuntu:22.04
25

3-
ENV DEBIAN_FRONTEND=noninteractive
4-
ARG PHPVERSION=7.4
6+
ARG PHPVERSION=8.3
7+
ENV DEBIAN_FRONTEND=noninteractive \
8+
PHAN_DISABLE_XDEBUG_WARN=1 \
9+
PATH="$PATH:/root/.config/composer/vendor/bin:/root/.composer/vendor/bin"
510

6-
RUN apt-get update && apt-get install -y software-properties-common \
7-
&& add-apt-repository -y ppa:ondrej/php \
8-
&& apt-get install -y \
9-
zip \
10-
curl \
11-
git \
12-
subversion \
13-
php${PHPVERSION} php${PHPVERSION}-xml php${PHPVERSION}-curl php${PHPVERSION}-zip php${PHPVERSION}-mbstring php${PHPVERSION}-dev php${PHPVERSION}-xdebug \
14-
libmagickwand-dev php-imagick \
15-
&& add-apt-repository --remove -y ppa:ondrej/php \
16-
&& apt-get remove -y software-properties-common \
17-
&& rm -rf /var/lib/apt/lists/*
11+
WORKDIR /workspace
1812

19-
#RUN apt-get update && apt-get install -y php-dev
20-
# Enable PHP AST
21-
RUN git clone https://github.com/nikic/php-ast.git \
22-
&& cd php-ast \
23-
&& phpize \
24-
&& ./configure \
25-
&& make \
26-
&& make install \
27-
&& rm -rf php-ast \
28-
&& echo "extension=ast.so" > /etc/php/${PHPVERSION}/cli/conf.d/20-ast.ini
13+
# -----------------------------------------------------------------------------
14+
# 1) Install prerequisites & import Ondřej PPA key
15+
# -----------------------------------------------------------------------------
16+
RUN apt-get update \
17+
&& apt-get install -y --no-install-recommends \
18+
ca-certificates \
19+
curl \
20+
gnupg2 \
21+
dirmngr \
22+
lsb-release \
23+
zip \
24+
git \
25+
subversion \
26+
build-essential \
27+
\
28+
# fetch and install PPA signing key
29+
&& curl -fsSL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xB8DC7E53946656EFBCE4C1DD71DAEAAB4AD4CAB6" \
30+
| gpg --dearmor -o /etc/apt/trusted.gpg.d/ondrej-php.gpg \
31+
\
32+
# add the PPA to sources.list
33+
&& echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu $(lsb_release -sc) main" \
34+
> /etc/apt/sources.list.d/ondrej-php.list
2935

30-
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
31-
&& composer self-update 2.1.3 \
32-
&& composer global require \
33-
phpunit/phpunit \
34-
phpunit/php-code-coverage \
35-
squizlabs/php_codesniffer \
36-
overtrue/phplint \
37-
phan/phan
36+
# -----------------------------------------------------------------------------
37+
# 2) Install PHP + extensions
38+
# -----------------------------------------------------------------------------
39+
RUN apt-get update \
40+
&& apt-get install -y --no-install-recommends \
41+
php${PHPVERSION}-cli \
42+
php${PHPVERSION}-xml \
43+
php${PHPVERSION}-curl \
44+
php${PHPVERSION}-zip \
45+
php${PHPVERSION}-mbstring \
46+
php${PHPVERSION}-dev \
47+
php${PHPVERSION}-xdebug \
48+
php${PHPVERSION}-mysql \
49+
libmagickwand-dev \
50+
php${PHPVERSION}-imagick \
51+
\
52+
# clean up APT lists and PPA metadata
53+
&& rm -rf /var/lib/apt/lists/* \
54+
&& rm /etc/apt/sources.list.d/ondrej-php.list \
55+
&& apt-get purge -y gnupg2 dirmngr lsb-release
3856

39-
ENV PATH=$PATH:/root/.config/composer/vendor/bin PHAN_DISABLE_XDEBUG_WARN=1
40-
# Temporarily support legacy path
41-
ENV PATH=$PATH:/root/.composer/vendor/bin PHAN_DISABLE_XDEBUG_WARN=1
57+
# -----------------------------------------------------------------------------
58+
# 3) Build & enable nikic/php-ast
59+
# -----------------------------------------------------------------------------
60+
RUN git clone https://github.com/nikic/php-ast.git /tmp/php-ast \
61+
&& cd /tmp/php-ast \
62+
&& phpize \
63+
&& ./configure \
64+
&& make -j"$(nproc)" install \
65+
&& echo "extension=ast.so" \
66+
> /etc/php/${PHPVERSION}/cli/conf.d/20-ast.ini \
67+
&& rm -rf /tmp/php-ast
4268

43-
CMD php
69+
# -----------------------------------------------------------------------------
70+
# 4) Install Composer & global PHP tools
71+
# -----------------------------------------------------------------------------
72+
RUN curl -sS https://getcomposer.org/installer \
73+
| php -- --install-dir=/usr/local/bin --filename=composer \
74+
&& composer self-update --2 \
75+
&& composer global require --no-interaction \
76+
phpunit/phpunit \
77+
phpunit/php-code-coverage \
78+
squizlabs/php_codesniffer \
79+
overtrue/phplint \
80+
phan/phan
4481

45-
WORKDIR /workspace
82+
# -----------------------------------------------------------------------------
83+
# Default command
84+
# -----------------------------------------------------------------------------
85+
CMD ["php"]

hooks/build

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
#!/bin/bash
22
set -e
33

4+
PHPVERSION=8.3
5+
DOCKER_REPO=cyberpearuk/php-build-docker
6+
47
if [ "$DOCKER_TAG" == "latest" ] ; then
5-
docker build --build-arg PHPVERSION=7.4 -t $DOCKER_REPO:7.4 .
6-
docker build --build-arg PHPVERSION=8.0 -t $DOCKER_REPO:8.0 .
8+
docker build --build-arg PHPVERSION=$PHPVERSION -t $DOCKER_REPO:$PHPVERSION .
79

810
# Set latest
911
docker tag $DOCKER_REPO:7.4 $DOCKER_REPO:latest
1012
else
11-
docker build --build-arg PHPVERSION=7.4 -t $DOCKER_REPO:$DOCKER_TAG-7.4 .
12-
docker build --build-arg PHPVERSION=8.0 -t $DOCKER_REPO::$DOCKER_TAG-8.0 .
13+
docker build --build-arg PHPVERSION=$PHPVERSION -t $DOCKER_REPO::$DOCKER_TAG-$PHPVERSION .
1314

1415
# Set latest
15-
docker tag $DOCKER_REPO:$DOCKER_TAG-7.4 $DOCKER_REPO:$DOCKER_TAG
16+
docker tag $DOCKER_REPO:$DOCKER_TAG-$PHPVERSION $DOCKER_REPO:$DOCKER_TAG
1617
fi
1718

hooks/push

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#!/bin/bash
22
set -e
33

4+
PHPVERSION=8.3
5+
46
if [ "$DOCKER_TAG" == "latest" ] ; then
5-
docker push $DOCKER_REPO:7.4
6-
docker push $DOCKER_REPO:8.0
7+
docker push $DOCKER_REPO:$PHPVERSION
78
docker push $DOCKER_REPO:latest
89
else
910

10-
docker push $DOCKER_REPO:$DOCKER_TAG-7.4
11-
docker push $DOCKER_REPO:$DOCKER_TAG-8.0
11+
docker push $DOCKER_REPO:$DOCKER_TAG-$PHPVERSION
1212
docker push $DOCKER_REPO:$DOCKER_TAG
1313
fi
1414

local-dev.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
# Determine namespace and name from script location
6+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
7+
NAMESPACE=$(basename "$(dirname "$SCRIPT_DIR")")
8+
NAME=$(basename "$SCRIPT_DIR")
9+
DOCKER_TAG=development
10+
11+
IMAGE_NAME="${NAMESPACE}/${NAME}:${DOCKER_TAG}"
12+
13+
# Build the Docker image
14+
build() {
15+
echo "Building Docker image: ${IMAGE_NAME}"
16+
docker build -t "$IMAGE_NAME" "$SCRIPT_DIR"
17+
}
18+
19+
# Display usage information
20+
usage() {
21+
echo "Usage: $0 {build|run|build-run|build-push}"
22+
exit 1
23+
}
24+
25+
# Main command dispatcher
26+
case "${1:-}" in
27+
build)
28+
build
29+
;;
30+
*)
31+
usage
32+
;;
33+
esac

0 commit comments

Comments
 (0)