forked from gesinn-it/docker-mediawiki
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile-mysql.template
100 lines (86 loc) · 4.37 KB
/
Dockerfile-mysql.template
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
###################################################
# gesinn-it/docker-mediawiki:mw-%%MEDIAWIKI_VERSION%%
#
# MEDIAWIKI_VERSION: MediaWiki Version
# COMPOSER_VERSION: Composer Major Version (1 or 2)
###################################################
FROM mediawiki:%%MEDIAWIKI_VERSION%%
ARG MYSQL_PORT
# Fix owner
RUN chown -R www-data:www-data .
# Install required packages
RUN apt-get update && \
apt-get install -y \
sudo \
unzip \
less \
nano \
nodejs \
npm \
wget \
default-mysql-client
RUN rm -rf /var/lib/apt/lists/*
# Install required php extensions
RUN docker-php-ext-install calendar
# Test MySQL Connection
# RUN mysql --host 127.0.0.1 --port ${MYSQL_PORT} -uroot -pdatabase -e "SELECT @@VERSION"
# MySQL grant privileges
# RUN mysql --host 127.0.0.1 --port ${MYSQL_PORT} -uroot -pdatabase -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'database'"
# Install pdo_mysql
RUN docker-php-ext-install pdo_mysql
# Create database restore script
RUN echo "wget https://github.com/gesinn-it/docker-mediawiki/releases/download/%%MEDIAWIKI_VERSION%%/mediawiki-mysql-%%MEDIAWIKI_VERSION%%.sql.bz2" >> restore-database.sh && \
echo "bunzip2 mediawiki-mysql-%%MEDIAWIKI_VERSION%%.sql.bz2" >> restore-database.sh && \
echo "export MYSQL_PWD=database" >> restore-database.sh && \
echo "mysql --host mysql -uroot -e \"CREATE DATABASE wiki\"" >> restore-database.sh && \
echo "mysql --host mysql -uroot -e \"CREATE USER IF NOT EXISTS 'wiki'@'%';\"" >> restore-database.sh && \
echo "mysql --host mysql -uroot -e \"ALTER USER 'wiki'@'%' IDENTIFIED BY 'wiki';\"" >> restore-database.sh && \
echo "mysql --host mysql -uroot -e \"CREATE USER IF NOT EXISTS 'wiki'@'localhost';\"" >> restore-database.sh && \
echo "mysql --host mysql -uroot -e \"ALTER USER 'wiki'@'localhost' IDENTIFIED BY 'wiki';\"" >> restore-database.sh && \
echo "mysql --host mysql -uroot -e \"grant select, insert, update, delete, alter, drop, create, create temporary tables, index on wiki.* to 'wiki'@'%' WITH GRANT OPTION\"" >> restore-database.sh && \
echo "mysql --host mysql -uroot -e \"grant select, insert, update, delete, alter, drop, create, create temporary tables, index on wiki.* to 'wiki'@'localhost' WITH GRANT OPTION\"" >> restore-database.sh && \
echo "mysql --host mysql -uroot --default-character-set=utf8 \"wiki\" < mediawiki-mysql-%%MEDIAWIKI_VERSION%%.sql" >> restore-database.sh && \
echo "unset MYSQL_PWD" >> restore-database.sh && \
cat restore-database.sh
# Bashrc Alias
RUN echo "alias ll='ls -la'" >> /etc/bash.bashrc && \
echo "alias ..='cd ..'" >> /etc/bash.bashrc && \
echo "alias ...='cd ...'" >> /etc/bash.bashrc
# Install Composer
RUN php -r "copy('https://getcomposer.org/installer', 'installer');" && \
php -r "copy('https://composer.github.io/installer.sig', 'expected');" && \
echo `cat expected` " installer" | sha384sum -c - && \
php installer --version=%%COMPOSER_VERSION%% && \
rm -f installer expected && \
mv composer.phar /usr/local/bin/composer
# Install XDebug
RUN pecl install xdebug && \
bash -c "echo 'zend_extension=xdebug' >> /usr/local/etc/php/conf.d/99-xdebug.ini" && \
bash -c "echo 'xdebug.mode=coverage' >> /usr/local/etc/php/conf.d/99-xdebug.ini" && \
php -v
# Setup MediaWiki
## prevent caching
ARG CACHEBUST=1
RUN sudo -u www-data composer update && \
sudo -u www-data php maintenance/install.php \
--pass=wiki4everyone \
--server="http://localhost:8080" \
--scriptpath="" \
--dbserver=127.0.0.1:${MYSQL_PORT} \
--installdbuser=root \
--installdbpass=database \
--dbtype=mysql \
--dbname=wiki \
--dbuser=wiki \
--dbpass=wiki \
wiki WikiSysop
# Set wgDBserver=mysql
RUN sed -i '/$wgDBserver/c\$wgDBserver = "mysql";' LocalSettings.php
# Enable debug output, enable JS testing
RUN bash -c "echo 'error_reporting(E_ALL| E_STRICT);' >> LocalSettings.php" && \
bash -c "echo 'ini_set(\"display_errors\", 1);' >> LocalSettings.php" && \
bash -c 'echo "\$wgShowExceptionDetails = true;" >> LocalSettings.php' && \
bash -c 'echo "\$wgDevelopmentWarnings = true;" >> LocalSettings.php' && \
bash -c 'echo "\$wgEnableJavaScriptTest = true;" >> LocalSettings.php' && \
bash -c 'echo "\$wgDebugToolbar = true;" >> LocalSettings.php' && \
tail -n6 LocalSettings.php