diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..102b835 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +*/bin +*/obj +.git +.gitignore +Dockerfile +.dockerignore +.vs/ diff --git a/.githooks/pre-commit b/.githooks/pre-commit index f701376..d6ccb2b 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -3,5 +3,6 @@ # Use with: # # $> git config core.hooksPath .githooks -# -dotnet format --exclude vendor/ +if ! git diff --cached --quiet -- "*.cs"; then + dotnet format --verbosity quiet --exclude vendor/ +fi diff --git a/.github/workflows/server.yml b/.github/workflows/server.yml new file mode 100644 index 0000000..a5c0b99 --- /dev/null +++ b/.github/workflows/server.yml @@ -0,0 +1,27 @@ +name: Server +on: + push: + branches: + - master + paths-ignore: + - 'Pal.Client/**' +permissions: + packages: write +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Login to GitHub Package Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v4 + with: + push: true + tags: ghcr.io/${{ github.repository_owner }}/palace-pal:latest \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6e3f7ad --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build-env +WORKDIR /build +COPY Pal.Common/Pal.Common.csproj Pal.Common/ +COPY Pal.Server/Pal.Server.csproj Pal.Server/ +RUN dotnet restore Pal.Server/Pal.Server.csproj + +COPY . ./ +RUN dotnet publish Pal.Server/Pal.Server.csproj -c Release -o /dist + +FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS runtime +EXPOSE 5415 +ENV DOTNET_ENVIRONMENT=Production +ENV ASPNETCORE_URLS= +ENV DATADIRECTORY=/data +ENV Kestrel__Endpoints__Http2__Url=http://+:5415 + +RUN adduser --uid 2000 --disabled-password --group --no-create-home --quiet --system pal + +WORKDIR /app +COPY --from=build-env /dist . + +USER pal +ENTRYPOINT ["dotnet", "Pal.Server.dll"] \ No newline at end of file diff --git a/Pal.sln b/Pal.sln index 8ff8f7e..4e16275 100644 --- a/Pal.sln +++ b/Pal.sln @@ -11,7 +11,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Pal.Common", "Pal.Common\Pa EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{753F1752-AB41-4908-8359-C5809A79E5E7}" ProjectSection(SolutionItems) = preProject + Dockerfile = Dockerfile README.md = README.md + .github\workflows\server.yml = .github\workflows\server.yml EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ECommons", "vendor\ECommons\ECommons\ECommons.csproj", "{D0B37096-5BC3-41B0-8D81-203CBA3932B0}" diff --git a/README.md b/README.md index 3c53090..7dca07e 100644 --- a/README.md +++ b/README.md @@ -9,3 +9,18 @@ To install this plugin from my plugin repository, please check the Additionally, you **need to install Splatoon**, which is used to render the visible overlays. Please check [Splatoon's Installation Instructions](https://github.com/NightmareXIV/MyDalamudPlugins#installation). + +## Server Installation + +To run your own server, compile this plugin in DEBUG mode, load it as a dev plugin and configure the server as follows: + +```sh +# create the directory for the sqlite db & some keys +mkdir data + +# generate a random key (don't need to use openssl, any other base64 string is fine) +openssl rand -base64 48 > data/jwt.key + +# start the server +docker run -it --rm -v "$(pwd)/data:/data" -p 127.0.0.1:5415:5415 ghcr.io/carvelli/palace-pal +```