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.
This commit is contained in:
Archi 2024-02-05 16:26:54 +01:00
parent d0693d362a
commit 7899829dc7
No known key found for this signature in database
GPG key ID: 6B138B4C64555AEA
2 changed files with 16 additions and 10 deletions

View file

@ -44,17 +44,18 @@ RUN set -eu; \
*) echo "ERROR: Unsupported CPU architecture: ${TARGETARCH}"; exit 1 ;; \ *) echo "ERROR: Unsupported CPU architecture: ${TARGETARCH}"; exit 1 ;; \
esac; \ 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 \ 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"; \ sed -i "s/STEAM_TOKEN_DUMPER_TOKEN/${STEAM_TOKEN_DUMPER_TOKEN}/g" "ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/SharedInfo.cs"; \
fi; \ fi; \
\ \
for plugin in $PLUGINS; do \ 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 done
FROM --platform=$TARGETPLATFORM mcr.microsoft.com/dotnet/aspnet:8.0${IMAGESUFFIX} AS runtime FROM --platform=$TARGETPLATFORM mcr.microsoft.com/dotnet/aspnet:8.0${IMAGESUFFIX} AS runtime
ENV ASF_PATH /app
ENV ASF_USER asf ENV ASF_USER asf
ENV ASPNETCORE_URLS= ENV ASPNETCORE_URLS=
ENV DOTNET_CLI_TELEMETRY_OPTOUT true ENV DOTNET_CLI_TELEMETRY_OPTOUT true
@ -72,13 +73,15 @@ LABEL maintainer="JustArchi <JustArchi@JustArchi.net>" \
EXPOSE 1242 EXPOSE 1242
WORKDIR /app WORKDIR /app
COPY --from=build-dotnet /app/out/result . COPY --from=build-dotnet /app/out /asf
RUN set -eu; \ RUN set -eu; \
groupadd -r -g 1000 asf; \ groupadd -r -g 1000 asf; \
useradd -r -d /app -g 1000 -u 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"] VOLUME ["/app/config", "/app/logs"]
HEALTHCHECK CMD ["pidof", "-q", "dotnet"] HEALTHCHECK CMD ["pidof", "-q", "dotnet"]
ENTRYPOINT ["sh", "ArchiSteamFarm.sh", "--no-restart", "--process-required", "--system-required"] ENTRYPOINT ["ArchiSteamFarm", "--no-restart", "--process-required", "--system-required"]

View file

@ -44,17 +44,18 @@ RUN set -eu; \
*) echo "ERROR: Unsupported CPU architecture: ${TARGETARCH}"; exit 1 ;; \ *) echo "ERROR: Unsupported CPU architecture: ${TARGETARCH}"; exit 1 ;; \
esac; \ 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 \ 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"; \ sed -i "s/STEAM_TOKEN_DUMPER_TOKEN/${STEAM_TOKEN_DUMPER_TOKEN}/g" "ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/SharedInfo.cs"; \
fi; \ fi; \
\ \
for plugin in $PLUGINS; do \ 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 done
FROM --platform=$TARGETPLATFORM mcr.microsoft.com/dotnet/runtime-deps:8.0${IMAGESUFFIX} AS runtime FROM --platform=$TARGETPLATFORM mcr.microsoft.com/dotnet/runtime-deps:8.0${IMAGESUFFIX} AS runtime
ENV ASF_PATH /app
ENV ASF_USER asf ENV ASF_USER asf
ENV ASPNETCORE_URLS= ENV ASPNETCORE_URLS=
ENV DOTNET_CLI_TELEMETRY_OPTOUT true ENV DOTNET_CLI_TELEMETRY_OPTOUT true
@ -72,13 +73,15 @@ LABEL maintainer="JustArchi <JustArchi@JustArchi.net>" \
EXPOSE 1242 EXPOSE 1242
WORKDIR /app WORKDIR /app
COPY --from=build-dotnet /app/out/result . COPY --from=build-dotnet /app/out /asf
RUN set -eu; \ RUN set -eu; \
groupadd -r -g 1000 asf; \ groupadd -r -g 1000 asf; \
useradd -r -d /app -g 1000 -u 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"] VOLUME ["/app/config", "/app/logs"]
HEALTHCHECK CMD ["pidof", "-q", "ArchiSteamFarm"] HEALTHCHECK CMD ["pidof", "-q", "ArchiSteamFarm"]
ENTRYPOINT ["sh", "ArchiSteamFarm-Service.sh", "--no-restart", "--process-required", "--system-required"] ENTRYPOINT ["ArchiSteamFarm", "--no-restart", "--process-required", "--system-required"]