From 8459f7938dc003d0ded8e6aada67cab92d4eb215 Mon Sep 17 00:00:00 2001 From: Daniel Triendl Date: Fri, 10 Apr 2026 12:01:58 +0200 Subject: [PATCH] Move userscript to server --- .dockerignore | 3 +++ client/config/metadata.cjs | 2 +- client/readme.md | 8 ++------ .../src/CPATapi.Server/publish.bat => publish.bat | 2 +- server/src/CPATapi.Server/CPATapi.Server.csproj | 4 ++++ server/src/CPATapi.Server/Dockerfile | 15 ++++++++++++--- server/src/CPATapi.Server/Program.cs | 1 + 7 files changed, 24 insertions(+), 11 deletions(-) create mode 100644 .dockerignore rename server/src/CPATapi.Server/publish.bat => publish.bat (73%) diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..db838fa --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +*Dockerfile* +*docker-compose* +node_modules diff --git a/client/config/metadata.cjs b/client/config/metadata.cjs index b9ad4da..19f72ec 100644 --- a/client/config/metadata.cjs +++ b/client/config/metadata.cjs @@ -7,7 +7,7 @@ module.exports = { author: pkg.author, copyright: 'Copyright CP Solutions GmbH', source: pkg.repository.url, - downloadURL: `${pkg.repository.url}/raw/branch/master/3CX_TAPI.user.js`, + downloadURL: 'https://3cxtapi.cp-austria.at/3CX_TAPI.user.js', match: [ 'https://192.168.0.154:5001/*', 'https://cpsolution.my3cx.at:5001/*' diff --git a/client/readme.md b/client/readme.md index bd16fbf..6d5c12a 100644 --- a/client/readme.md +++ b/client/readme.md @@ -38,15 +38,11 @@ just install a package and import it in your js file. webpack will pack them wit npm run build ``` -`dist/index.prod.user.js` is the final script. +`dist/3CX TAPI.prod.user.js` is the final script. ## distribution -``` -cp "dist/3CX TAPI.prod.user.js" ../3CX_TAPI.user.js -``` - -And commit 3CX_TAPI.user.js +Userscript is included in server docker image ## see also diff --git a/server/src/CPATapi.Server/publish.bat b/publish.bat similarity index 73% rename from server/src/CPATapi.Server/publish.bat rename to publish.bat index 4d70f36..0ae302d 100644 --- a/server/src/CPATapi.Server/publish.bat +++ b/publish.bat @@ -2,7 +2,7 @@ setlocal cd /d %~dp0 -docker build -t source.cp-austria.at/cpatrd/3cx_tapi:latest -f Dockerfile .. +docker build -t source.cp-austria.at/cpatrd/3cx_tapi:latest -f server/src/CPATapi.Server/Dockerfile . if errorlevel 1 ( echo. echo ERROR: Docker build failed! diff --git a/server/src/CPATapi.Server/CPATapi.Server.csproj b/server/src/CPATapi.Server/CPATapi.Server.csproj index 0e88536..ee797d1 100644 --- a/server/src/CPATapi.Server/CPATapi.Server.csproj +++ b/server/src/CPATapi.Server/CPATapi.Server.csproj @@ -26,4 +26,8 @@ + + + + diff --git a/server/src/CPATapi.Server/Dockerfile b/server/src/CPATapi.Server/Dockerfile index f6ba016..3ee3e8a 100644 --- a/server/src/CPATapi.Server/Dockerfile +++ b/server/src/CPATapi.Server/Dockerfile @@ -6,14 +6,22 @@ USER $APP_UID WORKDIR /app EXPOSE 8080 +# This stage is used to build the userscript project +FROM node:lts-alpine AS build-userscript +WORKDIR /src +COPY client . +RUN npm ci +RUN npm run build +#RUN ls -la /src/dist + # This stage is used to build the service project FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build ARG BUILD_CONFIGURATION=Release WORKDIR /src -COPY ["CPATapi.Server/CPATapi.Server.csproj", "CPATapi.Server/"] -RUN dotnet restore "CPATapi.Server/CPATapi.Server.csproj" +COPY ["server/src/CPATapi.Server/CPATapi.Server.csproj", "server/src/CPATapi.Server/CPATapi.Server.csproj"] +RUN dotnet restore "server/src/CPATapi.Server/CPATapi.Server.csproj" COPY . . -WORKDIR "/src/CPATapi.Server" +WORKDIR "/src/server/src/CPATapi.Server" RUN dotnet build "./CPATapi.Server.csproj" -c $BUILD_CONFIGURATION -o /app/build # This stage is used to publish the service project to be copied to the final stage @@ -25,4 +33,5 @@ RUN dotnet publish "./CPATapi.Server.csproj" -c $BUILD_CONFIGURATION -o /app/pub FROM base AS final WORKDIR /app COPY --from=publish /app/publish . +COPY --from=build-userscript ["/src/dist/3CX TAPI.prod.user.js", "./wwwroot/3CX_TAPI.user.js"] ENTRYPOINT ["dotnet", "CPATapi.Server.dll"] diff --git a/server/src/CPATapi.Server/Program.cs b/server/src/CPATapi.Server/Program.cs index 7116cf3..d8af1de 100644 --- a/server/src/CPATapi.Server/Program.cs +++ b/server/src/CPATapi.Server/Program.cs @@ -30,6 +30,7 @@ if (app.Environment.IsDevelopment()) app.UseDeveloperExceptionPage(); } +app.MapStaticAssets(); app.MapOpenApi(); app.UseSwaggerUI(options => {