Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 64 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,76 @@
ARG PHP_IMAGE=7.4-alpine
FROM php:${PHP_IMAGE}
ARG PHP_VERSION="8.3"

ENV docroot="."
FROM php:${PHP_VERSION}-alpine as base

EXPOSE 8000
RUN set -eux && apk update --no-cache

VOLUME [ "/root-dir" ]

# see https://github.com/php/php-src/blob/PHP-7.4/UPGRADING#L766-L775
# with PHP-7.4+ "docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/"
# has changed to "docker-php-ext-configure gd --with-freetype --with-jpeg"
FROM base as build

# See https://github.com/joseluisq/alpine-php-fpm/tree/master/8.1-fpm

# Install build dependencies
RUN set -eux \
&& apk add --no-cache --update --virtual .build-deps $PHPIZE_DEPS \
linux-headers \
freetype-dev \
libjpeg-turbo-dev \
libpng-dev \
libwebp-dev \
icu-dev \
libxpm-dev \
&& true

RUN apk add --no-cache --virtual .phpize-deps $PHPIZE_DEPS \
&& apk --no-cache add --virtual .ext-deps freetype-dev libjpeg-turbo-dev libpng-dev icu-dev \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install gd mysqli pdo pdo_mysql intl \
&& pecl install -o -f xdebug \
# Install PHP extensions
RUN set -eux \
\
# Install gd
&& ln -s /usr/lib/$(apk --print-arch)-linux-gnu/libXpm.* /usr/lib/ \
&& docker-php-ext-configure gd \
--enable-gd \
--with-webp \
--with-jpeg \
--with-xpm \
--with-freetype \
--enable-gd-jis-conv \
&& docker-php-ext-install -j$(nproc) gd \
\
# Install intl
&& docker-php-ext-install -j$(nproc) intl \
\
# Install mysqli
&& docker-php-ext-install -j$(nproc) mysqli \
\
# Install pdo
&& docker-php-ext-install -j$(nproc) pdo \
&& docker-php-ext-install -j$(nproc) pdo_mysql \
\
# Install xdebug
&& pecl install xdebug \
&& docker-php-ext-enable xdebug \
&& apk del .phpize-deps \
&& rm -rf /tmp/pear
\
# Clean up build dependencies
&& docker-php-source delete \
&& apk del .build-deps \
&& rm -rf /tmp/* \
&& true


FROM base as target

ENV DOCUMENT_ROOT="."

EXPOSE 80

VOLUME [ "/root-dir" ]

COPY xdebug.ini $PHP_INI_DIR/conf.d/
COPY --from=composer /usr/bin/composer /usr/bin/composer
COPY --from=build /usr/local/lib/php/extensions/* /usr/local/lib/php/extensions
COPY --from=build /usr/local/etc/php/conf.d/* /usr/local/lib/php/conf.d
RUN cp /usr/local/etc/php/php.ini-development /usr/local/etc/php/php.ini

COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh

ENTRYPOINT ["entrypoint.sh"]
CMD php -S 0.0.0.0:8000 -t $docroot
CMD ["php", "-S", "0.0.0.0:80", "-t", $DOCUMENT_ROOT]
1 change: 1 addition & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php phpinfo();