Created
September 22, 2022 08:28
-
-
Save elvinlari/7b75dc3d9115ab269ae69cff27fd3cdc to your computer and use it in GitHub Desktop.
PHP custom dockerfile.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM php:8.1-fpm-alpine | |
# environment arguments | |
ARG UID | |
ARG GID | |
ARG USER | |
ENV UID=${UID} | |
ENV GID=${GID} | |
ENV USER=${USER} | |
# Dialout group in alpine linux conflicts with MacOS staff group's gid, whis is 20. So we remove it. | |
RUN delgroup dialout | |
# Creating user and group | |
RUN addgroup -g ${GID} --system ${USER} | |
RUN adduser -G ${USER} --system -D -s /bin/sh -u ${UID} ${USER} | |
# Modify php fpm configuration to use the new user's priviledges. | |
RUN sed -i "s/user = www-data/user = '${USER}'/g" /usr/local/etc/php-fpm.d/www.conf | |
RUN sed -i "s/group = www-data/group = '${USER}'/g" /usr/local/etc/php-fpm.d/www.conf | |
RUN echo "php_admin_flag[log_errors] = on" >> /usr/local/etc/php-fpm.d/www.conf | |
# Installing php extensions | |
RUN apk update && apk upgrade | |
RUN docker-php-ext-install pdo pdo_mysql bcmath | |
# Installing redis extension | |
RUN mkdir -p /usr/src/php/ext/redis \ | |
&& curl -fsSL https://github.com/phpredis/phpredis/archive/5.3.4.tar.gz | tar xvz -C /usr/src/php/ext/redis --strip 1 \ | |
&& echo 'redis' >> /usr/src/php-available-exts \ | |
&& docker-php-ext-install redis | |
CMD ["php-fpm", "-y", "/usr/local/etc/php-fpm.conf", "-R"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment