diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..04f0647 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,98 @@ +name: Docker Image CI + +on: + push: + tags: + - v* + +permissions: + packages: write + +env: + APP_NAME: rdt-client + DOCKER_FILE: ./Dockerfile + DOCKER_PLATFORMS: "linux/arm/v7,linux/arm64/v8,linux/amd64" + ENABLE_DOCKERHUB: 0 + ENABLE_GHCR: 1 + +jobs: + + build: + + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Docker Metadata action + id: meta + uses: docker/metadata-action@v4.3.0 + with: + images: | + # ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.APP_NAME }} + ghcr.io/${{ secrets.DOCKERHUB_USERNAME }}/${{ env.APP_NAME }} + 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' && 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 == 1 }} + 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: ${{ env.DOCKER_FILE }} + platforms: ${{ env.DOCKER_PLATFORMS }} + 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 == 1 }} + uses: peter-evans/dockerhub-description@v3.3.0 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + 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 + + # - 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 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/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 +} diff --git a/docker-publish.ps1 b/docker-publish.ps1 index 3e88b62..63ef6a3 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") @@ -54,7 +55,7 @@ if ($SkipCache.IsPresent) { } if ($OutputToDocker.IsPresent) { - $dockerArgs += @("--output=type=docker") + $dockerArgs += @("--load") } if ([string]::IsNullOrEmpty($Version)) { 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