Skip to content

Instantly share code, notes, and snippets.

@fkaminski fkaminski/
Last active Dec 28, 2018

What would you like to do?
Contao-Docker-Tutorial -
### Include
### Due to possible file permission issues we mount the _backup folder in docker-composer.yml
### So we do not use the 'docker cp' command here - instead copy files in the container
echo -e $COL_START
echo -e " [STEP-1] Copy Contao composer.json file from Container $BACKUP_DIR directory"'\e[K'
echo -e $COL_STEP
eval 'docker exec -u '$CONTAINER_USER' '$CONTAINER_CONTAO' cp '$BACKUP_DIR'/composer.json .'
#eval 'docker exec -u '$CONTAINER_USER' '$CONTAINER_CONTAO' cp '$BACKUP_DIR'/composer.lock .'
echo -e $COL_START
echo -e " [STEP-2] Copy Contao config files from Container $BACKUP_DIR directory"'\e[K'
echo -e $COL_STEP
eval 'docker exec -u '$CONTAINER_USER' '$CONTAINER_CONTAO' mkdir -p app/config/'
eval 'docker exec -u '$CONTAINER_USER' '$CONTAINER_CONTAO' cp '$BACKUP_DIR'/parameters.yml app/config/'
eval 'docker exec -u '$CONTAINER_USER' '$CONTAINER_CONTAO' cp '$BACKUP_DIR'/localconfig.php system/config/'
### Default: Contao cache clear/warmup only
### Call with -u or --update parameter to do a composer update
case "$1" in
echo -e $COL_START
echo -e " [STEP-3] Composer Update"'\e[K'
echo -e $COL_END
eval 'docker exec -t -u '$CONTAINER_USER' '$CONTAINER_CONTAO' composer update'
echo -e $COL_START
echo -e " [STEP-3] Contao Cache Clear/Warmup for prod environment"'\e[K'
echo -e $COL_STEP
eval 'docker exec -t -u '$CONTAINER_USER' '$CONTAINER_CONTAO' php vendor/bin/contao-console cache:clear'
eval 'docker exec -t -u '$CONTAINER_USER' '$CONTAINER_CONTAO' php vendor/bin/contao-console cache:warmup'
eval 'docker exec -t -u '$CONTAINER_USER' '$CONTAINER_CONTAO' php vendor/bin/contao-console contao:symlinks'
### Timing issue: mysql is possibly not yet started after running "docker-compose up -d"
### See
while ! docker exec $CONTAINER_DB mysql -u $GLOBAL_PASS_NAME --password=$GLOBAL_PASS_NAME -e "SELECT 1" >/dev/null 2>&1; do
echo -e "\e[92m Waiting for mysql to start ... \e[m"
sleep 10
echo -e $COL_START
echo -e " [STEP-4] Import DB Dump from Container $BACKUP_DIR directory"'\e[K'
echo -e $COL_END
eval 'docker exec -i '$CONTAINER_DB' mysql -u '$GLOBAL_PASS_NAME' --password='$GLOBAL_PASS_NAME' '$GLOBAL_PASS_NAME' < '$BACKUP_DIR'/db_'$PROJECT_NAME'.sql'
#eval 'gzip --decompress < '$BACKUP_DIR'/db_'$PROJECT_NAME'.zip | docker exec -i '$CONTAINER_DB' mysql -u '$GLOBAL_PASS_NAME' --password='$GLOBAL_PASS_NAME' '$GLOBAL_PASS_NAME''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.