-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile.php.dev
109 lines (80 loc) · 3.35 KB
/
Dockerfile.php.dev
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
101
102
103
104
105
106
107
108
109
ARG PHP_VERSION
ARG ALPINE_VERSION
# Set master image
FROM php:${PHP_VERSION}-fpm-alpine${ALPINE_VERSION}
# Set working directory
WORKDIR /var/www/html
# Install Additional dependencies
RUN apk add --no-cache \
build-base linux-headers shadow nano curl
# Add and Enable PHP-PDO Extenstions
RUN docker-php-ext-install pdo pdo_mysql && docker-php-ext-enable pdo_mysql
RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli
# https://stackoverflow.com/a/45976380
RUN apk add --no-cache --virtual buildDeps autoconf \
&& pecl install redis \
&& docker-php-ext-enable redis \
&& apk del buildDeps
RUN apk add --no-cache icu-dev icu-data-full \
&& docker-php-ext-configure intl \
&& docker-php-ext-install intl
# Remove Cache
RUN rm -rf /var/cache/apk/*
# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# --- DEV ---
# https://stackoverflow.com/a/46831699
RUN apk add --no-cache $PHPIZE_DEPS \
&& pecl install xdebug \
&& docker-php-ext-enable xdebug
RUN apk add --no-cache libzip-dev \
&& docker-php-ext-configure zip \
&& docker-php-ext-install zip
# https://github.com/docker-library/php/issues/225#issuecomment-226870896
# https://github.com/docker-library/php/issues/912#issuecomment-559918036
RUN apk add --no-cache freetype libpng libjpeg-turbo freetype-dev libpng-dev libjpeg-turbo-dev && \
docker-php-ext-configure gd \
--with-freetype \
--with-jpeg && \
NPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) && \
docker-php-ext-install -j${NPROC} gd && \
apk del --no-cache freetype-dev libpng-dev libjpeg-turbo-dev
RUN docker-php-ext-install exif \
&& docker-php-ext-enable exif
# # https://github.com/zgraveyard/php-7.1-xdebug-alpine
ENV PHP_XDEBUG_DEFAULT_ENABLE ${PHP_XDEBUG_DEFAULT_ENABLE:-1}
ENV PHP_XDEBUG_REMOTE_ENABLE ${PHP_XDEBUG_REMOTE_ENABLE:-1}
ENV PHP_XDEBUG_REMOTE_HOST ${PHP_XDEBUG_REMOTE_HOST:-"127.0.0.1"}
ENV PHP_XDEBUG_REMOTE_PORT ${PHP_XDEBUG_REMOTE_PORT:-9000}
ENV PHP_XDEBUG_REMOTE_AUTO_START ${PHP_XDEBUG_REMOTE_AUTO_START:-1}
ENV PHP_XDEBUG_REMOTE_CONNECT_BACK ${PHP_XDEBUG_REMOTE_CONNECT_BACK:-1}
ENV PHP_XDEBUG_IDEKEY ${PHP_XDEBUG_IDEKEY:-docker}
ENV PHP_XDEBUG_PROFILER_ENABLE ${PHP_XDEBUG_PROFILER_ENABLE:-0}
ENV PHP_XDEBUG_PROFILER_OUTPUT_DIR ${PHP_XDEBUG_PROFILER_OUTPUT_DIR:-"/tmp"}
COPY php/xdebug.ini /usr/local/etc/php/conf.d/xdebug-dev.ini
# Tamaño de subida máximo en PHP
COPY php/limits.ini /usr/local/etc/php/conf.d/php_limits.ini
# Caché de PHP
RUN docker-php-ext-install opcache
COPY php/opcache.ini /usr/local/etc/php/conf.d/php_opcache.ini
# Remove Cache
RUN rm -rf /var/cache/apk/*
# https://github.com/npm/uid-number/issues/3
ENV NPM_CONFIG_UNSAFE_PERM=true
# Node
RUN apk add --update --no-cache nodejs-current npm
# Utils
RUN apk add --update --no-cache bash nano
RUN docker-php-ext-install bcmath && docker-php-ext-enable bcmath
# Variables de configuración extra de PHP
COPY php/extra.ini /usr/local/etc/php/conf.d/extra.ini
# Add UID '1000' to www-data
RUN usermod -u 1000 www-data
RUN chown www-data:www-data /var/www/html
# Change current user to www
USER www-data
# Bash prompt
RUN echo "PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\W\[\033[00m\]\$ '" >> /home/www-data/.bashrc
# Expose port 9000 and start php-fpm server
EXPOSE 9000
CMD ["php-fpm"]