-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathphp.dockerfile
More file actions
64 lines (49 loc) · 1.7 KB
/
php.dockerfile
File metadata and controls
64 lines (49 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
FROM php:8-fpm-alpine
ARG UID
ARG GID
ENV UID=${UID}
ENV GID=${GID}
RUN mkdir -p /var/www/html
WORKDIR /var/www/html
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
# 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
# RUN docker-php-ext-install pdo pdo_mysql
# Install Redis extension manually
RUN mkdir -p /usr/src/php/ext/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"]