-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
127 lines (103 loc) · 2.83 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# ALPINE - PHP
ARG ALPINE_VERSION=3.20
ARG PHP_VERSION=8.3
FROM alpine:${ALPINE_VERSION}
FROM php:${PHP_VERSION}-fpm-alpine
# Setup unique user and group - needs bash
RUN apk add --no-cache bash
ARG UID
ARG GID
ENV UID=${UID}
ENV GID=${GID}
RUN addgroup -g ${GID} --system docker
RUN adduser -G docker --system -D -s /bin/sh -u ${UID} docker
# Create project root
RUN mkdir -p /var/www/htdocs
WORKDIR /var/www/htdocs
# Install main packages and remove default server definition
ENV PHP_V="php83"
RUN apk add --no-cache \
curl \
wget \
openssl \
nginx \
zip \
nano \
git \
supervisor
RUN set -xe \
&& apk add --no-cache --virtual .build-deps \
libzip-dev \
freetype-dev \
icu-dev \
libmcrypt-dev \
libjpeg-turbo-dev \
libpng-dev \
libxslt-dev \
patch \
openssh-client
# Install PHP and its extensions packages and remove default server definition
RUN apk add --no-cache \
${PHP_V} \
${PHP_V}-cli \
${PHP_V}-ctype \
${PHP_V}-curl \
${PHP_V}-dom \
${PHP_V}-fileinfo \
${PHP_V}-fpm \
${PHP_V}-gd \
${PHP_V}-intl \
${PHP_V}-mbstring \
${PHP_V}-opcache \
${PHP_V}-openssl \
${PHP_V}-phar \
${PHP_V}-session \
${PHP_V}-tokenizer \
${PHP_V}-soap \
${PHP_V}-xml \
${PHP_V}-xmlreader \
${PHP_V}-xmlwriter \
${PHP_V}-simplexml \
${PHP_V}-zip \
# Databases
${PHP_V}-pdo \
${PHP_V}-pdo_sqlite \
${PHP_V}-sqlite3 \
${PHP_V}-pdo_mysql \
${PHP_V}-mysqlnd \
${PHP_V}-mysqli \
${PHP_V}-pdo_pgsql \
${PHP_V}-pgsql \
${PHP_V}-mongodb \
${PHP_V}-redis
# PHP requires these extension from Docker
RUN docker-php-ext-install pdo pdo_mysql gd
# PHP PECL extensions
RUN apk add \
${PHP_V}-pecl-amqp \
${PHP_V}-pecl-xdebug
# Configure nginx - http
COPY config/nginx.conf /etc/nginx/nginx.conf
# Configure nginx - default server
COPY config/conf.d /etc/nginx/conf.d/
# Configure PHP-FPM
COPY config/fpm-pool.conf /etc/${PHP_V}/php-fpm.d/www.conf
COPY config/php.ini /etc/${PHP_V}/conf.d/custom.ini
# Configure XDebug - optional
#COPY config/xdebug.ini /etc/${PHP_V}/conf.d/xdebug.ini
# Configure supervisord
COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Make sure files/folders needed by the processes are accessable when they run under the nobody user
RUN chown -R docker.docker /var/www/htdocs /run /var/lib/nginx /var/log/nginx
# PHP Composer
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
# Create symlink for php
RUN ln -s -f /usr/bin/${PHP_V} /usr/bin/php
# Switch to use a non-root user from here on
USER docker
# Add application
COPY --chown=docker.docker ../ /var/www/htdocs/
# Expose port/s Nginx will listen - Add more as required: (9003 - Xdebug)
EXPOSE 80 443 9003
# Let supervisord start nginx & php-fpm
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]