Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update php.dockerfile #221

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
34 changes: 32 additions & 2 deletions dockerfiles/php.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,50 @@ COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
# MacOS staff group's gid is 20, so is the dialout group in alpine linux. We're not using it, let's just remove it.
RUN delgroup dialout

# Add the laravel user and group
RUN addgroup -g ${GID} --system laravel
RUN adduser -G laravel --system -D -s /bin/sh -u ${UID} laravel

# Update php-fpm configuration to use the laravel user
RUN sed -i "s/user = www-data/user = laravel/g" /usr/local/etc/php-fpm.d/www.conf
RUN sed -i "s/group = www-data/group = laravel/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

RUN docker-php-ext-install pdo pdo_mysql
# Install necessary packages
RUN apk add --no-cache \
icu-dev \
zip \
libzip-dev \
libintl \
oniguruma-dev \
curl \
gcc \
make \
autoconf \
g++ \
libc-dev \
linux-headers \
&& docker-php-ext-install \
pdo_mysql \
intl \
zip \
pcntl

# Install Redis extension
RUN pecl install redis && docker-php-ext-enable redis
Copy link

@Gildus Gildus Jan 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be:

RUN pecl install igbinary && \
    docker-php-ext-enable igbinary  && \
    echo "y" | pecl install redis && \
    docker-php-ext-enable redis


# RUN docker-php-ext-install pdo pdo_mysql

# Install Redis extension manually
RUN mkdir -p /usr/src/php/ext/redis \
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code would no longer work, because the extension would already be installed with:

RUN pecl install redis...

&& curl -L 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


# Give ownership of the /var/www/html directory to the laravel user
# RUN chown -R laravel:laravel /var/www/html
RUN chown -R laravel:laravel /var/www/html && chmod -R 775 /var/www/html

USER laravel

CMD ["php-fpm", "-y", "/usr/local/etc/php-fpm.conf", "-R"]