-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile.intermediate.performance.dotenv.0.5
227 lines (189 loc) · 7.85 KB
/
Dockerfile.intermediate.performance.dotenv.0.5
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
# syntax = docker/dockerfile:1.2
# Build intermediate container to handle Github token
FROM aro.jfrog.io/moodle/php:7.3-apache as composer
WORKDIR /
RUN apt-get update -y && \
apt-get upgrade -y --fix-missing && \
apt-get dist-upgrade -y && \
dpkg --configure -a && \
apt-get -f install && \
apt-get install -y ssh-client && \
apt-get install -y git && \
apt-get install -o Dpkg::Options::="--force-confold" -y -q --no-install-recommends && apt-get clean -y \
ca-certificates \
libcurl4-openssl-dev \
libgd-tools \
libmcrypt-dev \
default-mysql-client \
vim \
wget && \
apt-get autoremove -y && \
eval `ssh-agent -s` && \
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \
php composer-setup.php && \
mv composer.phar /usr/local/bin/composer && \
php -r "unlink('composer-setup.php');" && \
rm -vfr /var/lib/apt/lists/*
COPY .ssh/id_rsa /.ssh/id_rsa
COPY ./composer.json ./composer.json
ARG GITHUB_AUTH_TOKEN=""
ENV COMPOSER_MEMORY_LIMIT=-1
# Add Github Auth token for Composer build, then install (GITHUB_AUTH_TOKEN.txt should be in root directory and contain the token only)
RUN --mount=type=secret,id=GITHUB_AUTH_TOKEN \
composer config -g github-oauth.github.com $GITHUB_AUTH_TOKEN
RUN composer install --optimize-autoloader --no-interaction --prefer-dist
##################################################
##################################################
# Build Moodle image
FROM aro.jfrog.io/moodle/php:7.3-apache as moodle
ARG CONTAINER_PORT=8080
ARG ENV_FILE=""
ENV APACHE_DOCUMENT_ROOT /vendor/moodle/moodle
ENV VENDOR=/vendor/
ENV COMPOSER_MEMORY_LIMIT=-1
EXPOSE $CONTAINER_PORT
RUN ln -sf /proc/self/fd/1 /var/log/apache2/access.log && \
ln -sf /proc/self/fd/1 /var/log/apache2/error.log && \
apt-get update -y && \
apt-get upgrade -y --fix-missing && \
apt-get dist-upgrade -y && \
dpkg --configure -a && \
apt-get -f install && \
apt-get install -y zlib1g-dev libicu-dev g++ && \
apt-get install rsync && \
apt-get install tar && \
set -eux; \
\
if command -v a2enmod; then \
a2enmod rewrite; \
fi; \
\
savedAptMark="$(apt-mark showmanual)"; \
\
docker-php-ext-install -j "$(nproc)" \
; \
\
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
apt-mark auto '.*' > /dev/null; \
apt-mark manual $savedAptMark; \
ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \
| awk '/=>/ { print $3 }' \
| sort -u \
| xargs -r dpkg-query -S \
| cut -d: -f1 \
| sort -u \
| xargs -rt apt-mark manual; \
\
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false;
# Enable PHP extensions - full list:
# bcmath bz2 calendar ctype curl dba dom enchant exif fileinfo filter ftp gd gettext gmp hash iconv imap interbase intl json ldap mbstring mysqli oci8 odbc opcache pcntl pdo pdo_dblib pdo_firebird pdo_mysql pdo_oci pdo_odbc pdo_pgsql pdo_sqlite pgsql phar posix pspell readline recode reflection session shmop simplexml snmp soap sockets sodium spl standard sysvmsg sysvsem sysvshm tidy tokenizer wddx xml xmlreader xmlrpc xmlwriter xsl zend_test zip
ENV PHP_EXTENSIONS="mysqli xmlrpc soap zip bcmath bz2 exif ftp gd gettext intl opcache shmop sysvmsg sysvsem sysvshm"
#RUN docker-php-ext-install $PHP_EXTENTIONS && \
# docker-php-ext-enable $PHP_EXTENTIONS
RUN apt-get install libxml2-dev -y
RUN apt-get install libzip-dev -y
RUN apt-get update && apt-get install -y libbz2-dev
RUN apt-get install cron -y
RUN apt-get install libfreetype6-dev -y
RUN apt-get install libjpeg-dev \libpng-dev -y
RUN apt-get install libpq-dev -y
RUN apt-get install libssl-dev -y
RUN apt-get install ca-certificates -y
RUN apt-get install libcurl4-openssl-dev -y
RUN apt-get install libgd-tools -y
RUN apt-get install libmcrypt-dev -y
RUN apt-get install zip -y
RUN apt-get install default-mysql-client -y
RUN apt-get install vim -y
RUN apt-get install wget -y
RUN apt-get install libbz2-dev -y
RUN docker-php-ext-install mysqli
RUN docker-php-ext-install xmlrpc
RUN docker-php-ext-install soap
RUN docker-php-ext-install zip
RUN docker-php-ext-install bcmath
RUN docker-php-ext-install bz2
RUN docker-php-ext-install exif
RUN docker-php-ext-install ftp
RUN docker-php-ext-install gd
RUN docker-php-ext-install gettext
RUN docker-php-ext-install intl
RUN docker-php-ext-install opcache
RUN docker-php-ext-install shmop
RUN docker-php-ext-install sysvmsg
RUN docker-php-ext-install sysvsem
RUN docker-php-ext-install sysvshm
RUN docker-php-ext-enable gd
RUN docker-php-ext-enable intl
RUN docker-php-ext-enable mysqli
RUN docker-php-ext-enable soap
RUN docker-php-ext-enable xmlrpc
RUN docker-php-ext-enable zip
RUN docker-php-ext-configure intl
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/
RUN { \
echo 'opcache.enable_cli=1'; \
echo 'opcache.memory_consumption=1024'; \
echo 'opcache.interned_strings_buffer=8'; \
echo 'opcache.max_accelerated_files=6000'; \
echo 'opcache.revalidate_freq=60'; \
echo 'opcache.fast_shutdown=1'; \
echo 'mysqli.default_socket=/var/run/mysqld/mysqld.sock'; \
} > /usr/local/etc/php/conf.d/opcache-recommended.ini && \
apt autoremove -y
# Copy files from intermediate build
COPY --chown=www-data:www-data --from=composer $VENDOR $VENDOR
COPY --chown=www-data:www-data --from=composer /usr/local/bin/composer /usr/local/bin/composer
WORKDIR /
# Don't copy .env to OpenShift - use Deployment Config > Environment instead
COPY .env$ENV_FILE ./.env
# COPY /app/config/sync/apache.conf /etc/apache2/sites-enabled/000-default.conf
COPY --chown=www-data:www-data app/config/sync/apache2.conf /etc/apache2/apache2.conf
COPY --chown=www-data:www-data app/config/sync/ports.conf /etc/apache2/ports.conf
COPY --chown=www-data:www-data app/config/sync/web-root.htaccess /vendor/moodle/moodle/.htaccess
COPY --chown=www-data:www-data app/config/sync/moodle/php.ini-development /usr/local/etc/php/php.ini
COPY --chown=www-data:www-data app/config/sync/moodle/moodle-config.php /vendor/moodle/moodle/config.php
USER root
# Setup Permissions for www user
RUN rm -rf /vendor/moodle/moodle/.htaccess && \
mkdir -p /vendor/moodle/moodledata/ && \
mkdir -p /vendor/moodle/moodledata/persistent && \
if [ "$ENV_FILE" != ".local" ] ; then chown -R www-data:www-data /vendor/moodle ; fi && \
if [ "$ENV_FILE" != ".local" ] ; then chown -R www-data:www-data /vendor/moodle/moodledata/persistent ; fi && \
chgrp -R 0 /vendor/moodle/moodledata/persistent && \
chmod -R g=u /vendor/moodle/moodledata/persistent && \
chown -R www-data:www-data /vendor/moodle/moodledata/persistent && \
chown -R www-data:www-data /vendor/moodle/moodledata/persistent
# chown -R www-data:www-data $VENDOR && \
# chown -R www-data:www-data /usr/local/etc/php/php.ini && \
# chown -R www-data:www-data /vendor/moodle && \
# chown -R www-data:www-data /vendor/moodle/moodledata/persistent && \
# chown -R www-data:www-data /usr/local/bin/composer && \
# chown -R www-data:www-data /vendor/moodle/moodle/config.php
# Add custom theme
# COPY app/config/sync/moodle/theme/bcgov /vendor/moodle/moodledata/theme/bcgov
# RUN chown -R www-data:www-data /vendor/moodle/moodledata/theme/bcgov
#
# Add Cron Job for maintenance tasks
#
##RUN apt-get update && apt-get install -y cron
# Add crontab file in the cron directory
##ADD openshift/jobs/crontab.txt /etc/cron.d/moodle-cron
# Give execution rights on the cron job
##RUN chown -R www-data:www-data /etc/cron.d/moodle-cron
##RUN chmod 0644 /etc/cron.d/moodle-cron
# Apply cron job
##RUN crontab /etc/cron.d/moodle-cron
# Create the log file to be able to run tail
##RUN touch /var/log/cron.log
# Install Cron (above)
# Run the command on container startup
##RUN cron && tail -f /var/log/cron.log
## Can only have one CMD, so choose wisely
# docker
# ENTRYPOINT ["apachectl", "-D", "FOREGROUND"]
# or OpenShift
# CMD /etc/init.d/apache2 start
# CMD ["cron", "-f"]
# CMD /etc/init.d/apache2 start
# ENTRYPOINT [ "/etc/init.d/apache2", "start"]