Skip to content

Instantly share code, notes, and snippets.

@rhpaiva
Last active September 25, 2021 18:59
Show Gist options
  • Save rhpaiva/3651edf4d0f086b15fac18bb89587685 to your computer and use it in GitHub Desktop.
Save rhpaiva/3651edf4d0f086b15fac18bb89587685 to your computer and use it in GitHub Desktop.
Dockerfile for PHP 8 with amqp extension built from source while the library doesn't get updated. Based on the thread: https://github.com/php-amqp/php-amqp/issues/386
FROM php:8.0-fpm-alpine as linux_dependencies
# Install modules
RUN apk upgrade --update && apk --no-cache add \
$PHPIZE_DEPS \
freetype-dev \
libjpeg-turbo-dev \
libpng-dev \
icu-dev \
libpq \
curl-dev \
oniguruma-dev \
unzip \
postgresql-dev \
rabbitmq-c \
rabbitmq-c-dev
FROM linux_dependencies AS php_installation
# Extract PHP source
# Create directory for amqp extension
# Download AMQP master branch files to extension directory
# Install amqp extension using built-in docker binary
RUN docker-php-source extract \
&& mkdir /usr/src/php/ext/amqp \
&& curl -L https://github.com/php-amqp/php-amqp/archive/master.tar.gz | tar -xzC /usr/src/php/ext/amqp --strip-components=1
RUN docker-php-ext-install \
bcmath \
intl \
opcache \
mbstring \
amqp
FROM php_installation AS php_extentions_installation
# amqp-1.10.2 \
RUN docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install \
-j$(nproc) gd \
pdo \
pdo_pgsql \
&& pecl install \
redis-5.3.2 \
igbinary-3.2.1 \
&& docker-php-ext-enable \
redis \
amqp \
igbinary
RUN docker-php-source delete
CMD ["php-fpm"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment