-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
250 lines (212 loc) · 10.5 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
238
239
240
241
242
243
244
245
246
247
248
249
250
# syntax = docker/dockerfile:1.2
# Build intermediate container to handle Github token
FROM aro.jfrog.io/moodle/php:7.4-apache as composer
ENV APACHE_DOCUMENT_ROOT /vendor/moodle/moodle
# Version control for Moodle and plugins
ENV MOODLE_BRANCH_VERSION MOODLE_311_STABLE
ENV F2F_BRANCH_VERSION MOODLE_311_STABLE
ENV HVP_BRANCH_VERSION stable
ENV FORMAT_BRANCH_VERSION MOODLE_311
ENV CERTIFICATE_BRANCH_VERSION MOODLE_31_STABLE
ENV CUSTOMCERT_BRANCH_VERSION MOODLE_311_STABLE
ENV DATAFLOWS_BRANCH_VERSION MOODLE_35_STABLE-690-lasttimestarted
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 zip && \
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
# Add plugins (try to add these via composer later)
#RUN mkdir -p /vendor/moodle
RUN git clone --recurse-submodules --jobs 8 --branch $MOODLE_BRANCH_VERSION --single-branch https://github.com/moodle/moodle /vendor/moodle/moodle
RUN mkdir -p /vendor/moodle/moodle/admin/tool/trigger && \
mkdir -p /vendor/moodle/moodle/admin/tool/dataflows && \
mkdir -p /vendor/moodle/moodle/mod/facetoface && \
mkdir -p /vendor/moodle/moodle/mod/hvp && \
mkdir -p /vendor/moodle/moodle/course/format/topcoll && \
mkdir -p /vendor/moodle/moodle/mod/certificate && \
mkdir -p /vendor/moodle/moodle/mod/customcert && \
chown -R www-data:www-data /vendor/moodle/moodle/admin/tool/ && \
chown -R www-data:www-data /vendor/moodle/moodle/mod/ && \
chown -R www-data:www-data /vendor/moodle/moodle/course/format/
RUN git clone --recurse-submodules --jobs 8 https://github.com/catalyst/moodle-tool_trigger /vendor/moodle/moodle/admin/tool/trigger && \
git clone --recurse-submodules --jobs 8 --branch $DATAFLOWS_BRANCH_VERSION --single-branch https://github.com/catalyst/moodle-tool_dataflows.git /vendor/moodle/moodle/admin/tool/dataflows && \
git clone --recurse-submodules --jobs 8 --branch $F2F_BRANCH_VERSION --single-branch https://github.com/catalyst/moodle-mod_facetoface /vendor/moodle/moodle/mod/facetoface && \
git clone --recurse-submodules --jobs 8 --branch $HVP_BRANCH_VERSION --single-branch https://github.com/h5p/moodle-mod_hvp /vendor/moodle/moodle/mod/hvp && \
git clone --recurse-submodules --jobs 8 --branch $FORMAT_BRANCH_VERSION --single-branch https://github.com/gjb2048/moodle-format_topcoll /vendor/moodle/moodle/course/format/topcoll && \
git clone --recurse-submodules --jobs 8 --branch $CERTIFICATE_BRANCH_VERSION --single-branch https://github.com/mdjnelson/moodle-mod_certificate /vendor/moodle/moodle/mod/certificate && \
git clone --recurse-submodules --jobs 8 --branch $CUSTOMCERT_BRANCH_VERSION --single-branch https://github.com/mdjnelson/moodle-mod_customcert /vendor/moodle/moodle/mod/customcert
# RUN git submodule update --init
##################################################
##################################################
# Build Moodle image
FROM aro.jfrog.io/moodle/php:7.4-apache as moodle
ARG CONTAINER_PORT=8080
ARG ENV_FILE=""
ARG CRONTAB="FALSE"
ARG DB_HOST="localhost"
ARG DB_NAME="moodle"
ARG DB_PASSWORD=""
ARG DB_USER="moodle"
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 grsync && \
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
#Install rsync
RUN apt-get install rsync -y
RUN apt-get install cron -y && \
apt-get install libfreetype6-dev -y && \
apt-get install libjpeg-dev \libpng-dev -y && \
apt-get install libpq-dev -y && \
apt-get install libssl-dev -y && \
apt-get install ca-certificates -y && \
apt-get install libcurl4-openssl-dev -y && \
apt-get install libgd-tools -y && \
apt-get install libmcrypt-dev -y && \
apt-get install zip -y && \
apt-get install default-mysql-client -y && \
apt-get install vim -y && \
apt-get install wget -y && \
apt-get install graphviz -y && \
apt-get install libbz2-dev -y
RUN docker-php-ext-install mysqli && \
docker-php-ext-install xmlrpc && \
docker-php-ext-install soap && \
docker-php-ext-install zip && \
docker-php-ext-install bcmath && \
docker-php-ext-install bz2 && \
docker-php-ext-install exif && \
docker-php-ext-install ftp && \
docker-php-ext-install gd && \
docker-php-ext-install gettext && \
docker-php-ext-install intl && \
docker-php-ext-install opcache && \
docker-php-ext-install shmop && \
docker-php-ext-install sysvmsg && \
docker-php-ext-install sysvsem && \
docker-php-ext-install sysvshm && \
docker-php-ext-enable gd && \
docker-php-ext-enable intl && \
docker-php-ext-enable mysqli && \
docker-php-ext-enable soap && \
docker-php-ext-enable xmlrpc && \
docker-php-ext-enable zip && \
docker-php-ext-configure intl && \
docker-php-ext-configure gd --with-freetype --with-jpeg
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
USER root
# Use ONE of these - High Availability (-ha-readonly) or standard
#COPY --chown=www-data:www-data app/config/sync/moodle/moodle-config-no-composer.php /vendor/moodle/moodle/config.php
COPY --chown=www-data:www-data app/config/sync/moodle/moodle-config.php /vendor/moodle/moodle/config.php
# Find/replace config values to make the file solid for CLI/Cron (not using ENV vars)
RUN sed -i "s|DB_HOST|${DB_HOST}|" /vendor/moodle/moodle/config.php
RUN sed -i "s|DB_NAME|${DB_NAME}|" /vendor/moodle/moodle/config.php
RUN sed -i "s|DB_USER|${DB_USER}|" /vendor/moodle/moodle/config.php
RUN sed -i "s|DB_PASSWORD|${DB_PASSWORD}|" /vendor/moodle/moodle/config.php
# 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/apache2-mods-available-mpm_prefork.conf /etc/apache2/mods-available/mpm_prefork.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
# 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/moodle/mod ; fi && \
if [ "$ENV_FILE" != ".local" ] ; then chown -R www-data:www-data /vendor/moodle/moodledata/persistent ; fi && \
chgrp -R 0 ${APACHE_DOCUMENT_ROOT} && \
chmod -R g=u ${APACHE_DOCUMENT_ROOT} && \
chown -R www-data:www-data ${APACHE_DOCUMENT_ROOT} && \
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 && \
chgrp -R 0 /.env && \
chmod -R g=u /.env && \
chown -R www-data:www-data /vendor/moodle/moodle/mod && \
chgrp -R 0 /vendor/moodle/moodle/mod && \
chmod -R g=u /vendor/moodle/moodle/mod
ENTRYPOINT ["apachectl", "-D", "FOREGROUND"]