From f17966c5928f4ac1c62a5d56b9e670126e8e706f Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Wed, 27 Dec 2023 20:30:33 +0100 Subject: [PATCH] Refactor project structure and Docker configurations The changes included in this commit are made to refactor the project structure and Docker configurations. Previously, the application was structured around the AllInOneWeb solution, but it has been split into Server.Web and ServerAndStudio.Web solutions for better separation of concerns. Additionally, the Docker configurations have been updated to reflect the new structure, which should streamline the build and deployment process. --- .github/workflows/all-in-one-web.yml | 61 ------------------- Elsa.sln | 16 +++-- docker/.dockerignore | 2 +- docker/ElsaServer.Dockerfile | 24 ++++++++ ...kerfile => ElsaServerAndStudio.Dockerfile} | 8 +-- .../DataSourceActivity.cs | 2 +- .../Elsa.Server.Web.csproj} | 0 .../Program.cs | 0 .../Properties/launchSettings.json | 0 .../README.md | 0 .../appsettings.json | 0 .../Elsa.ServerAndStudio.Web.csproj} | 0 .../Extensions/CorsOptionsExtensions.cs | 2 +- .../Pages/_Host.cshtml | 0 .../Program.cs | 2 +- .../Properties/launchSettings.json | 0 .../README.md | 0 .../appsettings.json | 0 18 files changed, 43 insertions(+), 74 deletions(-) delete mode 100644 .github/workflows/all-in-one-web.yml create mode 100644 docker/ElsaServer.Dockerfile rename docker/{Dockerfile => ElsaServerAndStudio.Dockerfile} (63%) rename src/bundles/{Elsa.WorkflowServer.Web => Elsa.Server.Web}/DataSourceActivity.cs (96%) rename src/bundles/{Elsa.WorkflowServer.Web/Elsa.WorkflowServer.Web.csproj => Elsa.Server.Web/Elsa.Server.Web.csproj} (100%) rename src/bundles/{Elsa.WorkflowServer.Web => Elsa.Server.Web}/Program.cs (100%) rename src/bundles/{Elsa.WorkflowServer.Web => Elsa.Server.Web}/Properties/launchSettings.json (100%) rename src/bundles/{Elsa.WorkflowServer.Web => Elsa.Server.Web}/README.md (100%) rename src/bundles/{Elsa.WorkflowServer.Web => Elsa.Server.Web}/appsettings.json (100%) rename src/bundles/{Elsa.AllInOne.Web/Elsa.AllInOne.Web.csproj => Elsa.ServerAndStudio.Web/Elsa.ServerAndStudio.Web.csproj} (100%) rename src/bundles/{Elsa.AllInOne.Web => Elsa.ServerAndStudio.Web}/Extensions/CorsOptionsExtensions.cs (95%) rename src/bundles/{Elsa.AllInOne.Web => Elsa.ServerAndStudio.Web}/Pages/_Host.cshtml (100%) rename src/bundles/{Elsa.AllInOne.Web => Elsa.ServerAndStudio.Web}/Program.cs (98%) rename src/bundles/{Elsa.AllInOne.Web => Elsa.ServerAndStudio.Web}/Properties/launchSettings.json (100%) rename src/bundles/{Elsa.AllInOne.Web => Elsa.ServerAndStudio.Web}/README.md (100%) rename src/bundles/{Elsa.AllInOne.Web => Elsa.ServerAndStudio.Web}/appsettings.json (100%) diff --git a/.github/workflows/all-in-one-web.yml b/.github/workflows/all-in-one-web.yml deleted file mode 100644 index 0d06f369a..000000000 --- a/.github/workflows/all-in-one-web.yml +++ /dev/null @@ -1,61 +0,0 @@ -name: Build and deploy All In One reference application as Docker image -on: - workflow_dispatch: - push: - branches: - - main - -jobs: - push_to_registry: - name: Push Docker image to Docker Hub - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - with: - platforms: all - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v2 - - - name: Docker meta - id: meta - uses: docker/metadata-action@v3 - with: - # list of Docker images to use as base name for tags - images: | - elsaworkflows/elsa-v3 - flavor: | - latest=true - # generate Docker tags based on the following events/attributes - tags: | - type=sha - - - name: Login to DockerHub - if: github.event_name != 'pull_request' - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_USER }} - password: ${{ secrets.DOCKER_PASS }} - - - name: Build and push - id: docker_build - uses: docker/build-push-action@v3 - with: - builder: ${{ steps.buildx.outputs.name }} - context: . - file: ./docker/Dockerfile - platforms: linux/amd64,linux/arm64,linux/arm/v7 - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache - - - name: Image digest - run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/Elsa.sln b/Elsa.sln index f13913620..403535162 100644 --- a/Elsa.sln +++ b/Elsa.sln @@ -12,7 +12,6 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "solution", "solution", "{7D21EB5E-D6B4-48A5-A9BC-A26387A65F0B}" ProjectSection(SolutionItems) = preProject .gitignore = .gitignore - .github\workflows\all-in-one-web.yml = .github\workflows\all-in-one-web.yml build-and-run-all-in-one-web-docker.sh = build-and-run-all-in-one-web-docker.sh common.props = common.props configureawait.props = configureawait.props @@ -20,7 +19,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "solution", "solution", "{7D icon.png = icon.png NuGet.Config = NuGet.Config packages.props = packages.props - .github\workflows\packages.yml = .github\workflows\packages.yml README.md = README.md update-migrations.sh = update-migrations.sh frameworks.props = frameworks.props @@ -64,9 +62,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.ProtoActor", "src\modu EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Dsl", "src\modules\Elsa.Dsl\Elsa.Dsl.csproj", "{78DAB791-8595-4612-8E9E-2248AF5B1862}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.AllInOne.Web", "src\bundles\Elsa.AllInOne.Web\Elsa.AllInOne.Web.csproj", "{E31F8955-B221-48AA-B301-6EE317D6F5B1}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.ServerAndStudio.Web", "src\bundles\Elsa.ServerAndStudio.Web\Elsa.ServerAndStudio.Web.csproj", "{E31F8955-B221-48AA-B301-6EE317D6F5B1}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.WorkflowServer.Web", "src\bundles\Elsa.WorkflowServer.Web\Elsa.WorkflowServer.Web.csproj", "{3C2752A7-EEBC-4ED4-B1BF-0FCF6E071BC2}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Server.Web", "src\bundles\Elsa.Server.Web\Elsa.Server.Web.csproj", "{3C2752A7-EEBC-4ED4-B1BF-0FCF6E071BC2}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Workflows.Api", "src\modules\Elsa.Workflows.Api\Elsa.Workflows.Api.csproj", "{C9539BD8-D2AE-4A8D-8281-71A05B3FBF31}" EndProject @@ -120,8 +118,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Samples.AspNet.Workflo EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docker", "docker", "{986E5482-0482-448C-B9E4-EC67A9474B85}" ProjectSection(SolutionItems) = preProject - docker\Dockerfile = docker\Dockerfile docker\.dockerignore = docker\.dockerignore + docker\ElsaServer.Dockerfile = docker\ElsaServer.Dockerfile + docker\ElsaServerAndStudio.Dockerfile = docker\ElsaServerAndStudio.Dockerfile EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Samples.AspNet.RunTaskIntegration", "src\samples\aspnet\Elsa.Samples.AspNet.RunTaskIntegration\Elsa.Samples.AspNet.RunTaskIntegration.csproj", "{51050209-EC2F-4DC7-8F46-07E22B7811CD}" @@ -286,6 +285,13 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.MassTransit.AzureServi EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Samples.AspNet.Heartbeats", "src\samples\aspnet\Elsa.Samples.AspNet.Heartbeats\Elsa.Samples.AspNet.Heartbeats.csproj", "{26888832-DBEA-4B23-8DC2-84478A702CC4}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "pipelines", "pipelines", "{B789B743-0FBE-4BBC-9F45-84C20C8D4814}" + ProjectSection(SolutionItems) = preProject + .github\workflows\elsa-server-and-studio.yml = .github\workflows\elsa-server-and-studio.yml + .github\workflows\elsa-server.yml = .github\workflows\elsa-server.yml + .github\workflows\packages.yml = .github\workflows\packages.yml + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/docker/.dockerignore b/docker/.dockerignore index cd967fc3a..af50df1a9 100644 --- a/docker/.dockerignore +++ b/docker/.dockerignore @@ -1,4 +1,4 @@ -**/.dockerignore +**/.dockerignore **/.env **/.git **/.gitignore diff --git a/docker/ElsaServer.Dockerfile b/docker/ElsaServer.Dockerfile new file mode 100644 index 000000000..40c415e91 --- /dev/null +++ b/docker/ElsaServer.Dockerfile @@ -0,0 +1,24 @@ +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-bookworm-slim AS build +WORKDIR /source + +# copy sources. +COPY src/. ./src +COPY ./NuGet.Config ./ +COPY *.props ./ + +# restore packages. +RUN dotnet restore "./src/bundles/Elsa.Server.Web/Elsa.Server.Web.csproj" + +# build and publish (UseAppHost=false creates platform independent binaries). +WORKDIR /source/src/bundles/Elsa.AllInOne.Web +RUN dotnet build "Elsa.Server.Web.csproj" -c Release -o /app/build +RUN dotnet publish "Elsa.Server.Web.csproj" -c Release -o /app/publish /p:UseAppHost=false --no-restore -f net8.0 + +# move binaries into smaller base image. +FROM mcr.microsoft.com/dotnet/aspnet:8.0-bookworm-slim AS base +WORKDIR /app +COPY --from=build /app/publish ./ + +EXPOSE 80/tcp +EXPOSE 443/tcp +ENTRYPOINT ["dotnet", "Elsa.Server.Web.dll"] diff --git a/docker/Dockerfile b/docker/ElsaServerAndStudio.Dockerfile similarity index 63% rename from docker/Dockerfile rename to docker/ElsaServerAndStudio.Dockerfile index 4b84a3eb8..3bcfc23d3 100644 --- a/docker/Dockerfile +++ b/docker/ElsaServerAndStudio.Dockerfile @@ -8,12 +8,12 @@ COPY *.props ./ # restore packages. RUN dotnet restore "./src/bundles/ElsaStudioWebAssembly/ElsaStudioWebAssembly.csproj" -RUN dotnet restore "./src/bundles/Elsa.AllInOne.Web/Elsa.AllInOne.Web.csproj" +RUN dotnet restore "./src/bundles/Elsa.ServerAndStudio.Web/Elsa.ServerAndStudio.Web.csproj" # build and publish (UseAppHost=false creates platform independent binaries). WORKDIR /source/src/bundles/Elsa.AllInOne.Web -RUN dotnet build "Elsa.AllInOne.Web.csproj" -c Release -o /app/build -RUN dotnet publish "Elsa.AllInOne.Web.csproj" -c Release -o /app/publish /p:UseAppHost=false --no-restore -f net8.0 +RUN dotnet build "Elsa.ServerAndStudio.Web.csproj" -c Release -o /app/build +RUN dotnet publish "Elsa.ServerAndStudio.Web.csproj" -c Release -o /app/publish /p:UseAppHost=false --no-restore -f net8.0 # move binaries into smaller base image. FROM mcr.microsoft.com/dotnet/aspnet:8.0-bookworm-slim AS base @@ -22,4 +22,4 @@ COPY --from=build /app/publish ./ EXPOSE 80/tcp EXPOSE 443/tcp -ENTRYPOINT ["dotnet", "Elsa.AllInOne.Web.dll"] +ENTRYPOINT ["dotnet", "Elsa.ServerAndStudio.Web.dll"] diff --git a/src/bundles/Elsa.WorkflowServer.Web/DataSourceActivity.cs b/src/bundles/Elsa.Server.Web/DataSourceActivity.cs similarity index 96% rename from src/bundles/Elsa.WorkflowServer.Web/DataSourceActivity.cs rename to src/bundles/Elsa.Server.Web/DataSourceActivity.cs index 764f1fbb9..35b8c1f31 100644 --- a/src/bundles/Elsa.WorkflowServer.Web/DataSourceActivity.cs +++ b/src/bundles/Elsa.Server.Web/DataSourceActivity.cs @@ -4,7 +4,7 @@ using Elsa.Workflows; using Elsa.Workflows.Attributes; using Elsa.Workflows.Models; -namespace Elsa.WorkflowServer.Web; +namespace Elsa.Server.Web; [Activity("Demo", "Data Source", "Generates a collection of random strings.")] public class DataSourceActivity : CodeActivity> diff --git a/src/bundles/Elsa.WorkflowServer.Web/Elsa.WorkflowServer.Web.csproj b/src/bundles/Elsa.Server.Web/Elsa.Server.Web.csproj similarity index 100% rename from src/bundles/Elsa.WorkflowServer.Web/Elsa.WorkflowServer.Web.csproj rename to src/bundles/Elsa.Server.Web/Elsa.Server.Web.csproj diff --git a/src/bundles/Elsa.WorkflowServer.Web/Program.cs b/src/bundles/Elsa.Server.Web/Program.cs similarity index 100% rename from src/bundles/Elsa.WorkflowServer.Web/Program.cs rename to src/bundles/Elsa.Server.Web/Program.cs diff --git a/src/bundles/Elsa.WorkflowServer.Web/Properties/launchSettings.json b/src/bundles/Elsa.Server.Web/Properties/launchSettings.json similarity index 100% rename from src/bundles/Elsa.WorkflowServer.Web/Properties/launchSettings.json rename to src/bundles/Elsa.Server.Web/Properties/launchSettings.json diff --git a/src/bundles/Elsa.WorkflowServer.Web/README.md b/src/bundles/Elsa.Server.Web/README.md similarity index 100% rename from src/bundles/Elsa.WorkflowServer.Web/README.md rename to src/bundles/Elsa.Server.Web/README.md diff --git a/src/bundles/Elsa.WorkflowServer.Web/appsettings.json b/src/bundles/Elsa.Server.Web/appsettings.json similarity index 100% rename from src/bundles/Elsa.WorkflowServer.Web/appsettings.json rename to src/bundles/Elsa.Server.Web/appsettings.json diff --git a/src/bundles/Elsa.AllInOne.Web/Elsa.AllInOne.Web.csproj b/src/bundles/Elsa.ServerAndStudio.Web/Elsa.ServerAndStudio.Web.csproj similarity index 100% rename from src/bundles/Elsa.AllInOne.Web/Elsa.AllInOne.Web.csproj rename to src/bundles/Elsa.ServerAndStudio.Web/Elsa.ServerAndStudio.Web.csproj diff --git a/src/bundles/Elsa.AllInOne.Web/Extensions/CorsOptionsExtensions.cs b/src/bundles/Elsa.ServerAndStudio.Web/Extensions/CorsOptionsExtensions.cs similarity index 95% rename from src/bundles/Elsa.AllInOne.Web/Extensions/CorsOptionsExtensions.cs rename to src/bundles/Elsa.ServerAndStudio.Web/Extensions/CorsOptionsExtensions.cs index 2a591a583..d7ab5e203 100644 --- a/src/bundles/Elsa.AllInOne.Web/Extensions/CorsOptionsExtensions.cs +++ b/src/bundles/Elsa.ServerAndStudio.Web/Extensions/CorsOptionsExtensions.cs @@ -1,6 +1,6 @@ using Microsoft.AspNetCore.Cors.Infrastructure; -namespace Elsa.AllInOne.Web.Extensions; +namespace Elsa.ServerAndStudio.Web.Extensions; public static class CorsOptionsExtensions { diff --git a/src/bundles/Elsa.AllInOne.Web/Pages/_Host.cshtml b/src/bundles/Elsa.ServerAndStudio.Web/Pages/_Host.cshtml similarity index 100% rename from src/bundles/Elsa.AllInOne.Web/Pages/_Host.cshtml rename to src/bundles/Elsa.ServerAndStudio.Web/Pages/_Host.cshtml diff --git a/src/bundles/Elsa.AllInOne.Web/Program.cs b/src/bundles/Elsa.ServerAndStudio.Web/Program.cs similarity index 98% rename from src/bundles/Elsa.AllInOne.Web/Program.cs rename to src/bundles/Elsa.ServerAndStudio.Web/Program.cs index a2de213e1..eb19d40ac 100644 --- a/src/bundles/Elsa.AllInOne.Web/Program.cs +++ b/src/bundles/Elsa.ServerAndStudio.Web/Program.cs @@ -1,4 +1,4 @@ -using Elsa.AllInOne.Web.Extensions; +using Elsa.ServerAndStudio.Web.Extensions; using Elsa.EntityFrameworkCore.Extensions; using Elsa.EntityFrameworkCore.Modules.Management; using Elsa.EntityFrameworkCore.Modules.Runtime; diff --git a/src/bundles/Elsa.AllInOne.Web/Properties/launchSettings.json b/src/bundles/Elsa.ServerAndStudio.Web/Properties/launchSettings.json similarity index 100% rename from src/bundles/Elsa.AllInOne.Web/Properties/launchSettings.json rename to src/bundles/Elsa.ServerAndStudio.Web/Properties/launchSettings.json diff --git a/src/bundles/Elsa.AllInOne.Web/README.md b/src/bundles/Elsa.ServerAndStudio.Web/README.md similarity index 100% rename from src/bundles/Elsa.AllInOne.Web/README.md rename to src/bundles/Elsa.ServerAndStudio.Web/README.md diff --git a/src/bundles/Elsa.AllInOne.Web/appsettings.json b/src/bundles/Elsa.ServerAndStudio.Web/appsettings.json similarity index 100% rename from src/bundles/Elsa.AllInOne.Web/appsettings.json rename to src/bundles/Elsa.ServerAndStudio.Web/appsettings.json