-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
155 lines (135 loc) · 4.11 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
#
# This image uses 2 interstage and an php:7.3-apache final stage
#
# Interstages are:
# - composer
# - npm & yarn & grunt
#
# Final stage gets all that generated stuff and add it to the final image
#
############################
#=== composer interstage ===
############################
FROM composer:latest as composer
WORKDIR /app
#=== Get PMF source code ===
ARG PMF_BRANCH="3.0"
RUN set -x \
&& git clone \
--depth 1 \
-b $PMF_BRANCH \
https://github.com/thorsten/phpMyFAQ.git \
/app
#=== Call composer ===
RUN set -x \
&& composer install --no-dev
########################
#=== yarn interstage ===
########################
FROM node:latest as yarn
WORKDIR /app
#=== Get PMF source code from previous stage ===
COPY --from=composer /app /app
#=== Install dependencies ===
RUN set -x \
&& npm install node-sass -g --unsafe-perm
#=== Build assets ===
RUN set -x \
&& yarn install --network-timeout 1000000 \
&& yarn build
#################################
#=== Final stage with payload ===
#################################
FROM php:7.3-apache
#=== Install gd php dependencie ===
RUN set -x \
&& buildDeps="libpng-dev libjpeg-dev libfreetype6-dev" \
&& apt-get update && apt-get install -y ${buildDeps} --no-install-recommends \
\
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install gd \
\
&& apt-get purge -y ${buildDeps} \
&& rm -rf /var/lib/apt/lists/*
#=== Install ldap php dependencie ===
RUN set -x \
&& buildDeps="libldap2-dev" \
&& apt-get update && apt-get install -y ${buildDeps} --no-install-recommends \
\
&& docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \
&& docker-php-ext-install ldap \
\
&& apt-get purge -y ${buildDeps} \
&& rm -rf /var/lib/apt/lists/*
#=== Install intl, opcache, and zip php dependencie ===
RUN set -x \
&& buildDeps="libicu-dev zlib1g-dev libxml2-dev" \
&& apt-get update && apt-get install -y ${buildDeps} --no-install-recommends \
\
&& docker-php-ext-configure intl \
&& docker-php-ext-install intl \
&& docker-php-ext-install zip \
&& docker-php-ext-install opcache \
\
&& apt-get purge -y ${buildDeps} \
&& rm -rf /var/lib/apt/lists/*
#=== Install mysqli php dependencie ===
RUN set -x \
&& docker-php-ext-install mysqli
#=== Install pgsql dependencie ===
RUN set -ex \
&& buildDeps="libpq-dev" \
&& apt-get update && apt-get install -y $buildDeps \
\
&& docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
&& docker-php-ext-install pdo pdo_pgsql pgsql \
\
&& apt-get purge -y ${buildDeps} \
&& rm -rf /var/lib/apt/lists/*
#=== Apache vhost ===
RUN { \
echo '<VirtualHost *:80>'; \
echo 'DocumentRoot /var/www/html'; \
echo; \
echo '<Directory /var/www/html>'; \
echo '\tOptions -Indexes'; \
echo '\tAllowOverride all'; \
echo '</Directory>'; \
echo '</VirtualHost>'; \
} | tee "$APACHE_CONFDIR/sites-available/app.conf" \
&& set -x \
&& a2ensite app \
&& a2dissite 000-default \
&& echo "ServerName localhost" >> $APACHE_CONFDIR/apache2.conf
#=== Apache security ===
RUN { \
echo 'ServerTokens Prod'; \
echo 'ServerSignature Off'; \
echo 'TraceEnable Off'; \
echo 'Header set X-Content-Type-Options: "nosniff"'; \
echo 'Header set X-Frame-Options: "sameorigin"'; \
} | tee $APACHE_CONFDIR/conf-available/security.conf \
&& set -x \
&& a2enconf security
#=== php default ===
ENV PMF_TIMEZONE="Europe/Berlin" \
PMF_ENABLE_UPLOADS=On \
PMF_MEMORY_LIMIT=64M \
PMF_DISABLE_HTACCESS="" \
PHP_LOG_ERRORS=On \
PHP_ERROR_REPORTING=E_ALL\
PHP_POST_MAX_SIZE=64M \
PHP_UPLOAD_MAX_FILESIZE=64M
#=== Add source code from previously built interstage ===
COPY --from=yarn /app/phpmyfaq .
#=== Ensure debug mode is disabled and do some other stuff over the code ===
RUN set -x \
&& sed -ri ./src/Bootstrap.php \
-e "s~define\('DEBUG', true\);~define\('DEBUG', false\);~" \
&& mv ./config ../saved-config
#=== Set custom entrypoint ===
COPY docker-entrypoint.sh /entrypoint
RUN chmod +x /entrypoint
ENTRYPOINT [ "/entrypoint" ]
#=== Re-Set CMD as we changed the default entrypoint ===
CMD [ "apache2-foreground" ]