Docker: make it possible to pass arguments

This commit is contained in:
JustArchi
2017-10-07 19:54:23 +02:00
parent 5c737a286b
commit 685e52d53f
5 changed files with 17 additions and 7 deletions

View File

@@ -2,9 +2,13 @@
set -eu set -eu
cd "$(dirname "$(readlink -f "$0")")" cd "$(dirname "$(readlink -f "$0")")"
if [[ -z "${ASF_ARGS-}" ]]; then
ASF_ARGS=""
fi
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT
while [[ -f ArchiSteamFarm.dll ]]; do while [[ -f ArchiSteamFarm.dll ]]; do
dotnet ArchiSteamFarm.dll --service # We will abort the script if ASF exits with an error dotnet ArchiSteamFarm.dll --service $ASF_ARGS # We will abort the script if ASF exits with an error
sleep 1 sleep 1
done done

View File

@@ -1,3 +1,3 @@
@echo off @echo off
pushd %~dp0 pushd %~dp0
dotnet ArchiSteamFarm.dll dotnet %ASF_ARGS% ArchiSteamFarm.dll

View File

@@ -1,4 +1,10 @@
#!/bin/bash #!/bin/bash
set -eu set -eu
cd "$(dirname "$(readlink -f "$0")")" cd "$(dirname "$(readlink -f "$0")")"
dotnet ArchiSteamFarm.dll
if [[ -z "${ASF_ARGS-}" ]]; then
ASF_ARGS=""
fi
# We don't need our shell anymore, just replace the current process instead of starting a new one
exec dotnet $ASF_ARGS ArchiSteamFarm.dll

View File

@@ -1,9 +1,10 @@
FROM microsoft/dotnet:2.0-sdk AS build-env FROM microsoft/dotnet:2.0-sdk AS build-env
WORKDIR /app WORKDIR /app
COPY . ./ COPY . ./
RUN dotnet publish ArchiSteamFarm -c Release -o out /nologo RUN dotnet publish ArchiSteamFarm -c Release -o out /nologo && \
cp "ArchiSteamFarm/scripts/generic/ArchiSteamFarm.sh" "ArchiSteamFarm/out/ArchiSteamFarm.sh"
FROM microsoft/dotnet:2.0-runtime FROM microsoft/dotnet:2.0-runtime
WORKDIR /app WORKDIR /app
COPY --from=build-env /app/ArchiSteamFarm/out ./ COPY --from=build-env /app/ArchiSteamFarm/out ./
ENTRYPOINT ["dotnet", "ArchiSteamFarm.dll"] ENTRYPOINT ["./ArchiSteamFarm.sh"]

View File

@@ -3,8 +3,7 @@ WORKDIR /app
COPY . ./ COPY . ./
RUN dotnet publish ArchiSteamFarm -c Release -o out /nologo && \ RUN dotnet publish ArchiSteamFarm -c Release -o out /nologo && \
echo "generic" > "ArchiSteamFarm/out/ArchiSteamFarm.version" && \ echo "generic" > "ArchiSteamFarm/out/ArchiSteamFarm.version" && \
cp "ArchiSteamFarm/scripts/generic/ArchiSteamFarm-Service.sh" "ArchiSteamFarm/out/ArchiSteamFarm-Service.sh" && \ 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 FROM microsoft/dotnet:2.0-runtime
WORKDIR /app WORKDIR /app