php/8/Dockerfile.almalinux

66 lines
2.0 KiB
Docker

ARG OS_VERSION=9.5
FROM quay.io/teras/almalinux:${OS_VERSION}-minimal AS builder
ARG PHP_VERSION=8.4
ARG COMPOSER_VERSION=2.8.9
ENV PHP_VERSION=${PHP_VERSION}
ENV COMPOSER_VERSION=${COMPOSER_VERSION}
ENV SERVER_ROOT=/app
RUN /bin/mkdir -p ${SERVER_ROOT}; \
/sbin/groupadd -g 10000 php; \
/sbin/useradd -u 10000 -g 10000 -s /bin/sh -M -d ${SERVER_ROOT} php; \
/bin/chown -R php:php ${SERVER_ROOT}; \
/bin/microdnf -y --nodocs install epel-release; \
/bin/microdnf -y upgrade; \
/bin/rpm -Uvh --replacepkgs --replacefiles \
https://rpms.remirepo.net/enterprise/remi-release-9.rpm; \
/bin/microdnf -y module reset php; \
/bin/microdnf -y module enable php:remi-${PHP_VERSION}; \
/bin/microdnf -y --nodocs install \
php php-cli php-common php-phar \
php-iconv php-mbstring php-json;
ADD https://github.com/composer/composer/releases/download/${COMPOSER_VERSION}/composer.phar /usr/local/bin/composer
RUN /bin/chmod +rx /usr/local/bin/composer; \
/bin/microdnf clean all; \
/bin/rm -rf /var/cache/yum/*; \
/bin/rm -rf /var/lib/yum/history/*; \
/bin/rm -rf /var/lib/yum/yumdb/*; \
/bin/rm -rf /var/lib/dnf/*;
# Create symlinks to /usr/bin/php in case it doesn't exists
RUN ln -ns /usr/bin/php${PHP_VERSION} /usr/bin/php; exit 0
FROM scratch
ARG PHP_VERSION=8.4
ARG COMPOSER_VERSION=2.8.9
ENV PHP_VERSION=${PHP_VERSION}
ENV COMPOSER_VERSION=${COMPOSER_VERSION}
ENV SERVER_ROOT=/app
LABEL maintainer="Muhamad Aditya Prima <aditya@teraslink.id>"
LABEL name="php"
LABEL version="${PHP_VERSION}"
LABEL distribution-scope="public"
#labels for container catalog
LABEL summary="PHP ${PHP_VERSION} on almalinux-minimal container image"
LABEL description="Provide php on almalinux-minimal container base image"
LABEL io.k8s.description="PHP with composer"
LABEL io.k8s.display-name="PHP ${PHP_VERSION}"
COPY --from=builder / /
WORKDIR ${SERVER_ROOT}
USER php
STOPSIGNAL SIGQUIT
CMD ["/usr/bin/php", "-v"]