chore(deps): update swashbuckle-aspnetcore monorepo to 7.1.0
[ArchiSteamFarm.git] / Dockerfile.Service
blob27c452c170a0953383bf2b18d29fed0b82706ea6
1 ARG IMAGESUFFIX
3 FROM --platform=$BUILDPLATFORM node:lts${IMAGESUFFIX} AS build-node
4 WORKDIR /app/ASF-ui
5 COPY --link ASF-ui .
6 COPY --link .git/modules/ASF-ui /app/.git/modules/ASF-ui
8 RUN <<EOF
9     set -eu
11     echo "node: $(node --version)"
12     echo "npm: $(npm --version)"
14     npm ci --no-progress
15     npm run deploy --no-progress
16 EOF
18 FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:9.0${IMAGESUFFIX} AS build-dotnet
19 ARG CONFIGURATION=Release
20 ARG TARGETARCH
21 ARG TARGETOS
22 ENV DOTNET_CLI_TELEMETRY_OPTOUT=true
23 ENV DOTNET_NOLOGO=true
24 ENV PLUGINS_BUNDLED="ArchiSteamFarm.OfficialPlugins.ItemsMatcher ArchiSteamFarm.OfficialPlugins.MobileAuthenticator ArchiSteamFarm.OfficialPlugins.SteamTokenDumper"
25 WORKDIR /app
26 COPY --from=build-node --link /app/ASF-ui/dist ASF-ui/dist
27 COPY --link ArchiSteamFarm ArchiSteamFarm
28 COPY --link ArchiSteamFarm.OfficialPlugins.ItemsMatcher ArchiSteamFarm.OfficialPlugins.ItemsMatcher
29 COPY --link ArchiSteamFarm.OfficialPlugins.MobileAuthenticator ArchiSteamFarm.OfficialPlugins.MobileAuthenticator
30 COPY --link ArchiSteamFarm.OfficialPlugins.SteamTokenDumper ArchiSteamFarm.OfficialPlugins.SteamTokenDumper
31 COPY --link resources resources
32 COPY --link .editorconfig .editorconfig
33 COPY --link Directory.Build.props Directory.Build.props
34 COPY --link Directory.Packages.props Directory.Packages.props
35 COPY --link LICENSE.txt LICENSE.txt
37 RUN --mount=type=secret,id=ASF_PRIVATE_SNK --mount=type=secret,id=STEAM_TOKEN_DUMPER_TOKEN <<EOF
38     set -eu
40     dotnet --info
42     case "$TARGETOS" in
43         "linux") ;;
44         *) echo "ERROR: Unsupported OS: ${TARGETOS}"; exit 1 ;;
45     esac
47     case "$TARGETARCH" in
48         "amd64") asf_variant="${TARGETOS}-x64" ;;
49         "arm") asf_variant="${TARGETOS}-${TARGETARCH}" ;;
50         "arm64") asf_variant="${TARGETOS}-${TARGETARCH}" ;;
51         *) echo "ERROR: Unsupported CPU architecture: ${TARGETARCH}"; exit 1 ;;
52     esac
54     if [ -f "/run/secrets/ASF_PRIVATE_SNK" ]; then
55         base64 -d "/run/secrets/ASF_PRIVATE_SNK" > "resources/ArchiSteamFarm.snk"
56     else
57         echo "WARN: No ASF_PRIVATE_SNK provided!"
58     fi
60     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
62     if [ -f "/run/secrets/STEAM_TOKEN_DUMPER_TOKEN" ]; then
63         STEAM_TOKEN_DUMPER_TOKEN="$(cat "/run/secrets/STEAM_TOKEN_DUMPER_TOKEN")"
65         if [ -n "STEAM_TOKEN_DUMPER_TOKEN" ] && [ -f "ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/SharedInfo.cs" ]; then
66             sed -i "s/STEAM_TOKEN_DUMPER_TOKEN/${STEAM_TOKEN_DUMPER_TOKEN}/g" "ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/SharedInfo.cs"
67         else
68             echo "WARN: STEAM_TOKEN_DUMPER_TOKEN not applied!"
69         fi
70     else
71         echo "WARN: No STEAM_TOKEN_DUMPER_TOKEN provided!"
72     fi
74     for plugin in $PLUGINS_BUNDLED; do
75         dotnet publish "$plugin" -c "$CONFIGURATION" -o "out/plugins/$plugin" "-p:ASFVariant=${asf_variant}" -p:ContinuousIntegrationBuild=true -p:UseAppHost=false -r "$asf_variant" --nologo
76     done
77 EOF
79 FROM mcr.microsoft.com/dotnet/runtime-deps:9.0${IMAGESUFFIX} AS runtime
80 ENV ASF_PATH=/app
81 ENV ASF_USER=asf
82 ENV ASPNETCORE_URLS=
83 ENV DOTNET_CLI_TELEMETRY_OPTOUT=true
84 ENV DOTNET_NOLOGO=true
86 LABEL maintainer="JustArchi <JustArchi@JustArchi.net>" \
87     org.opencontainers.image.authors="JustArchi <JustArchi@JustArchi.net>" \
88     org.opencontainers.image.url="https://github.com/JustArchiNET/ArchiSteamFarm/wiki/Docker" \
89     org.opencontainers.image.documentation="https://github.com/JustArchiNET/ArchiSteamFarm/wiki" \
90     org.opencontainers.image.source="https://github.com/JustArchiNET/ArchiSteamFarm" \
91     org.opencontainers.image.vendor="JustArchiNET" \
92     org.opencontainers.image.licenses="Apache-2.0" \
93     org.opencontainers.image.title="ArchiSteamFarm" \
94     org.opencontainers.image.description="C# application with primary purpose of idling Steam cards from multiple accounts simultaneously"
96 EXPOSE 1242
97 COPY --from=build-dotnet --link /app/out /asf
99 RUN <<EOF
100     set -eu
102     mkdir -p "$ASF_PATH"
104     groupadd -r -g 1000 "$ASF_USER"
105     useradd -r -d "$ASF_PATH" -g 1000 -u 1000 "$ASF_USER"
106     chown -hR "${ASF_USER}:${ASF_USER}" "$ASF_PATH" /asf
108     ln -s /asf/ArchiSteamFarm-Service.sh /usr/bin/ArchiSteamFarm
111 WORKDIR /app
112 VOLUME ["/app/config", "/app/logs"]
113 HEALTHCHECK CMD ["pidof", "-q", "ArchiSteamFarm"]
114 ENTRYPOINT ["ArchiSteamFarm", "--no-restart", "--system-required"]