From 8e5b987b2ca4809247274e8eca90f8b6d4abcbde Mon Sep 17 00:00:00 2001 From: spiral Date: Sun, 10 Apr 2022 10:57:51 -0400 Subject: [PATCH] feat: add Nomad run script --- .dockerignore | 1 + Dockerfile | 5 +++++ scripts/run-clustered.sh | 15 +++++++++++++++ 3 files changed, 21 insertions(+) create mode 100755 scripts/run-clustered.sh diff --git a/.dockerignore b/.dockerignore index d5b32e97..1812f56f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -8,6 +8,7 @@ !nuget.config !.git !proto +!scripts/run-clustered.sh # Re-exclude host build artifact directories **/bin diff --git a/Dockerfile b/Dockerfile index 32c26a63..3930b9e5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build + WORKDIR /app # Restore/fetch dependencies excluding app code to make use of caching @@ -24,6 +25,10 @@ LABEL org.opencontainers.image.source = "https://github.com/xSke/PluralKit" WORKDIR /app COPY --from=build /app ./ +# Runtime dependency in prod +RUN apt update && apt install -y curl +ADD scripts/run-clustered.sh / + # Allow overriding CMD from eg. docker-compose to run API layer too ENTRYPOINT ["dotnet"] CMD ["bin/PluralKit.Bot.dll"] diff --git a/scripts/run-clustered.sh b/scripts/run-clustered.sh new file mode 100755 index 00000000..24150c1c --- /dev/null +++ b/scripts/run-clustered.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +notify () { + curl http://172.17.0.1:8081/notify -d "$1" +} + +curl http://172.17.0.1:8081/config > pluralkit.conf + +notify "Cluster $NOMAD_ALLOC_INDEX starting" + +export PluralKit__Bot__Cluster__NodeName="pluralkit-$NOMAD_ALLOC_INDEX" + +dotnet bin/PluralKit.Bot.dll + +notify "Cluster $NOMAD_ALLOC_INDEX exited with code $?"