Externalize DB creation

This commit is contained in:
nemunaire 2015-01-13 17:38:30 +01:00 committed by Nemunaire
parent de48af8ef8
commit d687920779
3 changed files with 24 additions and 13 deletions

View File

@ -1,4 +1,5 @@
.git
TODO
db/
docs/guide
perl-mcrypt/

View File

@ -39,19 +39,6 @@ RUN dpkg -i /var/www/fic-server/libmcrypt-perl*.deb || \
ln -sf /var/www/fic-server/nginx-server.conf /etc/nginx/sites-enabled/default && \
ln -sf /var/www/fic-server/php-fpm.conf /etc/php5/fpm/pool.d/www.conf
# Generate test certificates ##########################################
RUN bash ./CA.sh -newca
# Import DB ###########################################################
RUN service mysql start && \
echo "CREATE DATABASE fic;" | mysql -u root && \
cat /var/www/fic-server/db/fic2014.sql | mysql -u root fic
# Uncomment the following line to fill with random values
RUN service mysql start && cat /var/www/fic-server/db/feed.sql | mysql -u root fic
# Configure site ######################################################
RUN ln -sf /var/www/fic-server/onyx/config/sample.root.xml /var/www/fic-server/onyx/config/root.xml && \

23
db/Dockerfile Normal file
View File

@ -0,0 +1,23 @@
FROM debian:wheezy
MAINTAINER Pierre-Olivier Mercier <nemunaire@nemunai.re>
# Install packages ####################################################
RUN apt-get -y update && \
apt-get install -y \
mysql-client \
&& \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Copying files #######################################################
WORKDIR /var/www/fic-server
ADD fic2014.sql feed.sql /var/www/fic-server/db/
# Import DB ###########################################################
CMD echo "CREATE DATABASE IF NOT EXISTS $DB_ENV_MYSQL_DATABASE;" | mysql -h $DB_PORT_3306_TCP_ADDR -u root --password=$DB_ENV_MYSQL_ROOT_PASSWORD && \
cat /var/www/fic-server/db/fic2014.sql | mysql -h $DB_PORT_3306_TCP_ADDR -u root --password=$DB_ENV_MYSQL_ROOT_PASSWORD $DB_ENV_MYSQL_DATABASE && \
cat /var/www/fic-server/db/feed.sql | mysql -h $DB_PORT_3306_TCP_ADDR -u $DB_ENV_MYSQL_USER --password=$DB_ENV_MYSQL_PASSWORD $DB_ENV_MYSQL_DATABASE && \
echo "Import ok"