ci: Do not use single-file builds for MUSL

Single-file builds incur a performance cost. Mainly because the runtime
must extract the contents of the C# application to a temp directory in
order for it to run. In a Docker container, single-file offers no
tangible benefit because the user isn't interacting directly with those
files.

To gain some performance improvement, single-file is disabled for MUSL
builds. Furthermore, the docker image is reconfigured to place the
Recyclarr binary files in a different directory. Previously, as a
single-file binary, it was placed in the container at `/usr/local/bin`,
but now that it is a multiple-file application, it now lives in
`/app/recyclarr`.
pull/108/head
Robert Dailey 2 years ago
parent 3a5e1f0c5e
commit 72b0c9272d

@ -70,9 +70,14 @@ jobs:
with:
dotnet-version: ${{ env.dotnetVersion }}
- name: Determine if single file build or not
if: contains(matrix.runtime, 'musl')
id: single_file
run: echo '::set-output name=arg::-noSingleFile'
- name: Publish
shell: pwsh
run: ci/Publish.ps1 ${{ matrix.runtime }}
run: ci/Publish.ps1 ${{ matrix.runtime }} ${{ steps.single_file.outputs.arg }}
- name: Upload Artifacts
uses: actions/upload-artifact@v3

@ -1,18 +1,26 @@
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string] $runtime
[string] $runtime,
[Parameter()]
[switch] $noSingleFile
)
$ErrorActionPreference = "Stop"
if (-not $noSingleFile) {
$singleFileArgs = @(
"--self-contained=true"
"-p:PublishSingleFile=true"
"-p:IncludeNativeLibrariesForSelfExtract=true"
"-p:PublishReadyToRunComposite=true"
"-p:PublishReadyToRunShowWarnings=true"
"-p:EnableCompressionInSingleFile=true"
)
}
dotnet publish src\Recyclarr `
--output publish\$runtime `
--configuration Release `
--runtime $runtime `
--self-contained true `
-p:PublishSingleFile=true `
-p:IncludeNativeLibrariesForSelfExtract=true `
-p:PublishReadyToRunComposite=true `
-p:PublishReadyToRunShowWarnings=true `
-p:EnableCompressionInSingleFile=true
$singleFileArgs

@ -16,7 +16,8 @@ RUN ./build.sh
FROM alpine AS final
# Required by environment and/or dotnet
ENV RECYCLARR_APP_DATA=/config \
ENV PATH="${PATH}:/app/recyclarr" \
RECYCLARR_APP_DATA=/config \
CRON_SCHEDULE="@daily" \
DOTNET_BUNDLE_EXTRACT_BASE_DIR=/tmp/.net \
# The GLOBALIZATION variable is so that we do not need libicu installed (saves us ~40MB).
@ -26,7 +27,7 @@ RUN set -ex; \
apk add --no-cache bash libstdc++ tzdata supercronic; \
mkdir -p "$DOTNET_BUNDLE_EXTRACT_BASE_DIR" && chmod 777 "$DOTNET_BUNDLE_EXTRACT_BASE_DIR";
COPY --chmod=555 --from=build /build/recyclarr /usr/local/bin
COPY --from=build /build/publish /app/recyclarr/
COPY --chmod=555 ./scripts/prod/*.sh /
USER 1000:1000

@ -1,8 +1,7 @@
#!/usr/bin/env bash
set -ex
# Do not shallow clone because gitversion needs history!
git clone -b $BUILD_FROM_BRANCH "https://github.com/$REPOSITORY.git" source
cd source
pwsh ./ci/Publish.ps1 $runtime
cp ./publish/$runtime/recyclarr ..
dotnet publish source/src/Recyclarr -o publish -c Release -r $runtime

@ -11,4 +11,4 @@ fi
# Download and extract the recyclarr binary from the release
wget --quiet -O recyclarr.zip "https://github.com/$REPOSITORY/releases/$download_path/recyclarr-$runtime.zip"
unzip recyclarr.zip
unzip recyclarr.zip -d publish

@ -14,3 +14,5 @@ if [ -z "$BUILD_FROM_BRANCH" ]; then
else
. ./build-using-clone.sh
fi
chmod a+rx publish/recyclarr

Loading…
Cancel
Save