From 5d090018f98c19b353d7e68ef15423ba0cc1be19 Mon Sep 17 00:00:00 2001 From: "Simon L." Date: Tue, 25 Mar 2025 09:13:06 +0100 Subject: [PATCH] move images to ghcr.io Signed-off-by: Simon L. --- .github/workflows/playwright.yml | 6 ++--- .github/workflows/update-helm.yml | 3 ++- Containers/mastercontainer/start.sh | 6 ++--- develop.md | 2 +- php/containers.json | 34 +++++++++++++------------- php/src/Docker/DockerActionManager.php | 30 +++++++++++++++++++++-- 6 files changed, 54 insertions(+), 27 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index dfa6ad7e..67653783 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -29,7 +29,7 @@ jobs: run: | docker rm --force nextcloud-aio-{mastercontainer,apache,notify-push,nextcloud,redis,database,domaincheck,whiteboard,imaginary,talk,collabora,borgbackup} || true docker volume rm nextcloud_aio_{mastercontainer,apache,database,database_dump,nextcloud,nextcloud_data,redis,backup_cache,elasticsearch} || true - docker pull nextcloud/all-in-one:develop + docker pull ghcr.io/nextcloud-releases/all-in-one:develop docker run \ -d \ --init \ @@ -40,7 +40,7 @@ jobs: --volume /var/run/docker.sock:/var/run/docker.sock:ro \ --env SKIP_DOMAIN_VALIDATION=true \ --env APACHE_PORT=11000 \ - nextcloud/all-in-one:develop + ghcr.io/nextcloud-releases/all-in-one:develop echo Waiting for 10 seconds for the development container to start ... sleep 10 @@ -61,7 +61,7 @@ jobs: --volume /var/run/docker.sock:/var/run/docker.sock:ro \ --env SKIP_DOMAIN_VALIDATION=false \ --env APACHE_PORT=11000 \ - nextcloud/all-in-one:develop + ghcr.io/nextcloud-releases/all-in-one:develop echo Waiting for 10 seconds for the development container to start ... sleep 10 diff --git a/.github/workflows/update-helm.yml b/.github/workflows/update-helm.yml index 3065c4a9..83c35135 100644 --- a/.github/workflows/update-helm.yml +++ b/.github/workflows/update-helm.yml @@ -14,7 +14,8 @@ jobs: uses: actions/checkout@v4 - name: update helm chart run: | - DOCKER_TAG="$(curl -L -s 'https://registry.hub.docker.com/v2/repositories/nextcloud/all-in-one/tags?page_size=1024' | jq '."results"[]["name"]' | sed 's|"||g' | grep '^20[0-9_]\+' | grep -v latest | sort -r | head -1)" + GHCR_TOKEN="$(curl https://ghcr.io/token\?scope\="repository:nextcloud-releases/all-in-one:pull" | jq '.token')" + DOCKER_TAG="$(curl -H "Authorization: Bearer ${GHCR_TOKEN}" -L -s 'https://ghcr.io/v2/nextcloud-releases/all-in-one/tags/list?page_size=1024' | jq '.tags' | sed 's|"||g' | grep '^20[0-9_]\+' | grep -v latest | sort -r | head -1)" export DOCKER_TAG if [ -n "$DOCKER_TAG" ] && ! grep -q "$DOCKER_TAG" ./nextcloud-aio-helm-chart/templates/nextcloud-aio-nextcloud-deployment.yaml; then sudo bash nextcloud-aio-helm-chart/update-helm.sh "$DOCKER_TAG" diff --git a/Containers/mastercontainer/start.sh b/Containers/mastercontainer/start.sh index bca074ae..1a455626 100644 --- a/Containers/mastercontainer/start.sh +++ b/Containers/mastercontainer/start.sh @@ -283,10 +283,10 @@ if [ "$?" = 6 ]; then exit 1 fi -# Check if auth.docker.io is reachable +# Check if ghcr.io is reachable # Solves issues like https://github.com/nextcloud/all-in-one/discussions/5268 -if ! curl https://auth.docker.io/token 2>&1 | grep -q token; then - print_red "Could not reach https://auth.docker.io." +if ! curl https://ghcr.io 2>&1; then + print_red "Could not reach https://ghcr.io." echo "Most likely is something blocking access to it." echo "You should be able to fix this by using https://github.com/nextcloud/all-in-one/tree/main/manual-install" exit 1 diff --git a/develop.md b/develop.md index a35a521c..6f84b2d4 100644 --- a/develop.md +++ b/develop.md @@ -11,7 +11,7 @@ sudo docker run \ --publish 8443:8443 \ --volume nextcloud_aio_mastercontainer:/mnt/docker-aio-config \ --volume /var/run/docker.sock:/var/run/docker.sock:ro \ -nextcloud/all-in-one:develop +ghcr.io/nextcloud-releases/all-in-one:develop ``` And you are done :) It will now also select the developer channel for all other containers automatically. diff --git a/php/containers.json b/php/containers.json index 4f218af2..d87fe9ca 100644 --- a/php/containers.json +++ b/php/containers.json @@ -13,7 +13,7 @@ "nextcloud-aio-whiteboard" ], "display_name": "Apache", - "image": "nextcloud/aio-apache", + "image": "ghcr.io/nextcloud-releases/aio-apache", "user": "33", "init": true, "healthcheck": { @@ -84,7 +84,7 @@ "container_name": "nextcloud-aio-database", "image_tag": "%AIO_CHANNEL%", "display_name": "Database", - "image": "nextcloud/aio-postgresql", + "image": "ghcr.io/nextcloud-releases/aio-postgresql", "user": "999", "init": true, "healthcheck": { @@ -149,7 +149,7 @@ "nextcloud-aio-docker-socket-proxy" ], "display_name": "Nextcloud", - "image": "nextcloud/aio-nextcloud", + "image": "ghcr.io/nextcloud-releases/aio-nextcloud", "init": true, "healthcheck": { "start_period": "0s", @@ -271,7 +271,7 @@ "container_name": "nextcloud-aio-notify-push", "image_tag": "%AIO_CHANNEL%", "display_name": "Notify Push", - "image": "nextcloud/aio-notify-push", + "image": "ghcr.io/nextcloud-releases/aio-notify-push", "user": "33", "init": true, "healthcheck": { @@ -319,7 +319,7 @@ "container_name": "nextcloud-aio-redis", "image_tag": "%AIO_CHANNEL%", "display_name": "Redis", - "image": "nextcloud/aio-redis", + "image": "ghcr.io/nextcloud-releases/aio-redis", "user": "999", "init": true, "healthcheck": { @@ -361,7 +361,7 @@ "image_tag": "%AIO_CHANNEL%", "documentation": "https://github.com/nextcloud/all-in-one/discussions/1358", "display_name": "Collabora", - "image": "nextcloud/aio-collabora", + "image": "ghcr.io/nextcloud-releases/aio-collabora", "init": true, "healthcheck": { "start_period": "60s", @@ -404,7 +404,7 @@ "image_tag": "%AIO_CHANNEL%", "documentation": "https://github.com/nextcloud/all-in-one/discussions/1358", "display_name": "Talk", - "image": "nextcloud/aio-talk", + "image": "ghcr.io/nextcloud-releases/aio-talk", "user": "1000", "init": true, "healthcheck": { @@ -466,7 +466,7 @@ "container_name": "nextcloud-aio-talk-recording", "image_tag": "%AIO_CHANNEL%", "display_name": "Talk Recording", - "image": "nextcloud/aio-talk-recording", + "image": "ghcr.io/nextcloud-releases/aio-talk-recording", "user": "122", "init": true, "healthcheck": { @@ -518,7 +518,7 @@ { "container_name": "nextcloud-aio-borgbackup", "image_tag": "%AIO_CHANNEL%", - "image": "nextcloud/aio-borgbackup", + "image": "ghcr.io/nextcloud-releases/aio-borgbackup", "init": true, "environment": [ "BORG_REMOTE_REPO=%BORGBACKUP_REMOTE_REPO%", @@ -586,7 +586,7 @@ { "container_name": "nextcloud-aio-watchtower", "image_tag": "%AIO_CHANNEL%", - "image": "nextcloud/aio-watchtower", + "image": "ghcr.io/nextcloud-releases/aio-watchtower", "init": true, "environment": [ "CONTAINER_TO_UPDATE=nextcloud-aio-mastercontainer" @@ -606,7 +606,7 @@ { "container_name": "nextcloud-aio-domaincheck", "image_tag": "%AIO_CHANNEL%", - "image": "nextcloud/aio-domaincheck", + "image": "ghcr.io/nextcloud-releases/aio-domaincheck", "init": true, "ports": [ { @@ -637,7 +637,7 @@ "container_name": "nextcloud-aio-clamav", "image_tag": "%AIO_CHANNEL%", "display_name": "ClamAV", - "image": "nextcloud/aio-clamav", + "image": "ghcr.io/nextcloud-releases/aio-clamav", "user": "100", "init": false, "healthcheck": { @@ -683,7 +683,7 @@ "container_name": "nextcloud-aio-onlyoffice", "image_tag": "%AIO_CHANNEL%", "display_name": "OnlyOffice", - "image": "nextcloud/aio-onlyoffice", + "image": "ghcr.io/nextcloud-releases/aio-onlyoffice", "init": true, "healthcheck": { "start_period": "60s", @@ -729,7 +729,7 @@ "container_name": "nextcloud-aio-imaginary", "image_tag": "%AIO_CHANNEL%", "display_name": "Imaginary", - "image": "nextcloud/aio-imaginary", + "image": "ghcr.io/nextcloud-releases/aio-imaginary", "user": "65534", "init": true, "healthcheck": { @@ -771,7 +771,7 @@ "image_tag": "%AIO_CHANNEL%", "documentation": "https://github.com/nextcloud/all-in-one/discussions/1709", "display_name": "Fulltextsearch", - "image": "nextcloud/aio-fulltextsearch", + "image": "ghcr.io/nextcloud-releases/aio-fulltextsearch", "init": false, "healthcheck": { "start_period": "60s", @@ -819,7 +819,7 @@ "container_name": "nextcloud-aio-docker-socket-proxy", "image_tag": "%AIO_CHANNEL%", "display_name": "Docker Socket Proxy", - "image": "nextcloud/aio-docker-socket-proxy", + "image": "ghcr.io/nextcloud-releases/aio-docker-socket-proxy", "init": true, "internal_port": "2375", "environment": [ @@ -845,7 +845,7 @@ "container_name": "nextcloud-aio-whiteboard", "image_tag": "%AIO_CHANNEL%", "display_name": "Whiteboard", - "image": "nextcloud/aio-whiteboard", + "image": "ghcr.io/nextcloud-releases/aio-whiteboard", "user": "65534", "init": true, "healthcheck": { diff --git a/php/src/Docker/DockerActionManager.php b/php/src/Docker/DockerActionManager.php index 643b0f0e..bbcd4b77 100644 --- a/php/src/Docker/DockerActionManager.php +++ b/php/src/Docker/DockerActionManager.php @@ -742,6 +742,33 @@ readonly class DockerActionManager { } } + private function GetCurrentImageName(): string { + $cacheKey = 'aio-image-name'; + $imageName = apcu_fetch($cacheKey); + if ($imageName !== false && is_string($imageName)) { + return $imageName; + } + + $containerName = 'nextcloud-aio-mastercontainer'; + $url = $this->BuildApiUrl(sprintf('containers/%s/json', $containerName)); + try { + $output = json_decode($this->guzzleClient->get($url)->getBody()->getContents(), true); + $imageNameArray = explode(':', $output['Config']['Image']); + if (count($imageNameArray) === 2) { + $imageName = $imageNameArray[0]; + } else { + error_log("No tag was found when getting the current channel. You probably did not follow the documentation correctly. Changing the imageName to the default " . $output['Config']['Image']); + $imageName = $output['Config']['Image']; + } + apcu_add($cacheKey, $imageName); + return $imageName; + } catch (\Exception $e) { + error_log('Could not get current imageName ' . $e->getMessage()); + } + + return 'nextcloud/all-in-one'; + } + public function GetCurrentChannel(): string { $cacheKey = 'aio-ChannelName'; $channelName = apcu_fetch($cacheKey); @@ -753,7 +780,6 @@ readonly class DockerActionManager { $url = $this->BuildApiUrl(sprintf('containers/%s/json', $containerName)); try { $output = json_decode($this->guzzleClient->get($url)->getBody()->getContents(), true); - $containerChecksum = $output['Image']; $tagArray = explode(':', $output['Config']['Image']); if (count($tagArray) === 2) { $tag = $tagArray[1]; @@ -771,7 +797,7 @@ readonly class DockerActionManager { } public function IsMastercontainerUpdateAvailable(): bool { - $imageName = 'nextcloud/all-in-one'; + $imageName = $this->GetCurrentImageName(); $containerName = 'nextcloud-aio-mastercontainer'; $tag = $this->GetCurrentChannel();