mirror of
https://github.com/JustArchiNET/ArchiSteamFarm
synced 2024-11-10 15:14:41 +00:00
Correct overlay for dockerfiles
This commit is contained in:
parent
cb883cf235
commit
56754053c3
3 changed files with 109 additions and 4 deletions
108
ArchiSteamFarm/overlay/variant-specific/docker/ArchiSteamFarm.sh
Executable file
108
ArchiSteamFarm/overlay/variant-specific/docker/ArchiSteamFarm.sh
Executable file
|
@ -0,0 +1,108 @@
|
|||
#!/usr/bin/env sh
|
||||
set -eu
|
||||
|
||||
CONFIG_PATH="config/ASF.json"
|
||||
OS_TYPE="$(uname -s)"
|
||||
|
||||
case "$OS_TYPE" in
|
||||
"Darwin") SCRIPT_PATH="$(readlink "$0")" ;;
|
||||
"FreeBSD") SCRIPT_PATH="$(readlink -f "$0")" ;;
|
||||
"Linux") SCRIPT_PATH="$(readlink -f "$0")" ;;
|
||||
*) echo "ERROR: Unknown OS type: ${OS_TYPE}. If you believe that our script should work on your machine, please let us know."; exit 1
|
||||
esac
|
||||
|
||||
SCRIPT_DIR="$(dirname "$SCRIPT_PATH")"
|
||||
BINARY="${SCRIPT_DIR}/ArchiSteamFarm.dll"
|
||||
|
||||
if [ ! -f "$BINARY" ]; then
|
||||
echo "ERROR: $BINARY could not be found!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "$SCRIPT_DIR"
|
||||
|
||||
BINARY_ARGS=""
|
||||
PATH_NEXT=0
|
||||
SERVICE=0
|
||||
|
||||
PARSE_ARG() {
|
||||
BINARY_ARGS="$BINARY_ARGS $1"
|
||||
|
||||
case "$1" in
|
||||
--path) PATH_NEXT=1 ;;
|
||||
--path=*)
|
||||
if [ "$PATH_NEXT" -eq 1 ]; then
|
||||
PATH_NEXT=0
|
||||
cd "$1"
|
||||
else
|
||||
cd "$(echo "$1" | cut -d '=' -f 2-)"
|
||||
fi
|
||||
;;
|
||||
--service) SERVICE=1 ;;
|
||||
*)
|
||||
if [ "$PATH_NEXT" -eq 1 ]; then
|
||||
PATH_NEXT=0
|
||||
cd "$1"
|
||||
fi
|
||||
esac
|
||||
}
|
||||
|
||||
if [ -n "${ASF_PATH-}" ]; then
|
||||
cd "$ASF_PATH"
|
||||
fi
|
||||
|
||||
if [ -n "${ASF_ARGS-}" ]; then
|
||||
for ARG in $ASF_ARGS; do
|
||||
if [ -n "$ARG" ]; then
|
||||
PARSE_ARG "$ARG"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
for ARG in "$@"; do
|
||||
if [ -n "$ARG" ]; then
|
||||
PARSE_ARG "$ARG"
|
||||
fi
|
||||
done
|
||||
|
||||
BINARY_PREFIX=""
|
||||
|
||||
if [ -n "${ASF_USER-}" ] && [ "$(id -u)" -eq 0 ] && id -u "$ASF_USER" >/dev/null 2>&1; then
|
||||
# Fix permissions first to ensure ASF has read/write access to the directory specified by --path and its own
|
||||
chown -hR "${ASF_USER}:${ASF_USER}" . "$SCRIPT_DIR"
|
||||
|
||||
BINARY_PREFIX="su ${ASF_USER} -c"
|
||||
fi
|
||||
|
||||
CONFIG_PATH="$(pwd)/${CONFIG_PATH}"
|
||||
|
||||
# Kill underlying ASF process on shell process exit
|
||||
trap "trap - TERM && kill -- -$$" INT TERM
|
||||
|
||||
if ! command -v dotnet >/dev/null; then
|
||||
echo "ERROR: dotnet CLI tools are not installed!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
dotnet --info
|
||||
|
||||
if [ "$SERVICE" -eq 1 ] || ([ -f "$CONFIG_PATH" ] && grep -Eq '"Headless":\s+?true' "$CONFIG_PATH"); then
|
||||
# We're running ASF in headless mode so we don't need STDIN
|
||||
# Start ASF in the background, trap will work properly due to non-blocking call
|
||||
if [ -n "$BINARY_PREFIX" ]; then
|
||||
$BINARY_PREFIX "dotnet ${DOTNET_ARGS-} $BINARY $BINARY_ARGS" &
|
||||
else
|
||||
dotnet ${DOTNET_ARGS-} "$BINARY" $BINARY_ARGS &
|
||||
fi
|
||||
|
||||
# This will forward dotnet error code, set -e will abort the script if it's non-zero
|
||||
wait $!
|
||||
else
|
||||
# We're running ASF in non-headless mode, so we need STDIN to be operative
|
||||
# Start ASF in the foreground, trap won't work until process exit
|
||||
if [ -n "$BINARY_PREFIX" ]; then
|
||||
$BINARY_PREFIX "dotnet ${DOTNET_ARGS-} $BINARY $BINARY_ARGS"
|
||||
else
|
||||
dotnet ${DOTNET_ARGS-} "$BINARY" $BINARY_ARGS
|
||||
fi
|
||||
fi
|
|
@ -40,7 +40,6 @@ RUN dotnet --info && \
|
|||
esac && \
|
||||
if [ -n "${STEAM_TOKEN_DUMPER_TOKEN-}" ] && [ -f "${STEAM_TOKEN_DUMPER_NAME}/SharedInfo.cs" ]; then sed -i "s/STEAM_TOKEN_DUMPER_TOKEN/${STEAM_TOKEN_DUMPER_TOKEN}/g" "${STEAM_TOKEN_DUMPER_NAME}/SharedInfo.cs"; dotnet publish "${STEAM_TOKEN_DUMPER_NAME}" -c "$CONFIGURATION" -f "$NET_CORE_VERSION" -o "out/${STEAM_TOKEN_DUMPER_NAME}/${NET_CORE_VERSION}" -p:ASFVariant=docker -p:ContinuousIntegrationBuild=true -p:UseAppHost=false -r "$asf_variant" --nologo --no-self-contained; fi && \
|
||||
dotnet publish ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" -o "out/result" -p:ASFVariant=docker -p:ContinuousIntegrationBuild=true -p:UseAppHost=false -r "$asf_variant" --nologo --no-self-contained && \
|
||||
if [ -d "ArchiSteamFarm/overlay/generic" ]; then cp -pR "ArchiSteamFarm/overlay/generic/"* "out/result"; fi && \
|
||||
if [ -d "out/${STEAM_TOKEN_DUMPER_NAME}/${NET_CORE_VERSION}" ]; then mkdir -p "out/result/plugins/${STEAM_TOKEN_DUMPER_NAME}"; cp -pR "out/${STEAM_TOKEN_DUMPER_NAME}/${NET_CORE_VERSION}/"* "out/result/plugins/${STEAM_TOKEN_DUMPER_NAME}"; fi
|
||||
|
||||
FROM --platform=$TARGETPLATFORM mcr.microsoft.com/dotnet/aspnet:6.0${IMAGESUFFIX} AS runtime
|
||||
|
|
|
@ -38,10 +38,8 @@ RUN dotnet --info && \
|
|||
"arm64") asf_variant="${TARGETOS}-${TARGETARCH}" ;; \
|
||||
*) echo "ERROR: Unsupported CPU architecture: ${TARGETARCH}"; exit 1 ;; \
|
||||
esac && \
|
||||
if [ -n "${STEAM_TOKEN_DUMPER_TOKEN-}" ] && [ -f "${STEAM_TOKEN_DUMPER_NAME}/SharedInfo.cs" ]; then sed -i "s/STEAM_TOKEN_DUMPER_TOKEN/${STEAM_TOKEN_DUMPER_TOKEN}/g" "${STEAM_TOKEN_DUMPER_NAME}/SharedInfo.cs"; dotnet publish "${STEAM_TOKEN_DUMPER_NAME}" -c "$CONFIGURATION" -f "$NET_CORE_VERSION" -o "out/${STEAM_TOKEN_DUMPER_NAME}/${NET_CORE_VERSION}" -p:ASFVariant=docker -p:ContinuousIntegrationBuild=true -p:UseAppHost=false -r "$asf_variant" --nologo --no-self-contained; fi && \
|
||||
if [ -n "${STEAM_TOKEN_DUMPER_TOKEN-}" ] && [ -f "${STEAM_TOKEN_DUMPER_NAME}/SharedInfo.cs" ]; then sed -i "s/STEAM_TOKEN_DUMPER_TOKEN/${STEAM_TOKEN_DUMPER_TOKEN}/g" "${STEAM_TOKEN_DUMPER_NAME}/SharedInfo.cs"; dotnet publish "${STEAM_TOKEN_DUMPER_NAME}" -c "$CONFIGURATION" -f "$NET_CORE_VERSION" -o "out/${STEAM_TOKEN_DUMPER_NAME}/${NET_CORE_VERSION}" "-p:ASFVariant=${asf_variant}" -p:ContinuousIntegrationBuild=true -p:UseAppHost=false -r "$asf_variant" --nologo --no-self-contained; fi && \
|
||||
dotnet publish ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" -o "out/result" "-p:ASFVariant=${asf_variant}" -p:ContinuousIntegrationBuild=true -p:PublishSingleFile=true -p:PublishTrimmed=true -r "$asf_variant" --nologo --self-contained && \
|
||||
if [ -d "ArchiSteamFarm/overlay/${TARGETOS}" ]; then cp -pR "ArchiSteamFarm/overlay/${TARGETOS}/"* "out/result"; fi && \
|
||||
if [ -d "ArchiSteamFarm/overlay/${asf_variant}" ]; then cp -pR "ArchiSteamFarm/overlay/${asf_variant}/"* "out/result"; fi && \
|
||||
if [ -d "out/${STEAM_TOKEN_DUMPER_NAME}/${NET_CORE_VERSION}" ]; then mkdir -p "out/result/plugins/${STEAM_TOKEN_DUMPER_NAME}"; cp -pR "out/${STEAM_TOKEN_DUMPER_NAME}/${NET_CORE_VERSION}/"* "out/result/plugins/${STEAM_TOKEN_DUMPER_NAME}"; fi
|
||||
|
||||
FROM --platform=$TARGETPLATFORM mcr.microsoft.com/dotnet/runtime-deps:6.0${IMAGESUFFIX} AS runtime
|
||||
|
|
Loading…
Reference in a new issue