gulp docker && docker-build tasks updated

This commit is contained in:
Joan Sanchez 2018-05-08 11:34:50 +02:00
parent 58f903b294
commit 3c839cea07
4 changed files with 33 additions and 37 deletions

View File

@ -433,9 +433,12 @@ gulp.task('docker-build', async () => {
try {
await execP('docker rmi dblocal:latest');
} catch (e) {}
try {
await execP('docker volume rm data');
} catch (e) {}
log('Building image...');
log(await execP('docker build -t dblocal:latest ./services/db > ./services/db/docker.log'));
await execP('docker build -t dblocal:latest ./services/db');
});
/**
@ -469,7 +472,7 @@ gulp.task('docker-start', async () => {
gulp.task('docker-run', async () => {
try {
await execP('docker image inspect -f "{{json .Id}}" dblocal');
await execP('docker run -d --name dblocal -p 3306:3306 dblocal');
await execP('docker run -d --name dblocal --volume data:/data -p 3306:3306 dblocal');
await runSequenceP('docker-wait');
} catch (err) {
await runSequenceP('docker-build');
@ -484,7 +487,7 @@ gulp.task('docker-wait', callback => {
let interval = 1;
let elapsedTime = 0;
let maxInterval = 45 * 60;
let maxInterval = 30 * 60;
log('Waiting for MySQL init process...');
checker();

View File

@ -1,10 +1,12 @@
FROM verdnatura/vn-mysql:latest
ENV MYSQL_ROOT_PASSWORD root
ENV TZ GMT-1
WORKDIR /docker-entrypoint-initdb.d
COPY install/ ./
COPY install ./
RUN chmod -R 777 .
RUN ./install.sh
CMD ./boot.sh
RUN mkdir /data
RUN chmod 777 /data
CMD ["mysqld"]
#HEALTHCHECK --interval=5s --timeout=10s --retries=200 \
# CMD mysqladmin ping -h 127.0.0.1 -u root || exit 1
EXPOSE 3306

View File

@ -1,8 +1,26 @@
#!/bin/bash
find /var/lib/mysql -type f -exec touch {} \; && service mysql start
if [ -d /data/mysql ]; then
cp -R /data/mysql /var/lib
echo "Restored database to default state"
else
# Disable SQL strict mode
mysql -u root -proot -e "SET GLOBAL sql_mode='NO_ENGINE_SUBSTITUTION';"
# Dump structure
for file in dump/*-*.sql; do
echo "Imported $file"
mysql -u root -proot < $file
done
sleep infinity
# Import changes
for file in changes/*/*.sql; do
echo "Imported $file"
mysql -u root -proot < $file
done
# Import fixtures
echo "Imported fixtures.sql"
mysql -u root -proot < dump/fixtures.sql
# Copy dumpted data to volume
cp -R /var/lib/mysql /data
fi

View File

@ -1,27 +0,0 @@
#!/bin/bash
# Start MySQL service
find /var/lib/mysql -type f -exec touch {} \; && service mysql start
# Disable SQL strict mode
mysql -u root -proot -e "SET GLOBAL sql_mode='NO_ENGINE_SUBSTITUTION';"
# Dump structure
for file in dump/*-*.sql; do
echo "Imported $file"
mysql -u root -proot < $file
done
# Import changes
for file in changes/*/*.sql; do
echo "Imported $file"
mysql -u root -proot < $file
done
# Import fixtures
echo "Imported fixtures.sql"
mysql -u root -proot < dump/fixtures.sql
# Remove installation
rm -rf changes dump install.sh