build base image from debian (#1662)

This commit is contained in:
Brett McBride 2025-07-11 21:11:46 +10:00 committed by GitHub
parent dc52549640
commit 2421c64c51
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 42 additions and 41 deletions

View File

@ -18,7 +18,7 @@ jobs:
name: OpenTelemetry PHP base docker image creation
strategy:
matrix:
php-version: ['8.0', '8.1', '8.2', '8.3', '8.4']
php-version: ['8.1', '8.2', '8.3', '8.4']
runs-on: ubuntu-latest
permissions:
packages: write
@ -47,7 +47,6 @@ jobs:
file: docker/Dockerfile
build-args: PHP_VERSION=${{ matrix.php-version }}
platforms: linux/amd64,linux/arm/v8,linux/arm64
tags: ghcr.io/open-telemetry/opentelemetry-php/opentelemetry-php-base:${{ matrix.php-version }}
- name: Build and push ${{ matrix.php-version }} to ghcr.io
uses: docker/build-push-action@v6

View File

@ -1,43 +1,45 @@
ARG PHP_VERSION=8.0
FROM php:8.0.30-cli-alpine AS php-8.0-cli-alpine
FROM php:8.1.32-cli-alpine AS php-8.1-cli-alpine
FROM php:8.2.28-cli-alpine AS php-8.2-cli-alpine
FROM php:8.3.20-cli-alpine AS php-8.3-cli-alpine
FROM php:8.4.8-cli-alpine AS php-8.4-cli-alpine
FROM php-${PHP_VERSION}-cli-alpine
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN chmod +x /usr/local/bin/install-php-extensions \
&& apk add binutils \
&& install-php-extensions \
@composer \
ast \
grpc \
intl\
opcache \
opentelemetry \
pcntl \
protobuf \
sockets \
xdebug \
zip \
&& find /usr/local/lib/php/extensions -name "*.so" -exec strip --strip-debug {} \;
RUN echo "grpc.enable_fork_support = 1" > $(php-config --ini-dir)/grpc.ini \
&& echo "grpc.poll_strategy = epoll1" >> $(php-config --ini-dir)/grpc.ini
FROM composer:2 AS composer
FROM debian:bullseye
WORKDIR /usr/src/myapp
RUN apk add --no-cache bash git; \
find /usr/local/lib/php/extensions -type d -exec chmod +x -R {} \;; \
addgroup -g "1000" -S php; \
adduser --system \
--gecos "" \
--ingroup "php" \
--uid "1000" \
"php";
RUN apt-get update \
&& apt-get install -y --no-install-recommends git wget gnupg2 \
&& rm -rf /var/lib/apt/lists/* \
&& groupadd --gid 1000 php \
&& useradd --system --uid 1000 --gid php --shell /bin/bash --create-home php
RUN apt-get update && apt-get install -y lsb-release apt-transport-https ca-certificates \
&& echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list \
&& wget -qO - https://packages.sury.org/php/apt.gpg | apt-key add - \
&& apt-get update
ARG PHP_VERSION=8.3
RUN apt-get install -y \
php${PHP_VERSION}-ast \
php${PHP_VERSION}-cli \
php${PHP_VERSION}-curl \
php${PHP_VERSION}-dev \
php${PHP_VERSION}-grpc \
php${PHP_VERSION}-intl \
php${PHP_VERSION}-mbstring \
php${PHP_VERSION}-opcache \
php${PHP_VERSION}-opentelemetry \
php${PHP_VERSION}-protobuf \
php${PHP_VERSION}-simplexml \
php${PHP_VERSION}-sockets \
php${PHP_VERSION}-xdebug \
php${PHP_VERSION}-zip \
php${PHP_VERSION}-mongodb \
php${PHP_VERSION}-amqp \
php${PHP_VERSION}-rdkafka \
php${PHP_VERSION}-mysqli \
unzip
COPY --from=composer /usr/bin/composer /usr/local/bin/composer
RUN echo ";grpc.enable_fork_support = 1" > $(php-config --ini-dir)/40-otel-dev.ini \
&& echo "grpc.poll_strategy = epoll1" >> $(php-config --ini-dir)/40-otel-dev.ini \
&& echo "zend.assertions = 1" >> $(php-config --ini-dir)/40-otel-dev.ini
USER php