I’m running a Docker container for one of the packages that I’m developing. I’m pushing it to a Gitlab instance with our own Kubernetes runners on it. But for some reasons, it doesn’t look like the runner there is using the same container definition as I’m using locally. I’m not sure what is going on, and I’m slowly losing my mind about this.
I’m installing pre-compiled php extensions in the Dockerfile. Especially the php8.2-sockets one is needed for a successful composer install. Locally it works just fine (You can see the php -m output comparison at the bottom).
It also looks like the main php executable is in a different location when running it in the Gitlab pipeline. Locally it is /usr/bin/php and in the runner it is /usr/local/bin/php.
I’m looking for something that explains the difference between local and pipeline, or at least find a way to install the php8.2-sockets extension in the version that is used by the Gitlab pipeline. I don’t want to use --ignore-platform-req=ext-dom because that makes it impossible to write any subsequent tests.
By the way, if someone know how to collapse code snippets. Please let me know. I’d like to collapse the command outputs so it is a bit more readable. Thanks in advance.
My Dockerfile:
FROM debian:bullseye-slim
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update
&& apt-get install -y zip git curl supervisor lsb-release ca-certificates libzip-dev libxml2-dev libicu-dev
&& curl -sSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg
&& sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ bullseye main" > /etc/apt/sources.list.d/php.list'
&& apt-get update
&& apt-get install -y
php8.2-cli php8.2-fpm
php8.2-curl php8.2-sockets php8.2-dom
&& apt-get autoremove -y
&& apt-get clean
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
ENV COMPOSER_ALLOW_SUPERUSER 1
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
WORKDIR /var/www
ENV WWWUSER 1000
ENV WWWGROUP 1001
RUN groupadd --gid $WWWGROUP cbe
&& useradd -m -g $WWWGROUP -u $WWWUSER cbe
ENTRYPOINT ["/bin/bash"]
My .gitlab-ci.yml
variables:
FF_GITLAB_REGISTRY_HELPER_IMAGE: 1
DOCKER_BUILDKIT: 1
DOCKER_DRIVER: overlay2
BUILDKIT_PROGRESS: plain
stages:
- image
- build
php-image:
stage: image
image: docker
services: [ docker:dind ]
before_script:
- echo ${CI_REGISTRY_PASSWORD} | docker login -u ${CI_REGISTRY_USER} --password-stdin ${CI_REGISTRY}
script:
- docker build
--tag ${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_SLUG}
--build-arg BUILDKIT_INLINE_CACHE=1
--push
--progress plain
-f Docker/Dockerfile .
composer:
stage: build
image: ${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_SLUG}
needs: [ php-image ]
script:
- php -m
- which php
- cp phpunit.xml.dist phpunit.xml
- php composer install --optimize-autoloader --no-ansi --no-interaction --no-progress
php -m comparison
Local
bash-5.1# php -m
[PHP Modules]
calendar
Core
ctype
curl
date
dom
exif
FFI
fileinfo
filter
ftp
gettext
hash
iconv
json
libxml
openssl
pcntl
pcre
PDO
Phar
posix
random
readline
Reflection
session
shmop
SimpleXML
sockets
sodium
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zlib
[Zend Modules]
Zend OPcache
bash-5.1# which php
/usr/bin/php
Runner
$ php -m
[PHP Modules]
Core
ctype
curl
date
dom
fileinfo
filter
ftp
hash
iconv
json
libxml
mbstring
mysqlnd
openssl
pcre
PDO
pdo_sqlite
Phar
posix
random
readline
Reflection
session
SimpleXML
sodium
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
zlib
[Zend Modules]
$ which php
/usr/local/bin/php