From 2a96afad5dbc759edbd61c5ffb8415f1692d4525 Mon Sep 17 00:00:00 2001 From: mosh Date: Mon, 9 Sep 2024 20:42:04 +0530 Subject: [PATCH] fix:azureDeploy --- .github/workflows/azure_deploy.yaml | 17 ++++++++++------- Dockerfile | 20 ++++++++++++++++++++ backend.sln | 25 +++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 7 deletions(-) create mode 100644 Dockerfile create mode 100644 backend.sln diff --git a/.github/workflows/azure_deploy.yaml b/.github/workflows/azure_deploy.yaml index 83579e3..509365a 100644 --- a/.github/workflows/azure_deploy.yaml +++ b/.github/workflows/azure_deploy.yaml @@ -12,19 +12,22 @@ jobs: - uses: actions/checkout@v4 - name: Set up .NET - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v3 with: - dotnet-version: '8.0.x' + dotnet-version: "8.0.x" - - name: Install dependencies - run: dotnet restore + - name: Restore + run: dotnet restore ./backend.sln - name: Build - run: dotnet publish -c Release -o app + run: dotnet build ./backend.sln --configuration Release --no-restore - - name: Deploy to Azure Web App + - name: Publish + run: dotnet publish ./backend.sln --configuration Release --no-build --output './publish'' + + - name: Deploy to Azure uses: azure/webapps-deploy@v2 with: app-name: apekade-server publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} - package: . + package: "./publish" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1208d54 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +# Use the official .NET SDK image to build the app +FROM mcr.microsoft.com/dotnet/sdk:8.0 +WORKDIR /app + +# Copy csproj and restore any dependencies (via NuGet) +COPY *.csproj ./ +RUN dotnet restore + +# Copy the entire project and build the app +COPY . ./ +RUN dotnet publish -c Release -o out + +# Use the official .NET runtime image to run the app +FROM mcr.microsoft.com/dotnet/aspnet:8.0 +WORKDIR /app +COPY --from=build /app/out . + +# Expose port 80 and define the entry point +EXPOSE 80 +ENTRYPOINT ["dotnet", "YourApp.dll"] diff --git a/backend.sln b/backend.sln new file mode 100644 index 0000000..4b8128e --- /dev/null +++ b/backend.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.002.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "apekade", "apekade.csproj", "{1394DB12-ACB1-4FAB-BA79-1F55F3E98EA9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1394DB12-ACB1-4FAB-BA79-1F55F3E98EA9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1394DB12-ACB1-4FAB-BA79-1F55F3E98EA9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1394DB12-ACB1-4FAB-BA79-1F55F3E98EA9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1394DB12-ACB1-4FAB-BA79-1F55F3E98EA9}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {193274AC-9C67-4DB0-AA22-B6619000A3FD} + EndGlobalSection +EndGlobal