Skip to content

Instantly share code, notes, and snippets.

@tieutantan
Created August 8, 2021 05:05
Show Gist options
  • Save tieutantan/917cc0b435eacb0c786fb51871f0027e to your computer and use it in GitHub Desktop.
Save tieutantan/917cc0b435eacb0c786fb51871f0027e to your computer and use it in GitHub Desktop.
Dockerfile for PHP8 + Laravel
FROM php:8.0.3-apache-buster
# Surpresses debconf complaints of trying to install apt packages interactively
# https://github.com/moby/moby/issues/4032#issuecomment-192327844
ARG DEBIAN_FRONTEND=noninteractive
# Update
RUN apt-get -y update --fix-missing && \
apt-get upgrade -y && \
apt-get --no-install-recommends install -y apt-utils && \
rm -rf /var/lib/apt/lists/*
# Install useful tools and install important libaries
RUN apt-get -y update && \
apt-get -y --no-install-recommends install nano wget \
dialog \
libsqlite3-dev \
libsqlite3-0 && \
apt-get -y --no-install-recommends install default-mysql-client \
zlib1g-dev \
libzip-dev \
libicu-dev && \
apt-get -y --no-install-recommends install --fix-missing apt-utils \
build-essential \
git \
curl \
libonig-dev && \
apt-get -y --no-install-recommends install --fix-missing libcurl4 \
libcurl4-openssl-dev \
zip \
openssl && \
rm -rf /var/lib/apt/lists/* && \
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Install xdebug
RUN pecl install xdebug-3.0.0 && \
docker-php-ext-enable xdebug
# Install redis
RUN pecl install redis-5.3.3 && \
docker-php-ext-enable redis
# Install imagick
RUN apt-get update && \
apt-get -y --no-install-recommends install --fix-missing libmagickwand-dev && \
rm -rf /var/lib/apt/lists/*
# Workarround until imagick is available in pecl with php8 support
# Imagick Commit to install
# https://github.com/Imagick/imagick
ARG IMAGICK_COMMIT="132a11fd26675db9eb9f0e9a3e2887c161875206"
RUN cd /usr/local/src && \
git clone https://github.com/Imagick/imagick && \
cd imagick && \
git checkout ${IMAGICK_COMMIT} && \
phpize && \
./configure && \
make && \
make install && \
cd .. && \
rm -rf imagick && \
docker-php-ext-enable imagick
# Other PHP8 Extensions
RUN docker-php-ext-install pdo_mysql
RUN docker-php-ext-install pdo_sqlite
RUN docker-php-ext-install mysqli
RUN docker-php-ext-install curl
RUN docker-php-ext-install tokenizer
RUN docker-php-ext-install zip
RUN docker-php-ext-install -j$(nproc) intl
RUN docker-php-ext-install mbstring
RUN docker-php-ext-install gettext
RUN docker-php-ext-install calendar
RUN docker-php-ext-install bcmath
RUN docker-php-ext-install ctype
RUN docker-php-ext-install fileinfo
RUN docker-php-ext-install xml
RUN docker-php-ext-install exif
# Install Freetype
RUN apt-get -y update && \
apt-get --no-install-recommends install -y libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev && \
rm -rf /var/lib/apt/lists/* && \
docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg && \
docker-php-ext-install gd
# Enable apache modules
RUN a2enmod rewrite headers
# Cleanup
RUN rm -rf /usr/src/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment