1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-20 14:54:15 +01:00

(bug) run the upgrade commands w/ the appropriate user

This commit is contained in:
Sylvain 2022-06-14 16:25:36 +02:00
parent 9ba177bf7b
commit a5cdd33e0b

View File

@ -162,9 +162,9 @@ version_error()
# set $VERSION
version_check()
{
VERSION=$(docker-compose exec --user "$(id -u):$(id -g)" -T "$SERVICE" cat .fabmanager-version 2>/dev/null)
VERSION=$(docker-compose exec -T "$SERVICE" cat .fabmanager-version 2>/dev/null)
if [[ $? = 1 ]]; then
VERSION=$(docker-compose exec --user "$(id -u):$(id -g)" -T "$SERVICE" cat package.json | jq -r '.version')
VERSION=$(docker-compose exec -T "$SERVICE" cat package.json | jq -r '.version')
fi
target_version
if [ "$TARGET" = 'custom' ]; then return; fi
@ -227,7 +227,7 @@ compile_assets()
elevate_cmd chown "$(id -u):$(id -g)" public/new_packs
fi
# shellcheck disable=SC2068
if ! docker run --user "$(id -u):$(id -g)" --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; then
if ! docker run --user "0:0" --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; then
printf "\e[93m[ ⚠ ] Something may have went wrong while compiling the assets, please check the logs above.\e[39m\n"
[[ "$YES_ALL" = "true" ]] && confirm="y" || read -rp ":: Ignore and continue? (Y/n) " confirm </dev/tty
if [[ "$confirm" = "n" ]]; then restore_tag; echo "Exiting..."; exit 4; fi
@ -284,21 +284,21 @@ upgrade()
done
for PRE in "${PREPROCESSING[@]}"; do
printf "\e[91m::\e[0m \e[1mRunning preprocessing command %s...\e[0m\n" "$PRE"
if ! docker-compose run --user "$(id -u):$(id -g)" --rm "$SERVICE" bundle exec "$PRE" </dev/tty; then
if ! docker-compose run --rm "$SERVICE" bundle exec "$PRE" </dev/tty; then
restore_tag
printf "\e[91m[ ❌ ] Something went wrong while running \"%s\", please check the logs above.\e[39m\nExiting...\n" "$PRE"
exit 4
fi
done
compile_assets
if ! docker-compose run --user "$(id -u):$(id -g)" --rm "$SERVICE" bundle exec rake db:migrate; then
if ! docker-compose run --rm "$SERVICE" bundle exec rake db:migrate; then
restore_tag
printf "\e[91m[ ❌ ] Something went wrong while migrating the database, please check the logs above.\e[39m\nExiting...\n"
exit 4
fi
for COMMAND in "${COMMANDS[@]}"; do
printf "\e[91m::\e[0m \e[1mRunning command %s...\e[0m\n" "$COMMAND"
if ! docker-compose run --user "$(id -u):$(id -g)" --rm "$SERVICE" bundle exec "$COMMAND" </dev/tty; then
if ! docker-compose run --rm "$SERVICE" bundle exec "$COMMAND" </dev/tty; then
restore_tag
printf "\e[91m[ ❌ ] Something went wrong while running \"%s\", please check the logs above.\e[39m\nExiting...\n" "$COMMAND"
exit 4