diff --git a/snap/hooks/post-refresh b/snap/hooks/post-refresh index a60b87a..86a2c11 100644 --- a/snap/hooks/post-refresh +++ b/snap/hooks/post-refresh @@ -2,7 +2,6 @@ . "$SNAP/snap.env" set_default_settings -reset_migrations_required export CURRENT_SNAP_VERSION="$(get_snap_version_file)" @@ -58,6 +57,7 @@ copy_config_as_daemon_user redis redis.conf # Mastodon . "$SNAP/mastodon.env" +reset_migrations_required # NOTE: This is a fix for older versions and may be removed in the future echo Set permissions on mastodon files and dirs diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 76d8a56..d383181 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -795,7 +795,8 @@ parts: - GEM_HOME: $CRAFT_PART_BUILD/vendor/ruby - GEM_PATH: $GEM_HOME - YARN_RC_FILENAME: $CRAFT_PART_BUILD/.yarnrc.yml - - YARN_CACHE_FOLDER: /tmp/yarn/cache + - YARN_CACHE_FOLDER: /tmp/yarn + - COREPACK_HOME: /tmp/corepack - MASTODON_USE_LIBVIPS: "true" # NOTE: workaround for current issue (see https://github.com/mastodon/mastodon/releases/tag/v4.3.0-beta.1) - BUNDLE_BUILD__CHARLOCK_HOLMES: "--with-cxxflags=-std=c++17" @@ -809,11 +810,11 @@ parts: bundle config build.pg --with-pg-config=$CRAFT_STAGE/postgres/bin/pg_config bundle install -j"$(nproc)" + mkdir -p $COREPACK_HOME $YARN_CACHE_FOLDER corepack enable corepack prepare --activate - mkdir -p $YARN_CACHE_FOLDER - yarn set version $YARN_VERSION - yarn install --immutable + corepack yarn set version $YARN_VERSION + corepack yarn install --immutable npx update-browserslist-db@latest yarn cache clean npm cache clean --force @@ -945,7 +946,8 @@ parts: - GEM_HOME: $CRAFT_STAGE/mastodon/vendor/ruby - GEM_PATH: $GEM_HOME - YARN_RC_FILENAME: $CRAFT_STAGE/mastodon/.yarnrc.yml - - YARN_CACHE_FOLDER: /tmp/yarn/cache + - YARN_CACHE_FOLDER: /tmp/yarn + - COREPACK_HOME: /tmp/corepack - OTP_SECRET: precompile_placeholder - SECRET_KEY_BASE: precompile_placeholder - ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY: precompile_placeholder @@ -953,7 +955,6 @@ parts: - ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY: precompile_placeholder override-build: | set -eux - mkdir -p $YARN_CACHE_FOLDER cd $CRAFT_STAGE/mastodon bundle exec rails assets:precompile bundle exec rails log:clear tmp:clear diff --git a/src/mastodon/bin/recompile b/src/mastodon/bin/recompile index d1401c5..b754320 100755 --- a/src/mastodon/bin/recompile +++ b/src/mastodon/bin/recompile @@ -2,7 +2,5 @@ . "$SNAP/mastodon.env" -mkdir_as_daemon_user "$YARN_CACHE_FOLDER" - echo "Recompile assets (this takes some time)" mastodon_rails assets:precompile && mastodon_rails log:clear tmp:clear diff --git a/src/mastodon/bin/restore b/src/mastodon/bin/restore index 508df7e..dc6481b 100755 --- a/src/mastodon/bin/restore +++ b/src/mastodon/bin/restore @@ -58,7 +58,7 @@ echo Restore database $SNAP/bin/psql.wrapper -f "$backup_dir/database.sql" template1 > /dev/null if [ "$BACKUP_VERSION" != "$SNAP_VERSION" ]; then echo Migrate database - $SNAP/bin/migrate > /dev/null + mastodon_db_migrate fi if [ -f "$backup_dir/redis.rdb" ]; then diff --git a/src/mastodon/bin/streaming b/src/mastodon/bin/streaming index 0c7e641..ce31854 100755 --- a/src/mastodon/bin/streaming +++ b/src/mastodon/bin/streaming @@ -8,5 +8,5 @@ redis_waitready export DB_POOL=25 export MALLOC_ARENA_MAX=2 -mastodon_node streaming \ +mastodon_streaming \ 2>&1 | tee -a "$LOG_DIR/streaming.log" diff --git a/src/mastodon/bin/yarn b/src/mastodon/bin/yarn index 7abec13..0050ecd 100755 --- a/src/mastodon/bin/yarn +++ b/src/mastodon/bin/yarn @@ -2,4 +2,7 @@ . "$SNAP/mastodon.env" +mkdir_as_daemon_user "$COREPACK_HOME" +mkdir_as_daemon_user "$YARN_CACHE_FOLDER" + cd "$MASTODON_DIR" && corepack yarn "$@" diff --git a/src/mastodon/mastodon.env b/src/mastodon/mastodon.env index 69589d9..854b722 100644 --- a/src/mastodon/mastodon.env +++ b/src/mastodon/mastodon.env @@ -23,8 +23,9 @@ export BUNDLE_RAKEFILE="$MASTODON_DIR/Rakefile" export GEM_HOME="$MASTODON_DIR/vendor/ruby" export GEM_PATH="$GEM_HOME" export YARN_RC_FILENAME="$MASTODON_DIR/.yarnrc.yml" -export YARN_CACHE_FOLDER=/tmp/yarn/cache +export YARN_CACHE_FOLDER="$MASTODON_DIR/.cache/yarn" export YARN_IGNORE_PATH=1 +export COREPACK_HOME="$MASTODON_DIR/.cache/corepack" export UPDATE_BACKUPS="$(snapctl get update.backups)" export MEDIA_DIR="$(snapctl get media.dir)" @@ -94,13 +95,8 @@ mastodon_rails() { cd "$MASTODON_DIR" && run_as_daemon_user bundle exec rails "$@" } -mastodon_node() { - cd "$MASTODON_DIR" && run_as_daemon_user node "$@" -} - -mastodon_yarn() { - mkdir -p "$YARN_CACHE_FOLDER" - cd "$MASTODON_DIR" && run_as_daemon_user yarn "$@" +mastodon_streaming() { + cd "$MASTODON_DIR" && run_as_daemon_user node streaming "$@" } mastodon_sidekiq() {