-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
90 lines (67 loc) · 2.43 KB
/
Dockerfile
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# Base image
FROM php:7-fpm-alpine AS base
RUN apk update --no-cache && \
apk upgrade --no-cache
FROM base AS build
RUN apk add --no-cache \
$PHPIZE_DEPS \
linux-headers
RUN apk add --no-cache \
freetype-dev \
libjpeg-turbo-dev \
libwebp-dev \
libzip-dev
#####################################
# PHP Extensions
#####################################
# Install for image manipulation
RUN docker-php-ext-install exif
# Install the PHP graphics library
RUN docker-php-ext-configure gd \
--with-freetype \
--with-jpeg \
--with-webp
RUN docker-php-ext-install gd
# Install the PHP opcache extention
RUN docker-php-ext-enable opcache
# Install the PHP pdo_mysql extention
RUN docker-php-ext-install pdo_mysql
# Install the PHP redis driver
RUN pecl install redis && \
docker-php-ext-enable redis
# Install the PHP zip extention
RUN docker-php-ext-install zip
FROM base AS target
ENV UID=1000
ENV GID=1000
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
RUN addgroup -g ${GID} --system laravel
RUN adduser -G laravel --system -D -s /bin/sh -u ${UID} laravel
RUN sed -i "s/pm.max_children = 5/pm.max_children = 15/g" /usr/local/etc/php-fpm.d/www.conf && \
sed -i "s/pm.max_spare_servers = 3/pm.max_spare_servers = 6/g" /usr/local/etc/php-fpm.d/www.conf && \
sed -i "s/user = www-data/user = laravel/g" /usr/local/etc/php-fpm.d/www.conf && \
sed -i "s/group = www-data/group = laravel/g" /usr/local/etc/php-fpm.d/www.conf && \
echo "php_admin_flag[log_errors] = on" >> /usr/local/etc/php-fpm.d/www.conf
#####################################
# Install necessary libraries
#####################################
RUN apk add --no-cache \
freetype \
libjpeg-turbo \
libwebp \
libzip
#####################################
# Copy extensions from build stage
#####################################
COPY --from=build /usr/local/lib/php/extensions/no-debug-non-zts-20190902/* /usr/local/lib/php/extensions/no-debug-non-zts-20190902
COPY --from=build /usr/local/etc/php/conf.d/* /usr/local/etc/php/conf.d
#####################################
# Cleanup
#####################################
RUN rm -rf /tmp/* /var/tmp/* /usr/src/php*
USER laravel
CMD ["php-fpm", "-y", "/usr/local/etc/php-fpm.conf", "-R"]