-
Notifications
You must be signed in to change notification settings - Fork 11
Feat/ghcr static build #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+352
−43
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8b5ef4b
Add Nextcloud upgrade hooks and Redis support
henmohr be81860
Align upgrade hooks with maintenance flow
henmohr 86691e5
fix backup dump handling
henmohr deb2f8e
fix backups bind mount
henmohr 3c1a38e
fix backups mount path
henmohr 1e1777e
test backup dir handling
henmohr 378e994
fix ghcr static tags
henmohr 6147de8
change to stable-fpm image version
henmohr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,6 @@ | ||
| /volumes | ||
| /backups/* | ||
| !/backups/ | ||
| !/backups/.gitkeep | ||
| .env | ||
| docker-compose.override.yml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| backup_dir=${NEXTCLOUD_BACKUP_DIR:-/backups} | ||
|
|
||
| cleanup() { | ||
| php occ maintenance:mode --off >/dev/null 2>&1 || true | ||
| } | ||
|
|
||
| trap cleanup EXIT | ||
|
|
||
| run_occ() { | ||
| echo "Running: php occ $*" | ||
| php occ "$@" | ||
| } | ||
|
|
||
| echo "Running post-upgrade Nextcloud commands" | ||
| php occ app:list > "$backup_dir/app_list.new" | ||
| if [ -f "$backup_dir/app_list.old" ]; then | ||
| echo "Comparing app lists" | ||
| diff -u "$backup_dir/app_list.old" "$backup_dir/app_list.new" || true | ||
| fi | ||
| run_occ db:add-missing-columns | ||
| run_occ db:add-missing-indices | ||
| run_occ db:add-missing-primary-keys | ||
| run_occ maintenance:repair --include-expensive | ||
| run_occ config:system:set maintenance_window_start --type=integer --value=1 | ||
| run_occ app:update --all | ||
| echo "Post-upgrade commands completed successfully" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| nextcloud_dir=${NEXTCLOUD_DIR:-/var/www/html} | ||
| backup_dir=${NEXTCLOUD_BACKUP_DIR:-/backups} | ||
| min_free_mb=${NEXTCLOUD_UPGRADE_MIN_FREE_MB:-2048} | ||
| db_host=${POSTGRES_HOST:-postgres} | ||
| db_name=${POSTGRES_DB:-nextcloud} | ||
| db_user=${POSTGRES_USER:-nextcloud} | ||
| db_password=${POSTGRES_PASSWORD:-} | ||
| backup_file="${backup_dir}/nextcloud-db.sql.gz" | ||
| backup_tmp_file="${backup_file}.tmp" | ||
| app_list_file="${backup_dir}/app_list.old" | ||
| maintenance_enabled=0 | ||
|
|
||
| cleanup() { | ||
| if [ "$maintenance_enabled" -eq 1 ]; then | ||
| php occ maintenance:mode --off >/dev/null 2>&1 || true | ||
| fi | ||
|
|
||
| rm -f "$backup_tmp_file" | ||
| } | ||
|
|
||
| trap cleanup EXIT | ||
|
|
||
| run_occ() { | ||
| echo "Running: php occ $*" | ||
| php occ "$@" | ||
| } | ||
|
|
||
| check_free_space() { | ||
| local path=$1 | ||
| local label=$2 | ||
| local available_mb | ||
|
|
||
| available_mb=$(df -Pm "$path" | awk 'NR==2 { print $4 }') | ||
|
|
||
| if [ "$available_mb" -lt "$min_free_mb" ]; then | ||
| echo "Not enough disk space on ${label}: ${available_mb} MB available, ${min_free_mb} MB required" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "${label} has ${available_mb} MB free" | ||
| } | ||
|
|
||
| echo "Running pre-upgrade safety checks" | ||
| mkdir -p "$backup_dir" | ||
|
|
||
| run_occ maintenance:mode --on | ||
| maintenance_enabled=1 | ||
| php occ app:list > "$app_list_file" | ||
| echo "Saved active apps list to ${app_list_file}" | ||
|
|
||
| check_free_space "$nextcloud_dir" "Nextcloud volume" | ||
| check_free_space "$backup_dir" "Backup volume" | ||
|
|
||
| if ! command -v pg_dump >/dev/null 2>&1; then | ||
| echo "pg_dump is not available in the container image" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ -z "$db_password" ]; then | ||
| echo "POSTGRES_PASSWORD is empty, refusing to create a database dump" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Creating PostgreSQL dump at ${backup_file}" | ||
| PGPASSWORD="$db_password" pg_dump -h "$db_host" -U "$db_user" "$db_name" | gzip -9 > "$backup_tmp_file" | ||
| mv "$backup_tmp_file" "$backup_file" | ||
| rm -f "$backup_tmp_file" | ||
| echo "Database dump completed successfully" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this cleanup trap runs on every exit, a successful pre-upgrade turns maintenance mode off immediately after creating the dump. The Nextcloud Docker entrypoint runs
pre-upgradebefore itsocc upgradestep andpost-upgradeafter that step, so this defeats the documented flow where pre-upgrade enables maintenance and post-upgrade disables it; the instance can be available during the upgrade gap and the post-upgrade repair/app-update commands run without maintenance mode.Useful? React with 👍 / 👎.