Ship a database snapshot with the docker image, to speed up first use
- Legacy-Id: 19451
This commit is contained in:
parent
19409b9156
commit
3b3e662719
|
@ -109,6 +109,21 @@ RUN rm /master.zip
|
|||
# Colorize the bash shell
|
||||
RUN sed -i 's/#force_color_prompt=/force_color_prompt=/' /root/.bashrc
|
||||
|
||||
# Make a database dump available as part of the image, for if a user doesn't
|
||||
# have one installed locally yet - this saves a bunch of time then
|
||||
ADD https://www.ietf.org/lib/dt/sprint/ietf_utf8.sql.gz /
|
||||
RUN pigz -v -d /ietf_utf8.sql.gz && \
|
||||
sed -i -e 's/ENGINE=MyISAM/ENGINE=InnoDB/' /ietf_utf8.sql
|
||||
RUN service mariadb start && \
|
||||
echo "This sequence will take a long time, please be patient" && \
|
||||
mysqladmin -u root --default-character-set=utf8 create ietf_utf8 && \
|
||||
bash -c "cd /mariadb-sys-master && mysql --user root < sys_10.sql" && \
|
||||
bash -c "mysql --user root ietf_utf8 <<< \"GRANT ALL PRIVILEGES ON *.* TO django@localhost IDENTIFIED BY 'RkTkDPFnKpko'; FLUSH PRIVILEGES;\"" && \
|
||||
bash -c "mysql --user=django --password=RkTkDPFnKpko -f ietf_utf8 < /ietf_utf8.sql" && \
|
||||
service mariadb stop && \
|
||||
rm -rf /ietf_utf8.sql /mariadb-sys-master && \
|
||||
mv /var/lib/mysql /
|
||||
|
||||
# Copy the startup file
|
||||
COPY docker-init.sh /docker-init.sh
|
||||
RUN chmod +x /docker-init.sh
|
||||
|
|
|
@ -10,15 +10,23 @@ fi
|
|||
service rsyslog start
|
||||
|
||||
if [ -z "$(ls -A $MYSQLDIR/mysql 2>/dev/null)" ]; then
|
||||
echo "WARNING: Database seems to be empty."
|
||||
mysql_install_db > /dev/null || exit 1
|
||||
can=$(date -r /mysql +%s)
|
||||
now=$(date +%s)
|
||||
age=$((($now - $can)/86400))
|
||||
echo "NOTE: Database empty; populating it from canned snapshot ($age days old)"
|
||||
echo " This will take a little while..."
|
||||
cp -r /mysql/* $MYSQLDIR
|
||||
fi
|
||||
|
||||
service mariadb start
|
||||
|
||||
if ! service mariadb status; then
|
||||
echo "ERROR: MySQL isn't running."
|
||||
echo "ERROR: MySQL didn't start. Here are some possible causes:"
|
||||
echo "-------------------------------------------------------------------"
|
||||
grep mysqld /var/log/syslog
|
||||
echo "-------------------------------------------------------------------"
|
||||
echo "Such errors are usually due to a corrupt or outdated database."
|
||||
echo "Remove your local database and let the image install a clean copy."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -27,16 +35,6 @@ if [ ! -f /root/src/ietf/settings_local.py ]; then
|
|||
cp /root/src/docker/settings_local.py /root/src/ietf/settings_local.py
|
||||
fi
|
||||
|
||||
if [ ! -d $MYSQLDIR/ietf_utf8 ]; then
|
||||
echo "WARNING: IETF database seems to be missing; populating it from dump."
|
||||
mysqladmin -u root --default-character-set=utf8 create ietf_utf8
|
||||
pushd /mariadb-sys-master || exit
|
||||
mysql -u root < sys_10.sql
|
||||
popd || exit
|
||||
mysql -u root ietf_utf8 <<< "GRANT ALL PRIVILEGES ON *.* TO django@localhost IDENTIFIED BY 'RkTkDPFnKpko'; FLUSH PRIVILEGES;"
|
||||
/root/src/docker/updatedb
|
||||
fi
|
||||
|
||||
for sub in \
|
||||
test/id \
|
||||
test/staging \
|
||||
|
|
Loading…
Reference in a new issue