diff --git a/Dockerfile b/Dockerfile index 4563a2cc..d431a61c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -36,11 +36,15 @@ RUN cargo build --release --all ########## RUNTIME CONTAINER ########## FROM alpine:3.18 +ARG PLAYIT_GUID=2000 +ARG PLAYIT_UUID=2000 RUN apk add --no-cache ca-certificates COPY --from=build-env /src/playit-agent/target/release/playit-cli /usr/local/bin/playit RUN mkdir /playit -COPY docker/entrypoint.sh /playit/entrypoint.sh -RUN chmod +x /playit/entrypoint.sh +COPY --chmod=1755 docker/entrypoint.sh /playit/ + +RUN addgroup -g ${PLAYIT_GUID} playit && adduser -S --no-create-home -u ${PLAYIT_UUID} -G playit playit +USER playit ENTRYPOINT ["/playit/entrypoint.sh"] diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index bafc159f..303859f6 100644 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -10,4 +10,18 @@ if [ -z "${SECRET_KEY}" ]; then fi fi -playit -s --secret "${SECRET_KEY}" --platform_docker start +term_handler() { + + echo "Shutting down Playit." + kill -SIGTERM $PlayitPID + wait $PlayitPID + exit +} +trap 'term_handler' SIGTERM + + +playit -s --secret "${SECRET_KEY}" --platform_docker start & + +PlayitPID=$! + +wait $PlayitPID \ No newline at end of file