Docker enhancements

This commit is contained in:
JustArchi 2017-10-07 17:26:08 +02:00
parent 334488919f
commit 8fa58a4841
6 changed files with 27 additions and 3 deletions

View file

@ -534,7 +534,7 @@ namespace ArchiSteamFarm {
}
private static async Task RestartOrExit() {
if (Program.GlobalConfig.AutoRestart) {
if (!Program.ServiceMode && Program.GlobalConfig.AutoRestart) {
ArchiLogger.LogGenericInfo(Strings.Restarting);
await Task.Delay(5000).ConfigureAwait(false);
await Program.Restart().ConfigureAwait(false);

View file

@ -29,7 +29,7 @@ using ArchiSteamFarm.Localization;
namespace ArchiSteamFarm {
internal static class Events {
internal static async void OnBotShutdown() {
if (IPC.KeepRunning || Bot.Bots.Values.Any(bot => bot.KeepRunning)) {
if (Program.ServiceMode || IPC.KeepRunning || Bot.Bots.Values.Any(bot => bot.KeepRunning)) {
return;
}

View file

@ -48,6 +48,7 @@ namespace ArchiSteamFarm {
internal static GlobalConfig GlobalConfig { get; private set; }
internal static GlobalDatabase GlobalDatabase { get; private set; }
internal static bool ServiceMode { get; private set; }
internal static WebBrowser WebBrowser { get; private set; }
private static readonly object ConsoleLock = new object();
@ -396,6 +397,9 @@ namespace ArchiSteamFarm {
case "--server":
IPC.Start();
break;
case "--service":
ServiceMode = true;
break;
default:
if (arg.StartsWith("--", StringComparison.Ordinal)) {
if (arg.StartsWith("--cryptkey=", StringComparison.Ordinal) && (arg.Length > 11)) {

View file

@ -0,0 +1,8 @@
#!/bin/bash
set -eu
cd "$(dirname "$(readlink -f "$0")")"
while [[ -f ArchiSteamFarm.dll ]]; do
dotnet ArchiSteamFarm.dll --service # We will abort the script if ASF exits with an error
sleep 1
done

View file

@ -3,7 +3,7 @@ WORKDIR /app
COPY . ./
RUN dotnet publish ArchiSteamFarm -c Release -o out /nologo
FROM microsoft/dotnet:2.0-runtime
FROM microsoft/dotnet:2.0-runtime
WORKDIR /app
COPY --from=build-env /app/ArchiSteamFarm/out ./
ENTRYPOINT ["dotnet", "ArchiSteamFarm.dll"]

12
Dockerfile.Service Normal file
View file

@ -0,0 +1,12 @@
FROM microsoft/dotnet:2.0-sdk AS build-env
WORKDIR /app
COPY . ./
RUN dotnet publish ArchiSteamFarm -c Release -o out /nologo && \
echo "generic" > "ArchiSteamFarm/out/ArchiSteamFarm.version" && \
cp "ArchiSteamFarm/scripts/generic/ArchiSteamFarm-Service.sh" "ArchiSteamFarm/out/ArchiSteamFarm-Service.sh" && \
chmod +x "ArchiSteamFarm/out/ArchiSteamFarm-Service.sh"
FROM microsoft/dotnet:2.0-runtime
WORKDIR /app
COPY --from=build-env /app/ArchiSteamFarm/out ./
ENTRYPOINT ["./ArchiSteamFarm-Service.sh"]