1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-19 13:54:25 +01:00

Check postgreSQL status before compiling assets

This commit is contained in:
Sylvain 2020-10-23 12:15:25 +02:00
parent 01524da0ab
commit 2d1a2d81dd
2 changed files with 8 additions and 3 deletions

View File

@ -1,6 +1,7 @@
# Changelog Fab-manager
- Add intermediate step version for upgrades: v4.4.6. This will prevent issues with FootprintDebug if a regeneration is needed
- Check postgreSQL status before compiling assets
- Fix a bug: unable to set libraries locales to their default values (en-us)
- Fix a bug: unable to display details about a closed period

View File

@ -102,17 +102,20 @@ add_environments()
done
}
compile_assets_and_migrate()
compile_assets()
{
IMAGE=$(yq r docker-compose.yml 'services.*(.==sleede/fab-manager*)')
mapfile -t COMPOSE_ENVS < <(yq r docker-compose.yml "services.$SERVICE.environment")
ENV_ARGS=$(for i in "${COMPOSE_ENVS[@]}"; do sed 's/: /=/g;s/^/-e /g' <<< "$i"; done)
PG_ID=$(docker-compose ps -q postgres)
if [[ "$PG_ID" = "" ]]; then
printf "PostgreSQL container is not running, unable to compile the assets\nExiting..."
exit 1
fi
PG_NET_ID=$(docker inspect "$PG_ID" -f "{{json .NetworkSettings.Networks }}" | jq -r '.[] .NetworkID')
# shellcheck disable=SC2068
docker run --rm --env-file ./config/env ${ENV_ARGS[@]} --link "$PG_ID" --net "$PG_NET_ID" -v "${PWD}/public/new_packs:/usr/src/app/public/packs" "$IMAGE" bundle exec rake assets:precompile
docker-compose down
docker-compose run --rm "$SERVICE" bundle exec rake db:migrate
rm -rf public/packs
mv public/new_packs public/packs
}
@ -136,7 +139,8 @@ upgrade()
\curl -sSL "https://raw.githubusercontent.com/sleede/fab-manager/$BRANCH/scripts/$SCRIPT.sh" | bash
fi
done
compile_assets_and_migrate
compile_assets
docker-compose run --rm "$SERVICE" bundle exec rake db:migrate
for COMMAND in "${COMMANDS[@]}"; do
docker-compose run --rm "$SERVICE" bundle exec "$COMMAND"
done