-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
237 lines (168 loc) · 4.7 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
ARG UID=1000
ARG GID=${UID}
ARG PHP_VERSION=8.3.14
ARG VARNISH_VERSION=7.6.1
ARG NGINX_VERSION=1.27.2
ARG MYSQL_VERSION=8.0.40
ARG MARIADB_VERSION=10.11.9
ARG SOLR_VERSION=9
##########
# Solr #
##########
FROM solr:${SOLR_VERSION}-slim AS solr
LABEL org.opencontainers.image.authors="[email protected]"
ARG UID
ARG GID
USER root
RUN <<EOF
set -ex
usermod -u ${UID} "$SOLR_USER"
groupmod -g ${GID} "$SOLR_GROUP"
chown -R ${UID}:${GID} /var/solr
EOF
COPY docker/solr/managed-schema.xml /opt/solr/server/solr/configsets/_default/conf/managed-schema
USER $SOLR_USER
###########
# MySQL #
###########
FROM mysql:${MYSQL_VERSION} AS mysql
LABEL org.opencontainers.image.authors="[email protected]"
ARG UID
ARG GID
COPY --link docker/mysql/performances.cnf /etc/mysql/conf.d/performances.cnf
RUN <<EOF
usermod -u ${UID} mysql
groupmod -g ${GID} mysql
EOF
#############
# MariaDB #
#############
FROM mariadb:${MARIADB_VERSION} AS mariadb
LABEL org.opencontainers.image.authors="[email protected]"
ARG UID
ARG GID
COPY --link docker/mysql/performances.cnf /etc/mysql/conf.d/performances.cnf
RUN <<EOF
usermod -u ${UID} mysql
groupmod -g ${GID} mysql
EOF
###########
# Varnish #
###########
FROM varnish:${VARNISH_VERSION} AS varnish
LABEL org.opencontainers.image.authors="[email protected]"
COPY --link docker/varnish/default.vcl /etc/varnish/
#######
# PHP #
#######
FROM php:${PHP_VERSION}-fpm-bookworm AS php
LABEL org.opencontainers.image.authors="[email protected]"
ARG UID
ARG GID
ARG COMPOSER_VERSION=2.8.1
ARG PHP_EXTENSION_INSTALLER_VERSION=2.6.0
ARG PHP_EXTENSION_REDIS_VERSION=6.1.0
SHELL ["/bin/bash", "-e", "-o", "pipefail", "-c"]
ENV APP_FFMPEG_PATH=/usr/bin/ffmpeg
RUN <<EOF
apt-get --quiet update
apt-get --quiet --yes --purge --autoremove upgrade
# Packages - System
apt-get --quiet --yes --no-install-recommends --verbose-versions install \
less \
sudo \
ffmpeg
rm -rf /var/lib/apt/lists/*
# User
addgroup --gid ${UID} php
adduser --home /home/php --shell /bin/bash --uid ${GID} --gecos php --ingroup php --disabled-password php
echo "php ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/php
# App
install --verbose --owner php --group php --mode 0755 --directory /app
# Php extensions
curl -sSLf https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions \
--output /usr/local/bin/install-php-extensions
chmod +x /usr/local/bin/install-php-extensions
install-php-extensions \
@composer-${COMPOSER_VERSION} \
fileinfo \
gd \
imagick \
iconv \
intl \
json \
mbstring \
opcache \
openssl \
pcntl \
pdo_mysql \
simplexml \
xsl \
zip \
redis-${PHP_EXTENSION_REDIS_VERSION}
EOF
WORKDIR /app
#############
# Php - Dev #
#############
FROM php AS php-dev
# Configs
RUN ln -sf ${PHP_INI_DIR}/php.ini-development ${PHP_INI_DIR}/php.ini
COPY --link docker/php/conf.d/app.dev.ini ${PHP_INI_DIR}/conf.d/zz-app.ini
COPY --link docker/php/fpm.d/www.dev.conf ${PHP_INI_DIR}-fpm.d/zz-www.conf
# Entrypoint
COPY --link --chmod=755 docker/php/docker-entrypoint.dev /usr/local/bin/docker-entrypoint
ENTRYPOINT ["docker-entrypoint"]
CMD ["php-fpm"]
USER php
##############
# Cron - Dev #
##############
FROM php-dev AS cron-dev
# Need to go back with root user
USER root
COPY --link docker/cron/crontab.txt /crontab.txt
RUN <<EOF
# Packages
apt-get --quiet update
apt-get --quiet --yes --no-install-recommends --verbose-versions install cron
rm -rf /var/lib/apt/lists/*
/usr/bin/crontab -u php /crontab.txt
EOF
# Entrypoint
COPY --link --chmod=755 docker/cron/docker-cron-entrypoint.dev /usr/local/bin/docker-entrypoint
ENTRYPOINT ["docker-entrypoint"]
USER root
#########
# Nginx #
#########
FROM nginx:${NGINX_VERSION}-bookworm AS nginx
LABEL org.opencontainers.image.authors="[email protected]"
ARG UID
ARG GID
SHELL ["/bin/bash", "-e", "-o", "pipefail", "-c"]
RUN <<EOF
# Packages
apt-get --quiet update
apt-get --quiet --yes --purge --autoremove upgrade
apt-get --quiet --yes --no-install-recommends --verbose-versions install \
less \
sudo
rm -rf /var/lib/apt/lists/*
# User
groupmod --gid ${GID} nginx
usermod --uid ${UID} nginx
echo "nginx ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/nginx
# App
install --verbose --owner nginx --group nginx --mode 0755 --directory /app
EOF
WORKDIR /app
###############
# Nginx - Dev #
###############
FROM nginx AS nginx-dev
# Config
COPY --link docker/nginx/nginx.conf /etc/nginx/nginx.conf
COPY --link docker/nginx/conf.d/_gzip.conf /etc/nginx/conf.d/_gzip.conf
COPY --link docker/nginx/conf.d/_security.conf /etc/nginx/conf.d/_security.conf
COPY --link docker/nginx/conf.d/default.dev.conf /etc/nginx/conf.d/default.conf