From 36b4dc2317fca28c5bdf86357a0dfe69706e3bc7 Mon Sep 17 00:00:00 2001 From: Shawn Date: Fri, 17 Mar 2023 08:00:35 -0400 Subject: [PATCH 01/11] Create .github/workflows/docker-image.yml --- .github/workflows/docker-image.yml | 69 ++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 .github/workflows/docker-image.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..086c2c6 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,69 @@ +name: Docker Image CI + +on: + push: + branches: [ "master" ] + +permissions: + packages: write + +jobs: + + build: + + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Docker Metadata action + uses: docker/metadata-action@v4.3.0 + with: + images: | + ${{ secrets.DOCKERHUB_USERNAME }}/rdt-client + ghcr.io/${{ secrets.DOCKERHUB_USERNAME }}/rdt-client + tags: | + type=schedule + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha + # List of custom labels + # labels: # optional + + - name: Docker Setup QEMU + uses: docker/setup-qemu-action@v2.1.0 + + - name: Docker Setup Buildx + uses: docker/setup-buildx-action@v2.5.0 + with: + buildkitd-flags: --debug + + - name: Docker Login + if: github.event_name != 'pull_request' + uses: docker/login-action@v2.1.0 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Login to GHCR + if: github.event_name != 'pull_request' + uses: docker/login-action@v2.1.0 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker images + uses: docker/build-push-action@v4.0.0 + with: + context: . + file: ./Dockerfile.dev + platforms: "linux/arm/v7,linux/arm64/v8,linux/amd64" + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + From db30217509b113ba21edc1978d9779876e27240e Mon Sep 17 00:00:00 2001 From: Shawn Date: Fri, 17 Mar 2023 08:02:01 -0400 Subject: [PATCH 02/11] Update docker-image.yml --- .github/workflows/docker-image.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 086c2c6..b607acb 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -18,6 +18,7 @@ jobs: uses: actions/checkout@v3 - name: Docker Metadata action + id: meta uses: docker/metadata-action@v4.3.0 with: images: | From 0d9792787e8e521502b64f94557cf70b2ecc1dd4 Mon Sep 17 00:00:00 2001 From: Shawn Anderson Date: Fri, 17 Mar 2023 08:05:32 -0400 Subject: [PATCH 03/11] Added support to change how docker progress is output to console --- docker-publish.ps1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docker-publish.ps1 b/docker-publish.ps1 index 3e88b62..c5af570 100755 --- a/docker-publish.ps1 +++ b/docker-publish.ps1 @@ -38,12 +38,13 @@ param( [string]$Dockerfile = "Dockerfile", [switch]$SkipPush, [switch]$SkipCache, - [switch]$OutputToDocker + [switch]$OutputToDocker, + [string]$BuildProgress="auto" ) $imageName = "$($DockerAccount)/rdtclient" -$dockerArgs = @( "buildx", "build", "--network=default", "--platform", $Platforms, "--tag", "$($imageName):latest", "--file", $Dockerfile, "." ) +$dockerArgs = @( "buildx", "build", "--network=default", "--platform", $Platforms, "--progress=$BuildProgress", "--tag", "$($imageName):latest", "--file", $Dockerfile, "." ) if (-Not $SkipPush.IsPresent) { $dockerArgs += @("--push") From 158720e1140ef0783694685a8469ac6fc909526e Mon Sep 17 00:00:00 2001 From: Shawn Date: Fri, 17 Mar 2023 16:10:42 -0400 Subject: [PATCH 04/11] Update docker-image.yml --- .github/workflows/docker-image.yml | 36 +++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index b607acb..543b1e4 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -7,6 +7,12 @@ on: permissions: packages: write +env: + APP_NAME: rdt-client + DOCKER_FILE: ./Dockerfile + ENABLE_DOCKERHUB: FALSE + ENABLE_GHCR: TRUE + jobs: build: @@ -22,8 +28,8 @@ jobs: uses: docker/metadata-action@v4.3.0 with: images: | - ${{ secrets.DOCKERHUB_USERNAME }}/rdt-client - ghcr.io/${{ secrets.DOCKERHUB_USERNAME }}/rdt-client + # ${{ secrets.DOCKERHUB_USERNAME }}/$APP_NAME + ghcr.io/${{ secrets.DOCKERHUB_USERNAME }}/$APP_NAME tags: | type=schedule type=ref,event=branch @@ -44,14 +50,14 @@ jobs: buildkitd-flags: --debug - name: Docker Login - if: github.event_name != 'pull_request' + if: ${{ github.event_name != 'pull_request' && env.ENABLE_DOCKERHUB == TRUE }} uses: docker/login-action@v2.1.0 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Login to GHCR - if: github.event_name != 'pull_request' + if: ${{ github.event_name != 'pull_request' && env.ENABLE_GHCR == TRUE }} uses: docker/login-action@v2.1.0 with: registry: ghcr.io @@ -62,9 +68,29 @@ jobs: uses: docker/build-push-action@v4.0.0 with: context: . - file: ./Dockerfile.dev + file: $DOCKER_FILE platforms: "linux/arm/v7,linux/arm64/v8,linux/amd64" push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + - name: Docker Hub Registry Description + if: ${{ env.ENABLE_DOCKERHUB == TRUE }} + uses: peter-evans/dockerhub-description@v3.3.0 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + repository: ${{ secrets.DOCKERHUB_USERNAME }}/$APP_NAME + short-description: | + a web interface to manage your torrents on Real-Debrid, AllDebrid or Premiumize. + readme-filepath: ./README-DOCKER.md + + - name: Github Registry Description + if: ${{ env.ENABLE_GHCR == TRUE }} + uses: peter-evans/dockerhub-description@v3.3.0 + with: + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + short-description: | + A web interface to manage your torrents on Real-Debrid, AllDebrid or Premiumize. + readme-filepath: ./README-DOCKER.md From d55bb3ce233ad8422b0c6f0d40faa5cc57ceb3e6 Mon Sep 17 00:00:00 2001 From: Shawn Date: Fri, 17 Mar 2023 16:11:55 -0400 Subject: [PATCH 05/11] Update docker-image.yml --- .github/workflows/docker-image.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 543b1e4..910b95c 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -10,8 +10,8 @@ permissions: env: APP_NAME: rdt-client DOCKER_FILE: ./Dockerfile - ENABLE_DOCKERHUB: FALSE - ENABLE_GHCR: TRUE + ENABLE_DOCKERHUB: 0 + ENABLE_GHCR: 1 jobs: @@ -50,14 +50,14 @@ jobs: buildkitd-flags: --debug - name: Docker Login - if: ${{ github.event_name != 'pull_request' && env.ENABLE_DOCKERHUB == TRUE }} + if: ${{ github.event_name != 'pull_request' && env.ENABLE_DOCKERHUB == 1 }} uses: docker/login-action@v2.1.0 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Login to GHCR - if: ${{ github.event_name != 'pull_request' && env.ENABLE_GHCR == TRUE }} + if: ${{ github.event_name != 'pull_request' && env.ENABLE_GHCR == 1 }} uses: docker/login-action@v2.1.0 with: registry: ghcr.io @@ -75,7 +75,7 @@ jobs: labels: ${{ steps.meta.outputs.labels }} - name: Docker Hub Registry Description - if: ${{ env.ENABLE_DOCKERHUB == TRUE }} + if: ${{ env.ENABLE_DOCKERHUB == 1 }} uses: peter-evans/dockerhub-description@v3.3.0 with: username: ${{ secrets.DOCKERHUB_USERNAME }} @@ -86,7 +86,7 @@ jobs: readme-filepath: ./README-DOCKER.md - name: Github Registry Description - if: ${{ env.ENABLE_GHCR == TRUE }} + if: ${{ env.ENABLE_GHCR == 1 }} uses: peter-evans/dockerhub-description@v3.3.0 with: username: ${{ github.repository_owner }} From 0326bb277a7c3844aef20704b5c71b2df4a52424 Mon Sep 17 00:00:00 2001 From: Shawn Date: Fri, 17 Mar 2023 16:13:38 -0400 Subject: [PATCH 06/11] Update docker-image.yml --- .github/workflows/docker-image.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 910b95c..d4b9910 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -28,8 +28,8 @@ jobs: uses: docker/metadata-action@v4.3.0 with: images: | - # ${{ secrets.DOCKERHUB_USERNAME }}/$APP_NAME - ghcr.io/${{ secrets.DOCKERHUB_USERNAME }}/$APP_NAME + # ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.APP_NAME }} + ghcr.io/${{ secrets.DOCKERHUB_USERNAME }}/${{ env.APP_NAME }} tags: | type=schedule type=ref,event=branch @@ -68,7 +68,7 @@ jobs: uses: docker/build-push-action@v4.0.0 with: context: . - file: $DOCKER_FILE + file: ${{ env.DOCKER_FILE }} platforms: "linux/arm/v7,linux/arm64/v8,linux/amd64" push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} @@ -80,7 +80,7 @@ jobs: with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - repository: ${{ secrets.DOCKERHUB_USERNAME }}/$APP_NAME + repository: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.APP_NAME }} short-description: | a web interface to manage your torrents on Real-Debrid, AllDebrid or Premiumize. readme-filepath: ./README-DOCKER.md From 43172f2355337bf011174cadb3663efc0c1eb5e2 Mon Sep 17 00:00:00 2001 From: Shawn Anderson Date: Fri, 17 Mar 2023 16:25:22 -0400 Subject: [PATCH 07/11] Changed how buildx exports to local docker instance --- docker-publish.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-publish.ps1 b/docker-publish.ps1 index c5af570..63ef6a3 100755 --- a/docker-publish.ps1 +++ b/docker-publish.ps1 @@ -55,7 +55,7 @@ if ($SkipCache.IsPresent) { } if ($OutputToDocker.IsPresent) { - $dockerArgs += @("--output=type=docker") + $dockerArgs += @("--load") } if ([string]::IsNullOrEmpty($Version)) { From 2e8ed68ba50bc615d00df7156bec8dbc64045d24 Mon Sep 17 00:00:00 2001 From: Shawn Anderson Date: Fri, 17 Mar 2023 16:25:37 -0400 Subject: [PATCH 08/11] Cleanup --- docker-build-dev.ps1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docker-build-dev.ps1 b/docker-build-dev.ps1 index ca5ccaf..36115cd 100755 --- a/docker-build-dev.ps1 +++ b/docker-build-dev.ps1 @@ -20,11 +20,12 @@ docker rm rdtclientdev Write-Host "Building Container" $dockerArgs = @( "build", "--force-rm", "--tag", "rdtclientdev", "--progress=$BuildProgress", "--file", $Dockerfile, "." ) if ($SkipCache.IsPresent) { $dockerArgs += @("--no-cache" ) } + & docker $dockerArgs Write-Host "Starting Container" -docker run --cap-add=NET_ADMIN -d -v $downloadPath -v $dbPath --log-driver json-file --log-opt max-size=10m -p 6500:6500 --name rdtclientdev rdtclientdev +docker run --cap-add=NET_ADMIN -d -v $($downloadPath):/data/downloads -v $($dbPath):/data/db --log-driver json-file --log-opt max-size=10m -p 6500:6500 --name rdtclientdev rdtclientdev if ($AutoAttach.IsPresent) { docker exec -it rdtclientdev /bin/bash -} \ No newline at end of file +} From f01774fb7dbb83d71e85a274d20ac16a4900a426 Mon Sep 17 00:00:00 2001 From: Shawn Anderson Date: Fri, 17 Mar 2023 16:28:55 -0400 Subject: [PATCH 09/11] Updated dockerfile to use newer version of node image for building frontend. Updated dotnet restore/publish to not use a local cache. Changed s6-overlay dependency for initalizing rdt-client from legacy-services to init-mods --- Dockerfile | 8 ++++---- .../s6-rc.d/init-rdt-client/dependencies.d/init-mods | 0 2 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 root/etc/s6-overlay/s6-rc.d/init-rdt-client/dependencies.d/init-mods diff --git a/Dockerfile b/Dockerfile index fbf94b9..69b5f23 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Stage 1 - Build the frontend -FROM node:16-buster AS node-build-env +FROM node:16-alpine3.17 AS node-build-env ARG TARGETPLATFORM ENV TARGETPLATFORM=${TARGETPLATFORM:-linux/amd64} ARG BUILDPLATFORM @@ -35,13 +35,13 @@ RUN \ cd server && \ if [ "$TARGETPLATFORM" = "linux/arm/v7" ] ; then \ echo "**** Building $TARGETPLATFORM arm v7 version" && \ - dotnet restore -r linux-arm RdtClient.sln && dotnet publish -r linux-arm -c Release -o out ; \ + dotnet restore --no-cache -r linux-arm RdtClient.sln && dotnet publish --no-restore -r linux-arm -c Release -o out ; \ elif [ "$TARGETPLATFORM" = "linux/arm/v8" ] ; then \ echo "**** Building $TARGETPLATFORM arm v8 version" && \ - dotnet restore -r linux-arm64 RdtClient.sln && dotnet publish -r linux-arm64 -c Release -o out ; \ + dotnet restore --no-cache -r linux-arm64 RdtClient.sln && dotnet publish --no-restore -r linux-arm64 -c Release -o out ; \ else \ echo "**** Building $TARGETPLATFORM x64 version" && \ - dotnet restore RdtClient.sln && dotnet publish -c Release -o out ; \ + dotnet restore --no-cache RdtClient.sln && dotnet publish --no-restore -c Release -o out ; \ fi # Stage 3 - Build runtime image diff --git a/root/etc/s6-overlay/s6-rc.d/init-rdt-client/dependencies.d/init-mods b/root/etc/s6-overlay/s6-rc.d/init-rdt-client/dependencies.d/init-mods new file mode 100644 index 0000000..e69de29 From 2f30cb52237d2d94f7f618c958272bff5518126a Mon Sep 17 00:00:00 2001 From: Shawn Anderson Date: Fri, 17 Mar 2023 17:09:07 -0400 Subject: [PATCH 10/11] Updated workflow --- .github/workflows/docker-image.yml | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index d4b9910..c2a6ced 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -3,6 +3,8 @@ name: Docker Image CI on: push: branches: [ "master" ] + tags: + - v* permissions: packages: write @@ -10,6 +12,7 @@ permissions: env: APP_NAME: rdt-client DOCKER_FILE: ./Dockerfile + DOCKER_PLATFORMS: "linux/arm/v7,linux/arm64/v8,linux/amd64" ENABLE_DOCKERHUB: 0 ENABLE_GHCR: 1 @@ -69,7 +72,7 @@ jobs: with: context: . file: ${{ env.DOCKER_FILE }} - platforms: "linux/arm/v7,linux/arm64/v8,linux/amd64" + platforms: ${{ env.DOCKER_PLATFORMS }} push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} @@ -85,12 +88,12 @@ jobs: a web interface to manage your torrents on Real-Debrid, AllDebrid or Premiumize. readme-filepath: ./README-DOCKER.md - - name: Github Registry Description - if: ${{ env.ENABLE_GHCR == 1 }} - uses: peter-evans/dockerhub-description@v3.3.0 - with: - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - short-description: | - A web interface to manage your torrents on Real-Debrid, AllDebrid or Premiumize. - readme-filepath: ./README-DOCKER.md + # - name: Github Registry Description + # if: ${{ env.ENABLE_GHCR == 1 }} + # uses: peter-evans/dockerhub-description@v3.3.0 + # with: + # username: ${{ github.repository_owner }} + # password: ${{ secrets.GITHUB_TOKEN }} + # short-description: | + # A web interface to manage your torrents on Real-Debrid, AllDebrid or Premiumize. + # readme-filepath: ./README-DOCKER.md From 9f711611d782f90c4d8fd4a85a33b1721cefbefd Mon Sep 17 00:00:00 2001 From: Shawn Anderson Date: Fri, 17 Mar 2023 17:36:23 -0400 Subject: [PATCH 11/11] Updated workflow --- .github/workflows/docker-image.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index c2a6ced..04f0647 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -2,7 +2,6 @@ name: Docker Image CI on: push: - branches: [ "master" ] tags: - v*