Skip to content

Commit

Permalink
DockerFile And Docker-compose added
Browse files Browse the repository at this point in the history
  • Loading branch information
babaktaremi committed Aug 7, 2023
1 parent a98df2d commit 29d60f5
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 3 deletions.
4 changes: 2 additions & 2 deletions CleanArcTemplate.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
<metadata>

<id>Bobby.CleanArcTemplate</id>
<version>4.0.6</version>
<version>4.1.0</version>
<title>Clean Architecture Solution Template</title>
<authors>BabakTaremi</authors>
<description>Clean Architecture Solution Template for and .NET 7. With many features available out of the box</description>
<summary>
Ready to develop template based on clean architecture principles. Supports ASP NET Core Identity integrated with JWE tokens, OTP authentication, stand alone plugin development, CQRS pattern using MediatR library and dynamic permission management system out of the box
</summary>
<releaseNotes>
Unit Test Setups added. Also database is now easy to test with Sqlite in memory feature.
Docker file and docker-compose file added. know you can build image and run the project on docker container
</releaseNotes>


Expand Down
34 changes: 34 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#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/aspnet:7.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["src/API/CleanArc.Web.Api/CleanArc.Web.Api.csproj", "src/API/CleanArc.Web.Api/"]
COPY ["src/API/CleanArc.WebFramework/CleanArc.WebFramework.csproj", "src/API/CleanArc.WebFramework/"]
COPY ["src/API/Plugins/CleanArc.Web.Plugins.Grpc/CleanArc.Web.Plugins.Grpc.csproj", "src/API/Plugins/CleanArc.Web.Plugins.Grpc/"]
COPY ["src/Core/CleanArc.Application/CleanArc.Application.csproj", "src/Core/CleanArc.Application/"]
COPY ["src/Core/CleanArc.Domain/CleanArc.Domain.csproj", "src/Core/CleanArc.Domain/"]
COPY ["src/Infrastructure/CleanArc.Infrastructure.CrossCutting/CleanArc.Infrastructure.CrossCutting.csproj", "src/Infrastructure/CleanArc.Infrastructure.CrossCutting/"]
COPY ["src/Infrastructure/CleanArc.Infrastructure.Identity/CleanArc.Infrastructure.Identity.csproj", "src/Infrastructure/CleanArc.Infrastructure.Identity/"]
COPY ["src/Infrastructure/CleanArc.Infrastructure.Persistence/CleanArc.Infrastructure.Persistence.csproj", "src/Infrastructure/CleanArc.Infrastructure.Persistence/"]
COPY ["src/Shared/CleanArc.SharedKernel/CleanArc.SharedKernel.csproj", "src/Shared/CleanArc.SharedKernel/"]
COPY ["src/Tests/CleanArc.Test.Infrastructure.Identity/CleanArc.Test.Infrastructure.Identity/CleanArc.Test.Infrastructure.Identity.csproj", "src/Tests/CleanArc.Test.Infrastructure.Identity/CleanArc.Test.Infrastructure.Identity/"]
COPY ["src/Tests/CleanArc.Tests.Setup/CleanArc.Tests.Setup.csproj", "src/Tests/CleanArc.Tests.Setup/"]


RUN dotnet restore "src/API/CleanArc.Web.Api/CleanArc.Web.Api.csproj"
COPY . .
WORKDIR "src/API/CleanArc.Web.Api"
RUN dotnet build "CleanArc.Web.Api.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "CleanArc.Web.Api.csproj" -c Release -o /app/publish /p:UseAppHost=false --no-restore

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "CleanArc.Web.Api.dll"]
22 changes: 22 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: "3.9" # optional since v1.27.0
services:
web_api:
image: bobby-cleanarc
container_name: bobby-cleanarc-app
environment:
"ASPNETCORE_URLS": "https://+;http://+"
"ASPNETCORE_Kestrel__Certificates__Default__Password": "Strong@Password"
"ASPNETCORE_Kestrel__Certificates__Default__Path": "/https/cleanarc.pfx"
ports:
- "5000:80"
- "5001:443"
volumes:
- ~/.aspnet/https:/https
sql:
image: "mcr.microsoft.com/mssql/server:2022-latest"
container_name: sql_server2022
ports: # not actually needed, because the two services are on the same network
- "1435:1433"
environment:
- ACCEPT_EULA=y
- SA_PASSWORD=A&VeryComplex123Password
6 changes: 6 additions & 0 deletions src/API/CleanArc.Web.Api/CleanArc.Web.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,10 @@
<ProjectReference Include="..\Plugins\CleanArc.Web.Plugins.Grpc\CleanArc.Web.Plugins.Grpc.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="Project.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
3 changes: 3 additions & 0 deletions src/API/CleanArc.Web.Api/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"ConnectionStrings": {
"SqlServer": "Data Source=localhost;Initial Catalog=CleanArc_DB_7_3;Integrated Security=true;Encrypt=False"
},
"Logging": {
"LogLevel": {
"Default": "Information",
Expand Down
2 changes: 1 addition & 1 deletion src/API/CleanArc.Web.Api/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"ConnectionStrings": {
"SqlServer": "Data Source=localhost;Initial Catalog=CleanArc_DB_7_3;Integrated Security=true;Encrypt=False"
"SqlServer": "Server=sql_server2022;Database=CleanArc_DB_Docker;User Id=SA;Password=A&VeryComplex123Password;MultipleActiveResultSets=true;encrypt=false"
},
"IdentitySettings": {
"SecretKey": "LongerThan-16Char-SecretKey",
Expand Down

0 comments on commit 29d60f5

Please sign in to comment.