From 7899829dc712d06241e2b87e4e42035f8ffdd2f8 Mon Sep 17 00:00:00 2001 From: Archi Date: Mon, 5 Feb 2024 16:26:54 +0100 Subject: [PATCH] Refactor docker containers to use /asf In order to keep compatibility with existing containers, we'll use the same paths for user-related overrides, that is, /app/config, /app/logs or /app/plugins. Instead, the only thing we'll do is moving ASF away from /app to new /asf directory, which will hopefully limit amount of screwups that users are doing within existing /app directory. Also while at it, add symlink for a bit better integration. --- Dockerfile | 13 ++++++++----- Dockerfile.Service | 13 ++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 092d7b165..63ce3be06 100644 --- a/Dockerfile +++ b/Dockerfile @@ -44,17 +44,18 @@ RUN set -eu; \ *) echo "ERROR: Unsupported CPU architecture: ${TARGETARCH}"; exit 1 ;; \ esac; \ \ - dotnet publish ArchiSteamFarm -c "$CONFIGURATION" -o "out/result" -p:ASFVariant=docker -p:ContinuousIntegrationBuild=true -p:UseAppHost=false -r "$asf_variant" --nologo --no-self-contained; \ + dotnet publish ArchiSteamFarm -c "$CONFIGURATION" -o "out" -p:ASFVariant=docker -p:ContinuousIntegrationBuild=true -p:UseAppHost=false -r "$asf_variant" --nologo --no-self-contained; \ \ if [ -n "${STEAM_TOKEN_DUMPER_TOKEN-}" ] && [ -f "ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/SharedInfo.cs" ]; then \ sed -i "s/STEAM_TOKEN_DUMPER_TOKEN/${STEAM_TOKEN_DUMPER_TOKEN}/g" "ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/SharedInfo.cs"; \ fi; \ \ for plugin in $PLUGINS; do \ - dotnet publish "$plugin" -c "$CONFIGURATION" -o "out/result/plugins/$plugin" -p:ASFVariant=docker -p:ContinuousIntegrationBuild=true -p:UseAppHost=false -r "$asf_variant" --nologo --no-self-contained; \ + dotnet publish "$plugin" -c "$CONFIGURATION" -o "out/plugins/$plugin" -p:ASFVariant=docker -p:ContinuousIntegrationBuild=true -p:UseAppHost=false -r "$asf_variant" --nologo --no-self-contained; \ done FROM --platform=$TARGETPLATFORM mcr.microsoft.com/dotnet/aspnet:8.0${IMAGESUFFIX} AS runtime +ENV ASF_PATH /app ENV ASF_USER asf ENV ASPNETCORE_URLS= ENV DOTNET_CLI_TELEMETRY_OPTOUT true @@ -72,13 +73,15 @@ LABEL maintainer="JustArchi " \ EXPOSE 1242 WORKDIR /app -COPY --from=build-dotnet /app/out/result . +COPY --from=build-dotnet /app/out /asf RUN set -eu; \ groupadd -r -g 1000 asf; \ useradd -r -d /app -g 1000 -u 1000 asf; \ - chown -hR asf:asf /app + mkdir -p /app /asf; \ + chown -hR asf:asf /app /asf; \ + ln -s /asf/ArchiSteamFarm.sh /usr/bin/ArchiSteamFarm VOLUME ["/app/config", "/app/logs"] HEALTHCHECK CMD ["pidof", "-q", "dotnet"] -ENTRYPOINT ["sh", "ArchiSteamFarm.sh", "--no-restart", "--process-required", "--system-required"] +ENTRYPOINT ["ArchiSteamFarm", "--no-restart", "--process-required", "--system-required"] diff --git a/Dockerfile.Service b/Dockerfile.Service index 0e36ead92..02710be74 100644 --- a/Dockerfile.Service +++ b/Dockerfile.Service @@ -44,17 +44,18 @@ RUN set -eu; \ *) echo "ERROR: Unsupported CPU architecture: ${TARGETARCH}"; exit 1 ;; \ esac; \ \ - dotnet publish ArchiSteamFarm -c "$CONFIGURATION" -o "out/result" "-p:ASFVariant=${asf_variant}" -p:ContinuousIntegrationBuild=true -p:PublishSingleFile=true -p:PublishTrimmed=true -r "$asf_variant" --nologo --self-contained; \ + dotnet publish ArchiSteamFarm -c "$CONFIGURATION" -o "out" "-p:ASFVariant=${asf_variant}" -p:ContinuousIntegrationBuild=true -p:PublishSingleFile=true -p:PublishTrimmed=true -r "$asf_variant" --nologo --self-contained; \ \ if [ -n "${STEAM_TOKEN_DUMPER_TOKEN-}" ] && [ -f "ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/SharedInfo.cs" ]; then \ sed -i "s/STEAM_TOKEN_DUMPER_TOKEN/${STEAM_TOKEN_DUMPER_TOKEN}/g" "ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/SharedInfo.cs"; \ fi; \ \ for plugin in $PLUGINS; do \ - dotnet publish "$plugin" -c "$CONFIGURATION" -o "out/result/plugins/$plugin" "-p:ASFVariant=${asf_variant}" -p:ContinuousIntegrationBuild=true -p:UseAppHost=false -r "$asf_variant" --nologo --no-self-contained; \ + dotnet publish "$plugin" -c "$CONFIGURATION" -o "out/plugins/$plugin" "-p:ASFVariant=${asf_variant}" -p:ContinuousIntegrationBuild=true -p:UseAppHost=false -r "$asf_variant" --nologo --no-self-contained; \ done FROM --platform=$TARGETPLATFORM mcr.microsoft.com/dotnet/runtime-deps:8.0${IMAGESUFFIX} AS runtime +ENV ASF_PATH /app ENV ASF_USER asf ENV ASPNETCORE_URLS= ENV DOTNET_CLI_TELEMETRY_OPTOUT true @@ -72,13 +73,15 @@ LABEL maintainer="JustArchi " \ EXPOSE 1242 WORKDIR /app -COPY --from=build-dotnet /app/out/result . +COPY --from=build-dotnet /app/out /asf RUN set -eu; \ groupadd -r -g 1000 asf; \ useradd -r -d /app -g 1000 -u 1000 asf; \ - chown -hR asf:asf /app + mkdir -p /app /asf; \ + chown -hR asf:asf /app /asf; \ + ln -s /asf/ArchiSteamFarm-Service.sh /usr/bin/ArchiSteamFarm VOLUME ["/app/config", "/app/logs"] HEALTHCHECK CMD ["pidof", "-q", "ArchiSteamFarm"] -ENTRYPOINT ["sh", "ArchiSteamFarm-Service.sh", "--no-restart", "--process-required", "--system-required"] +ENTRYPOINT ["ArchiSteamFarm", "--no-restart", "--process-required", "--system-required"]