-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.fpm
More file actions
100 lines (81 loc) · 2.73 KB
/
Dockerfile.fpm
File metadata and controls
100 lines (81 loc) · 2.73 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
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
91
92
93
94
95
96
97
98
99
100
ARG PHP_VERSION
ARG ALPINE_VERSION
FROM php:${PHP_VERSION}-fpm-alpine${ALPINE_VERSION}
LABEL maintainer="Samusevich Alexander <archer.developer@gmail.com>"
ARG ENVIRONMENT=development
ARG COMPOSER_VERSION
ENV COMPOSER_MEMORY_LIMIT=-1 \
SERVICE_AVAILABLE_DIR=/etc/sv \
SERVICE_ENABLED_DIR=/etc/service
RUN apk update --update-cache && \
apk upgrade --available && \
apk --no-cache add \
bash \
openssh \
icu-dev \
zlib-dev \
libzip-dev \
libpng-dev \
libjpeg-turbo-dev \
freetype-dev \
oniguruma-dev \
libxml2-dev \
unzip \
nginx \
runit \
git \
&& mkdir -p ${SERVICE_AVAILABLE_DIR} ${SERVICE_ENABLED_DIR}
# Install basic php extensions
RUN docker-php-ext-configure gd --with-freetype --with-jpeg && \
docker-php-ext-install -j$(nproc) \
gd \
pdo_mysql \
xml \
pcntl \
intl \
calendar \
bcmath \
sysvshm \
sysvsem \
sysvmsg \
zip
# Configure runit to run nginx service
RUN mkdir -p "/run/nginx"
RUN mkdir -p "$SERVICE_AVAILABLE_DIR/nginx"
COPY ./nginx/run "$SERVICE_AVAILABLE_DIR/nginx/run"
RUN chmod +x "$SERVICE_AVAILABLE_DIR/nginx/run"
RUN ln -s "$SERVICE_AVAILABLE_DIR/nginx" ${SERVICE_ENABLED_DIR}
# Configure runit to run php-fpm service
RUN mkdir -p "/run/php-fpm"
RUN mkdir -p "$SERVICE_AVAILABLE_DIR/php-fpm"
COPY ./php/run "$SERVICE_AVAILABLE_DIR/php-fpm/run"
RUN chmod +x "$SERVICE_AVAILABLE_DIR/php-fpm/run"
RUN ln -s "$SERVICE_AVAILABLE_DIR/php-fpm" ${SERVICE_ENABLED_DIR}
# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer --version=${COMPOSER_VERSION}
RUN composer --version
# Configure PHP and FPM
RUN rm /usr/local/etc/php-fpm.d/zz-docker.conf
ADD ./php/fpm/www.conf /usr/local/etc/php-fpm.d/
# Use the default configuration according to environment
RUN mv "$PHP_INI_DIR/php.ini-${ENVIRONMENT}" "$PHP_INI_DIR/php.ini"
# Customize the default configuration according to environment
ADD ./php/php.ini-${ENVIRONMENT} "$PHP_INI_DIR/conf.d/custom.ini"
# Configure Nginx
ADD ./nginx/nginx.conf /etc/nginx/nginx.conf
ADD ./nginx/default.conf /etc/nginx/conf.d/default.conf
ADD ./nginx/ssl/nginx-selfsigned.crt /etc/nginx/ssl/nginx-selfsigned.crt
ADD ./nginx/ssl/nginx-selfsigned.key /etc/nginx/ssl/nginx-selfsigned.key
RUN rm -rf /var/www/html && \
rm -rf /var/www/localhost
# forward request and error logs to docker log collector
RUN ln -sf /dev/stdout /var/log/nginx/access.log && \
ln -sf /dev/stderr /var/log/nginx/error.log
EXPOSE 443/tcp 80/tcp
STOPSIGNAL SIGTERM
# Replace default entrypoint and cmd
CMD []
ADD ./entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
WORKDIR /var/www/app
ENTRYPOINT ["/entrypoint.sh"]