diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..3729ff0c --- /dev/null +++ b/.dockerignore @@ -0,0 +1,25 @@ +**/.classpath +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/azds.yaml +**/bin +**/charts +**/docker-compose* +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/obj +**/secrets.dev.yaml +**/values.dev.yaml +LICENSE +README.md \ No newline at end of file diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 9ec8ebba..b4f54742 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -12,8 +12,9 @@ schedules: always: true trigger: -- master - + branches: + include: + - master pool: vmImage: 'ubuntu-latest' diff --git a/samples/EShopSample/aspnet-core/src/EShopSample.DbMigrator/DbMigratorHostedService.cs b/samples/EShopSample/aspnet-core/src/EShopSample.DbMigrator/DbMigratorHostedService.cs index fb9c6f4e..b9ba7e43 100644 --- a/samples/EShopSample/aspnet-core/src/EShopSample.DbMigrator/DbMigratorHostedService.cs +++ b/samples/EShopSample/aspnet-core/src/EShopSample.DbMigrator/DbMigratorHostedService.cs @@ -10,6 +10,13 @@ namespace EShopSample.DbMigrator { public class DbMigratorHostedService : IHostedService { + private readonly IHostApplicationLifetime _hostApplicationLifetime; + + public DbMigratorHostedService(IHostApplicationLifetime hostApplicationLifetime) + { + _hostApplicationLifetime = hostApplicationLifetime; + } + public async Task StartAsync(CancellationToken cancellationToken) { using (var application = AbpApplicationFactory.Create(options => @@ -26,6 +33,8 @@ namespace EShopSample.DbMigrator .MigrateAsync(); application.Shutdown(); + + _hostApplicationLifetime.StopApplication(); } } diff --git a/samples/EShopSample/aspnet-core/src/EShopSample.Web/Dockerfile b/samples/EShopSample/aspnet-core/src/EShopSample.Web/Dockerfile new file mode 100644 index 00000000..f150a658 --- /dev/null +++ b/samples/EShopSample/aspnet-core/src/EShopSample.Web/Dockerfile @@ -0,0 +1,78 @@ +#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. + +FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base +WORKDIR /app +EXPOSE 80 +EXPOSE 443 + +FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build +WORKDIR /src +COPY ["samples/EShopSample/aspnet-core/src/EShopSample.Web/EShopSample.Web.csproj", "samples/EShopSample/aspnet-core/src/EShopSample.Web/"] +COPY ["integration/EasyAbp.EShop/src/EasyAbp.EShop.Web/EasyAbp.EShop.Web.csproj", "integration/EasyAbp.EShop/src/EasyAbp.EShop.Web/"] +COPY ["modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Web/EasyAbp.EShop.Payments.Web.csproj", "modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Web/"] +COPY ["modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application.Contracts/EasyAbp.EShop.Stores.Application.Contracts.csproj", "modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application.Contracts/"] +COPY ["modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/EasyAbp.EShop.Stores.Domain.Shared.csproj", "modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain.Shared/"] +COPY ["modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.HttpApi/EasyAbp.EShop.Payments.HttpApi.csproj", "modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.HttpApi/"] +COPY ["modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application.Contracts/EasyAbp.EShop.Payments.Application.Contracts.csproj", "modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application.Contracts/"] +COPY ["modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain.Shared/EasyAbp.EShop.Payments.Domain.Shared.csproj", "modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain.Shared/"] +COPY ["modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Web/EasyAbp.EShop.Plugins.Web.csproj", "modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Web/"] +COPY ["modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.HttpApi/EasyAbp.EShop.Plugins.HttpApi.csproj", "modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.HttpApi/"] +COPY ["modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Application.Contracts/EasyAbp.EShop.Plugins.Application.Contracts.csproj", "modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Application.Contracts/"] +COPY ["modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Domain.Shared/EasyAbp.EShop.Plugins.Domain.Shared.csproj", "modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Domain.Shared/"] +COPY ["integration/EasyAbp.EShop/src/EasyAbp.EShop.HttpApi/EasyAbp.EShop.HttpApi.csproj", "integration/EasyAbp.EShop/src/EasyAbp.EShop.HttpApi/"] +COPY ["integration/EasyAbp.EShop/src/EasyAbp.EShop.Application.Contracts/EasyAbp.EShop.Application.Contracts.csproj", "integration/EasyAbp.EShop/src/EasyAbp.EShop.Application.Contracts/"] +COPY ["modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application.Contracts/EasyAbp.EShop.Products.Application.Contracts.csproj", "modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application.Contracts/"] +COPY ["modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp.EShop.Products.Domain.Shared.csproj", "modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/"] +COPY ["modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application.Contracts/EasyAbp.EShop.Orders.Application.Contracts.csproj", "modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application.Contracts/"] +COPY ["modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp.EShop.Orders.Domain.Shared.csproj", "modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/"] +COPY ["integration/EasyAbp.EShop/src/EasyAbp.EShop.Domain.Shared/EasyAbp.EShop.Domain.Shared.csproj", "integration/EasyAbp.EShop/src/EasyAbp.EShop.Domain.Shared/"] +COPY ["modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.HttpApi/EasyAbp.EShop.Stores.HttpApi.csproj", "modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.HttpApi/"] +COPY ["modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.HttpApi/EasyAbp.EShop.Orders.HttpApi.csproj", "modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.HttpApi/"] +COPY ["modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.HttpApi/EasyAbp.EShop.Products.HttpApi.csproj", "modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.HttpApi/"] +COPY ["modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Web/EasyAbp.EShop.Orders.Web.csproj", "modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Web/"] +COPY ["modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/EasyAbp.EShop.Stores.Web.csproj", "modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/"] +COPY ["modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Web/EasyAbp.EShop.Products.Web.csproj", "modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Web/"] +COPY ["samples/EShopSample/aspnet-core/src/EShopSample.Application/EShopSample.Application.csproj", "samples/EShopSample/aspnet-core/src/EShopSample.Application/"] +COPY ["integration/EasyAbp.EShop/src/EasyAbp.EShop.Application/EasyAbp.EShop.Application.csproj", "integration/EasyAbp.EShop/src/EasyAbp.EShop.Application/"] +COPY ["integration/EasyAbp.EShop/src/EasyAbp.EShop.Domain/EasyAbp.EShop.Domain.csproj", "integration/EasyAbp.EShop/src/EasyAbp.EShop.Domain/"] +COPY ["modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Domain/EasyAbp.EShop.Plugins.Domain.csproj", "modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Domain/"] +COPY ["modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp.EShop.Orders.Domain.csproj", "modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/"] +COPY ["modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp.EShop.Products.Domain.csproj", "modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/"] +COPY ["modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/EasyAbp.EShop.Payments.Domain.csproj", "modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Domain/"] +COPY ["modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/EasyAbp.EShop.Stores.Domain.csproj", "modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Domain/"] +COPY ["modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/EasyAbp.EShop.Stores.Application.csproj", "modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Application/"] +COPY ["modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp.EShop.Products.Application.csproj", "modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/"] +COPY ["modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Application/EasyAbp.EShop.Plugins.Application.csproj", "modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.Application/"] +COPY ["modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp.EShop.Payments.Application.csproj", "modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/"] +COPY ["modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp.EShop.Orders.Application.csproj", "modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/"] +COPY ["samples/EShopSample/aspnet-core/src/EShopSample.Domain/EShopSample.Domain.csproj", "samples/EShopSample/aspnet-core/src/EShopSample.Domain/"] +COPY ["plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Domain/EasyAbp.EShop.Plugins.Baskets.Domain.csproj", "plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Domain/"] +COPY ["plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Domain.Shared/EasyAbp.EShop.Plugins.Baskets.Domain.Shared.csproj", "plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Domain.Shared/"] +COPY ["samples/EShopSample/aspnet-core/src/EShopSample.Domain.Shared/EShopSample.Domain.Shared.csproj", "samples/EShopSample/aspnet-core/src/EShopSample.Domain.Shared/"] +COPY ["samples/EShopSample/aspnet-core/src/EShopSample.Application.Contracts/EShopSample.Application.Contracts.csproj", "samples/EShopSample/aspnet-core/src/EShopSample.Application.Contracts/"] +COPY ["plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Application.Contracts/EasyAbp.EShop.Plugins.Baskets.Application.Contracts.csproj", "plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Application.Contracts/"] +COPY ["plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Application/EasyAbp.EShop.Plugins.Baskets.Application.csproj", "plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Application/"] +COPY ["plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Web/EasyAbp.EShop.Plugins.Baskets.Web.csproj", "plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Web/"] +COPY ["plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.HttpApi/EasyAbp.EShop.Plugins.Baskets.HttpApi.csproj", "plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.HttpApi/"] +COPY ["samples/EShopSample/aspnet-core/src/EShopSample.EntityFrameworkCore.DbMigrations/EShopSample.EntityFrameworkCore.DbMigrations.csproj", "samples/EShopSample/aspnet-core/src/EShopSample.EntityFrameworkCore.DbMigrations/"] +COPY ["samples/EShopSample/aspnet-core/src/EShopSample.EntityFrameworkCore/EShopSample.EntityFrameworkCore.csproj", "samples/EShopSample/aspnet-core/src/EShopSample.EntityFrameworkCore/"] +COPY ["integration/EasyAbp.EShop/src/EasyAbp.EShop.EntityFrameworkCore/EasyAbp.EShop.EntityFrameworkCore.csproj", "integration/EasyAbp.EShop/src/EasyAbp.EShop.EntityFrameworkCore/"] +COPY ["modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.EntityFrameworkCore/EasyAbp.EShop.Stores.EntityFrameworkCore.csproj", "modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.EntityFrameworkCore/"] +COPY ["modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.EntityFrameworkCore/EasyAbp.EShop.Products.EntityFrameworkCore.csproj", "modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.EntityFrameworkCore/"] +COPY ["modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.EntityFrameworkCore/EasyAbp.EShop.Orders.EntityFrameworkCore.csproj", "modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.EntityFrameworkCore/"] +COPY ["modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.EntityFrameworkCore/EasyAbp.EShop.Payments.EntityFrameworkCore.csproj", "modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.EntityFrameworkCore/"] +COPY ["modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.EntityFrameworkCore/EasyAbp.EShop.Plugins.EntityFrameworkCore.csproj", "modules/EasyAbp.EShop.Plugins/src/EasyAbp.EShop.Plugins.EntityFrameworkCore/"] +COPY ["plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.EntityFrameworkCore/EasyAbp.EShop.Plugins.Baskets.EntityFrameworkCore.csproj", "plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.EntityFrameworkCore/"] +COPY ["samples/EShopSample/aspnet-core/src/EShopSample.HttpApi/EShopSample.HttpApi.csproj", "samples/EShopSample/aspnet-core/src/EShopSample.HttpApi/"] +RUN dotnet restore "samples/EShopSample/aspnet-core/src/EShopSample.Web/EShopSample.Web.csproj" +COPY . . +WORKDIR "/src/samples/EShopSample/aspnet-core/src/EShopSample.Web" +RUN dotnet build "EShopSample.Web.csproj" -c Release -o /app/build + +FROM build AS publish +RUN dotnet publish "EShopSample.Web.csproj" -c Release -o /app/publish + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "EShopSample.Web.dll"] \ No newline at end of file diff --git a/samples/EShopSample/aspnet-core/src/EShopSample.Web/EShopSample.Web.csproj b/samples/EShopSample/aspnet-core/src/EShopSample.Web/EShopSample.Web.csproj index fccd439f..70227bf3 100644 --- a/samples/EShopSample/aspnet-core/src/EShopSample.Web/EShopSample.Web.csproj +++ b/samples/EShopSample/aspnet-core/src/EShopSample.Web/EShopSample.Web.csproj @@ -13,6 +13,8 @@ false true EShopSample-4681b4fd-151f-4221-84a4-929d86723e4c + Linux + ..\..\..\..\.. @@ -32,6 +34,7 @@ + diff --git a/samples/EShopSample/aspnet-core/src/EShopSample.Web/Properties/launchSettings.json b/samples/EShopSample/aspnet-core/src/EShopSample.Web/Properties/launchSettings.json index a5a55e40..c0721e7b 100644 --- a/samples/EShopSample/aspnet-core/src/EShopSample.Web/Properties/launchSettings.json +++ b/samples/EShopSample/aspnet-core/src/EShopSample.Web/Properties/launchSettings.json @@ -22,6 +22,13 @@ "ASPNETCORE_ENVIRONMENT": "Development" }, "applicationUrl": "https://localhost:44340/" + }, + "Docker": { + "commandName": "Docker", + "launchBrowser": true, + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", + "publishAllPorts": true, + "useSSL": true } } } \ No newline at end of file