From 4d20bdebe3f188bf64bedbedaea760e82c6b23a2 Mon Sep 17 00:00:00 2001 From: Robert Dailey Date: Fri, 25 Nov 2022 10:45:57 -0600 Subject: [PATCH] chore: Update support script for building the docker image. --- CONTRIBUTING.md | 35 ++++++++++++++++------------------- docker/Build-Artifacts.ps1 | 14 -------------- docker/BuildAndRun.ps1 | 36 ++++++++++++++++++++++++++++++++++++ docker/Run.ps1 | 9 --------- 4 files changed, 52 insertions(+), 42 deletions(-) delete mode 100644 docker/Build-Artifacts.ps1 create mode 100644 docker/BuildAndRun.ps1 delete mode 100644 docker/Run.ps1 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6839075a..8e2c2c16 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -48,30 +48,27 @@ docker/artifacts/recyclarr-${{runtime}} Where `${{runtime}}` is one of the runtimes compatible with `dotnet publish`, such as `linux-musl-x64`. -There is a convenience script named `docker/Build-Artifacts.ps1` that will perform a build and place -the output in the appropriate location for you. This simplifies the process of testing docker -locally to these steps: +There is a convenience script named `docker/BuildAndRun.ps1` that will perform the following steps: -1. Run the convenience script to build and publish Recyclarr to the Docker artifacts directory: +1. Delete the `docker/artifacts` directory, if it exists. +1. Recompile Recyclarr and publish it to `docker/artifacts`. +1. Pull and start the Sonarr & Radarr containers in the `debugging` directory. +1. Build & run the `recyclarr` docker image. - ```sh - pwsh ci/Build-Artifacts.ps1 - ``` +You may also provide runtime arguments to the `BuildAndRun.ps1` script to run it in manual mode +instead of cron mode. Example: - > *Note:* The runtime defaults to `linux-musl-x64` but you can pass in an override as the first - > placeholder argument to the above command. - -1. Execute a Docker build locally via compose: - - ```sh - docker compose build --no-cache --progress plain - ``` +```sh +# Run `recyclarr radarr -h`: +.\BuildAndRun.ps1 -RunArgs radarr,-h +``` -1. Run the container to test it: +If you want to run any part of this process manually, open up the `BuildAndRun.ps1` script to see +what commands you need to run manually. - ```sh - docker compose run --rm recyclarr sonarr - ``` +> ⚠️ **Note** ⚠️
+> The runtime defaults to `linux-musl-x64` but you can pass in an override via the `-Runtime` +> option. ### Build Arguments diff --git a/docker/Build-Artifacts.ps1 b/docker/Build-Artifacts.ps1 deleted file mode 100644 index 12d10d92..00000000 --- a/docker/Build-Artifacts.ps1 +++ /dev/null @@ -1,14 +0,0 @@ -[CmdletBinding()] -param ( - $Runtime = "linux-musl-x64" -) - -$artifactsDir = "$PSScriptRoot\artifacts" - -Remove-Item $artifactsDir -Recurse -Force -ErrorAction SilentlyContinue - -Push-Location $PSScriptRoot\.. -& ci\Publish.ps1 -NoSingleFile ` - -OutputDir "$artifactsDir\recyclarr-$Runtime" ` - -Runtime $Runtime -Pop-Location diff --git a/docker/BuildAndRun.ps1 b/docker/BuildAndRun.ps1 new file mode 100644 index 00000000..d96492af --- /dev/null +++ b/docker/BuildAndRun.ps1 @@ -0,0 +1,36 @@ +[CmdletBinding()] +param ( + [string] $Runtime = "linux-musl-x64", + [string[]] $RunArgs +) + +$artifactsDir = "$PSScriptRoot\artifacts" + +# Delete old build artifacts +Remove-Item $artifactsDir -Recurse -Force -ErrorAction SilentlyContinue + +# Publish new build artifacts +Push-Location $PSScriptRoot\.. +try { + & ci\Publish.ps1 -NoSingleFile ` + -OutputDir "$artifactsDir\recyclarr-$Runtime" ` + -Runtime $Runtime +} +finally { + Pop-Location +} + +# Start the corresponding radarr/sonarr docker containers for testing/debugging +Push-Location "$PSScriptRoot\..\debugging" +try { + docker compose up -d --pull always +} +finally { + Pop-Location +} + +# Finally, build the docker image and run it +docker compose build +# TODO: Use `--build` when it releases: +# https://github.com/docker/compose/issues/10003 +docker compose run --rm recyclarr @RunArgs diff --git a/docker/Run.ps1 b/docker/Run.ps1 deleted file mode 100644 index 20fd2eb7..00000000 --- a/docker/Run.ps1 +++ /dev/null @@ -1,9 +0,0 @@ -& $PSScriptRoot\Build-Artifacts.ps1 - -Push-Location "$PSScriptRoot\..\debugging" -docker compose pull -docker compose up -d -Pop-Location - -docker compose build -docker compose run --rm recyclarr $args