This repository has been archived on 2024-12-31. You can view files and clone it, but cannot push or open issues or pull requests.
composer/Dockerfile.alpine

105 lines
4.1 KiB
Docker

ARG PHP_VERSION=8.4
ARG REGISTRY_URL=docker.io/aprimediet
FROM ${REGISTRY_URL}/php:${PHP_VERSION}-alpine
LABEL maintainer="<Muhamad Aditya Prima> aprimediet@gmail.com"
ARG COMPOSER_VERSION=2.8.4
USER root
WORKDIR /tmp
# Set composer home
ENV COMPOSER_HOME=/usr/local/share/composer
ENV COMPOSER_CACHE_DIR=${COMPOSER_HOME}/cache
# Setup composer user and required directories
RUN addgroup -g 10001 composer && \
adduser -D -u 10001 -G composer -s /bin/sh -h /build composer
mkdir -p ${COMPOSER_CACHE_DIR}/files && \
mkdir -p ${COMPOSER_CACHE_DIR}/repo && \
mkdir -p ${COMPOSER_CACHE_DIR}/vcs && \
chown -R composer:composer ${COMPOSER_CACHE_DIR}
# ADD apk repository
RUN printf "@testing https://dl-cdn.alpinelinux.org/alpine/edge/testing\n" >> /etc/apk/repositories
# Add all php extensions
RUN --mount=type=cache,target=/var/cache/apk \
apk update && apk upgrade && apk add git \
php${PHP_VERSION}-bcmath php${PHP_VERSION}-bz2 \
php${PHP_VERSION}-calendar php${PHP_VERSION}-cgi php${PHP_VERSION}-common \
php${PHP_VERSION}-ctype php${PHP_VERSION}-curl php${PHP_VERSION}-dba \
php${PHP_VERSION}-dev php${PHP_VERSION}-dom \
php${PHP_VERSION}-embed php${PHP_VERSION}-enchant php${PHP_VERSION}-exif \
php${PHP_VERSION}-ffi php${PHP_VERSION}-fileinfo php${PHP_VERSION}-ftp \
php${PHP_VERSION}-gd php${PHP_VERSION}-gettext php${PHP_VERSION}-gmp \
php${PHP_VERSION}-intl php${PHP_VERSION}-ldap php${PHP_VERSION}-mbstring \
php${PHP_VERSION}-mysqli php${PHP_VERSION}-mysqlnd php${PHP_VERSION}-odbc \
php${PHP_VERSION}-opcache php${PHP_VERSION}-pcntl php${PHP_VERSION}-pdo \
php${PHP_VERSION}-pdo_dblib php${PHP_VERSION}-pdo_mysql php${PHP_VERSION}-pdo_odbc \
php${PHP_VERSION}-pdo_pgsql php${PHP_VERSION}-pdo_sqlite php${PHP_VERSION}-pear \
php${PHP_VERSION}-pgsql php${PHP_VERSION}-posix php${PHP_VERSION}-session \
php${PHP_VERSION}-shmop php${PHP_VERSION}-simplexml php${PHP_VERSION}-snmp \
php${PHP_VERSION}-soap php${PHP_VERSION}-sockets php${PHP_VERSION}-sodium \
php${PHP_VERSION}-sqlite3 php${PHP_VERSION}-sysvmsg php${PHP_VERSION}-sysvsem \
php${PHP_VERSION}-sysvshm php${PHP_VERSION}-tidy php${PHP_VERSION}-tokenizer \
php${PHP_VERSION}-xml php${PHP_VERSION}-xmlreader php${PHP_VERSION}-xmlwriter \
php${PHP_VERSION}-xsl php${PHP_VERSION}-zip
# Install php-dbg
RUN --mount=type=cache,target=/var/cache/apk \
apk add --update php${PHP_VERSION}-dbg; exit 0
# Install php-openssl from testing if main or community doesn't exists
RUN --mount=type=cache,target=/var/cache/apk \
apk add --update php${PHP_VERSION}-dbg@testing; exit 0
# Install php-openSSL
RUN --mount=type=cache,target=/var/cache/apk \
apk add --update php${PHP_VERSION}-openssl; exit 0
# Install php-openssl from testing if main or community doesn't exists
RUN --mount=type=cache,target=/var/cache/apk \
apk add --update php${PHP_VERSION}-openssl@testing; exit 0
# Install php-phar
RUN --mount=type=cache,target=/var/cache/apk \
apk add --update php${PHP_VERSION}-phar; exit 0
# Install php-phar from testing if main or community doesn't exists
RUN --mount=type=cache,target=/var/cache/apk \
apk add --update php${PHP_VERSION}-phar@testing; exit 0
# Install php-json
RUN --mount=type=cache,target=/var/cache/apk \
apk add --update php${PHP_VERSION}-json; exit 0
# Install php-json from testing if main or community doesn't exists
RUN --mount=type=cache,target=/var/cache/apk \
apk add --update php${PHP_VERSION}-json@testing; exit 0
# Install php-iconv
RUN --mount=type=cache,target=/var/cache/apk \
apk add --update php${PHP_VERSION}-iconv; exit 0
# Install php-iconv from testing if main or community doesn't exists
RUN --mount=type=cache,target=/var/cache/apk \
apk add --update php${PHP_VERSION}-iconv@testing; exit 0
# Download and install composer
ADD https://getcomposer.org/installer ./composer-setup.php
RUN php composer-setup.php --version=${COMPOSER_VERSION} && \
mv composer.phar /usr/local/bin/composer && \
rm -f ./composer-setup.php
# Clean apk caches
RUN rm -vrf /var/cache/apk/* && \
rm -rf /root/.composer; exit 0
USER composer
WORKDIR /build
CMD ["/usr/local/bin/composer"]