-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile.nginx
64 lines (57 loc) · 1.78 KB
/
Dockerfile.nginx
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
FROM alpine:3.19
WORKDIR /var/www/html
RUN set -x \
&& apk add --no-cache nginx gettext unzip curl \
&& curl -L https://github.com/the-djmaze/snappymail/releases/download/v2.33.0/snappymail-2.33.0.zip -o snappymail.zip \
#https://github.com/the-djmaze/snappymail/releases/download/v2.16.3/snappymail-2.16.3.zip -o snappymail.zip \
&& unzip -o snappymail.zip \
&& rm snappymail.zip \
#&& rm -rf data/ \
&& find . -regex '.*\.php' | grep -v index.php | xargs rm \
#&& adduser -u 82 -D -S -G www-data www-data \
&& find . -type d -exec chmod 755 {} \; \
&& find . -type f -exec chmod 644 {} \; \
&& adduser -u 82 -D -S -G www-data www-data \
&& chown -R www-data:www-data .
ENV NGINX_PROCS\
NGINX_CONN\
PHP_HOST\
PHP_PORT
#nginx configuration
RUN echo -e "\
daemon off;\n\
worker_processes \$NGINX_PROCS;\n\
error_log stderr;\n\
pid /var/run/nginx.pid;\n\
\n\
events {\n\
worker_connections \$NGINX_CONN;\n\
}\n\
\n\
http {\n\
access_log /dev/stdout;\n\
include mime.types;\n\
server {\n\
listen 80;\n\
root /var/www/html/;\n\
index index.php;\n\
location ~ [^/]\.php(/|$) {\n\
fastcgi_split_path_info ^(.+?\.php)(/.*)$;\n\
if (!-f \$document_root\$fastcgi_script_name) {\n\
return 404;\n\
}\n\
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;\n\
fastcgi_pass \$PHP_HOST:\$PHP_PORT;\n\
fastcgi_index index.php;\n\
include fastcgi_params;\n\
}\n\
location ^~ /data {\n\
deny all;\n\
}\n\
}\n\
}\
" > /etc/nginx/nginx.conf.temp
CMD envsubst '$NGINX_PROCS,$NGINX_CONN,$PHP_HOST,$PHP_PORT'\
< /etc/nginx/nginx.conf.temp > /etc/nginx/nginx.conf\
&& exec nginx
EXPOSE 80