From 99ff90ed3018eff93df45289cfdadf2174e3dbea Mon Sep 17 00:00:00 2001 From: EpicOfficer <9379778+EpicOfficer@users.noreply.github.com> Date: Sat, 5 Oct 2024 13:05:47 +0100 Subject: [PATCH] Remove unused files and update configuration handling Deleted obsolete Docker run configurations and removed `appsettings.Development.json` references. Updated Dockerfile and docker-compose files to use environment variables for configuration, simplifying deployment. --- ...end.run.xml => Blink3 Development.run.xml} | 11 ++------- .run/Blink3.API_Dockerfile.run.xml | 24 ------------------- .run/Blink3.Activity_Dockerfile.run.xml | 23 ------------------ .run/Blink3.Bot_Dockerfile.run.xml | 15 ------------ Blink3.API/Blink3.API.csproj | 4 ---- Blink3.Bot/Blink3.Bot.csproj | 4 ---- Blink3.Web/05-configure.sh | 11 +++++++++ Blink3.Web/Dockerfile | 6 ++++- Blink3.Web/wwwroot/appsettings.json | 4 ++-- Blink3.sln | 1 - Configuration/appsettings.Development.json | 2 -- docker-compose.development.yml | 5 ++-- docker-compose.yml | 5 ++-- 13 files changed, 26 insertions(+), 89 deletions(-) rename .run/{Blink3 Backend.run.xml => Blink3 Development.run.xml} (61%) delete mode 100644 .run/Blink3.API_Dockerfile.run.xml delete mode 100644 .run/Blink3.Activity_Dockerfile.run.xml delete mode 100644 .run/Blink3.Bot_Dockerfile.run.xml create mode 100644 Blink3.Web/05-configure.sh delete mode 100644 Configuration/appsettings.Development.json diff --git a/.run/Blink3 Backend.run.xml b/.run/Blink3 Development.run.xml similarity index 61% rename from .run/Blink3 Backend.run.xml rename to .run/Blink3 Development.run.xml index 0a76da8..eb03e5c 100644 --- a/.run/Blink3 Backend.run.xml +++ b/.run/Blink3 Development.run.xml @@ -1,21 +1,14 @@ - + - diff --git a/.run/Blink3.API_Dockerfile.run.xml b/.run/Blink3.API_Dockerfile.run.xml deleted file mode 100644 index d1d6cd6..0000000 --- a/.run/Blink3.API_Dockerfile.run.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/.run/Blink3.Activity_Dockerfile.run.xml b/.run/Blink3.Activity_Dockerfile.run.xml deleted file mode 100644 index e885c5f..0000000 --- a/.run/Blink3.Activity_Dockerfile.run.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/.run/Blink3.Bot_Dockerfile.run.xml b/.run/Blink3.Bot_Dockerfile.run.xml deleted file mode 100644 index 264bb60..0000000 --- a/.run/Blink3.Bot_Dockerfile.run.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/Blink3.API/Blink3.API.csproj b/Blink3.API/Blink3.API.csproj index 09eb181..91339c1 100644 --- a/Blink3.API/Blink3.API.csproj +++ b/Blink3.API/Blink3.API.csproj @@ -30,10 +30,6 @@ .dockerignore - - appsettings.Development.json - Always - appsettings.json Always diff --git a/Blink3.Bot/Blink3.Bot.csproj b/Blink3.Bot/Blink3.Bot.csproj index 6a47743..6b4d53f 100644 --- a/Blink3.Bot/Blink3.Bot.csproj +++ b/Blink3.Bot/Blink3.Bot.csproj @@ -14,10 +14,6 @@ .dockerignore - - appsettings.Development.json - Always - appsettings.json Always diff --git a/Blink3.Web/05-configure.sh b/Blink3.Web/05-configure.sh new file mode 100644 index 0000000..39ec910 --- /dev/null +++ b/Blink3.Web/05-configure.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +set -e + +echo "Replacing configuration values.." + +# Replace placeholders in appsettings.json with corresponding environment variables +sed -i "s|\${API_ADDRESS}|${API_ADDRESS}|" /usr/share/nginx/html/appsettings.json +sed -i "s|\${CLIENT_ID}|${CLIENT_ID}|" /usr/share/nginx/html/appsettings.json + +echo "Configuration values replaced!" \ No newline at end of file diff --git a/Blink3.Web/Dockerfile b/Blink3.Web/Dockerfile index 721d8fa..9eaf564 100644 --- a/Blink3.Web/Dockerfile +++ b/Blink3.Web/Dockerfile @@ -17,4 +17,8 @@ RUN dotnet publish "Blink3.Web.csproj" -c $BUILD_CONFIGURATION -o /app/publish / FROM base AS final WORKDIR /usr/share/nginx/html COPY --from=publish /app/publish/wwwroot . -COPY Blink3.Web/nginx.conf /etc/nginx/nginx.conf \ No newline at end of file +COPY Blink3.Web/nginx.conf /etc/nginx/nginx.conf + +# Add and run the initialization script +COPY Blink3.Web/05-configure.sh /docker-entrypoint.d/05-configure.sh +RUN chmod +x /docker-entrypoint.d/05-configure.sh \ No newline at end of file diff --git a/Blink3.Web/wwwroot/appsettings.json b/Blink3.Web/wwwroot/appsettings.json index 264c6c7..6b8f51d 100644 --- a/Blink3.Web/wwwroot/appsettings.json +++ b/Blink3.Web/wwwroot/appsettings.json @@ -1,4 +1,4 @@ { - "ApiAddress": "http://localhost:8288/", - "ClientID": "1223292750766674080" + "ApiAddress": "${API_ADDRESS}", + "ClientID": "${CLIENT_ID}" } \ No newline at end of file diff --git a/Blink3.sln b/Blink3.sln index 2bd1fd8..138f1e5 100644 --- a/Blink3.sln +++ b/Blink3.sln @@ -15,7 +15,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Files", "Solution docker-compose.development.yml = docker-compose.development.yml docker-compose.yml = docker-compose.yml Configuration\appsettings.json = Configuration\appsettings.json - Configuration\appsettings.Development.json = Configuration\appsettings.Development.json .github\workflows\build.yml = .github\workflows\build.yml .github\workflows\docker-image.yml = .github\workflows\docker-image.yml README.md = README.md diff --git a/Configuration/appsettings.Development.json b/Configuration/appsettings.Development.json deleted file mode 100644 index 7a73a41..0000000 --- a/Configuration/appsettings.Development.json +++ /dev/null @@ -1,2 +0,0 @@ -{ -} \ No newline at end of file diff --git a/docker-compose.development.yml b/docker-compose.development.yml index 4b72a8c..a8b308d 100644 --- a/docker-compose.development.yml +++ b/docker-compose.development.yml @@ -35,8 +35,9 @@ services: build: context: . dockerfile: Blink3.Web/Dockerfile - volumes: - - ./Blink3.Web/wwwroot/appsettings.json:/usr/share/nginx/html/appsettings.json + environment: + API_ADDRESS: "http://localhost:8288/" + CLIENT_ID: "1223292750766674080" ports: - "8280:80" diff --git a/docker-compose.yml b/docker-compose.yml index ea3d3ff..b9f9c66 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -67,8 +67,9 @@ services: web: restart: always image: ghcr.io/epicofficer/blink3.web:latest - volumes: - - ./appsettings.json:/usr/share/nginx/html/appsettings.json + environment: + API_ADDRESS: "https://api.blinkbot.io/" + CLIENT_ID: "1223292750766674080" depends_on: - api networks: