Skip to content

Commit 12954f0

Browse files
authored
Feat/add containerization (#6)
* add docker support for containerization * put dockerignore in root
1 parent 511d89d commit 12954f0

File tree

4 files changed

+105
-0
lines changed

4 files changed

+105
-0
lines changed

.dockerignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
**/.classpath
2+
**/.dockerignore
3+
**/.env
4+
**/.git
5+
**/.gitignore
6+
**/.project
7+
**/.settings
8+
**/.toolstarget
9+
**/.vs
10+
**/.vscode
11+
**/*.*proj.user
12+
**/*.dbmdl
13+
**/*.jfm
14+
**/azds.yaml
15+
**/bin
16+
**/charts
17+
**/docker-compose*
18+
**/Dockerfile*
19+
**/node_modules
20+
**/npm-debug.log
21+
**/obj
22+
**/secrets.dev.yaml
23+
**/values.dev.yaml
24+
LICENSE
25+
README.md
26+
!**/.gitignore
27+
!.git/HEAD
28+
!.git/config
29+
!.git/packed-refs
30+
!.git/refs/heads/**

Dockerfile

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
2+
WORKDIR /src
3+
4+
# Copy the solution file
5+
COPY src/DesignPatternsLibrary.sln .
6+
7+
# Copy the main project file
8+
COPY src/DesignPatternsLibrary/DesignPatternsLibrary.csproj DesignPatternsLibrary/
9+
10+
# Copy referenced projects' CSPROJ files
11+
COPY ["src/AdditionalPatterns/EventAggregator/StoreManagement/StoreManagement.csproj", "AdditionalPatterns/EventAggregator/StoreManagement/"]
12+
COPY ["src/BuildingBlocks/BuildingBlocks.csproj", "BuildingBlocks/"]
13+
COPY ["src/AdditionalPatterns/FluentInterface/FluentInterfaceLibrary/FluentInterfaceLibrary.csproj", "AdditionalPatterns/FluentInterface/FluentInterfaceLibrary/"]
14+
COPY ["src/AdditionalPatterns/Interpreter/InterpreterLibrary/InterpreterLibrary.csproj", "AdditionalPatterns/Interpreter/InterpreterLibrary/"]
15+
COPY ["src/AdditionalPatterns/LazyLoad/LazyLoadLibrary/LazyLoadLibrary.csproj", "AdditionalPatterns/LazyLoad/LazyLoadLibrary/"]
16+
COPY ["src/AdditionalPatterns/NullObject/NullObjectLibrary/NullObjectLibrary.csproj", "AdditionalPatterns/NullObject/NullObjectLibrary/"]
17+
COPY ["src/AdditionalPatterns/Repository/OrderManagement/OrderManagement.csproj", "AdditionalPatterns/Repository/OrderManagement/"]
18+
COPY ["src/AdditionalPatterns/Rules/RulesLibrary/RulesLibrary.csproj", "AdditionalPatterns/Rules/RulesLibrary/"]
19+
COPY ["src/AdditionalPatterns/ServiceLocator/OrderProcessing/OrderProcessing.csproj", "AdditionalPatterns/ServiceLocator/OrderProcessing/"]
20+
COPY ["src/AdditionalPatterns/Specification/ProductSpecification/ProductSpecification.csproj", "AdditionalPatterns/Specification/ProductSpecification/"]
21+
COPY ["src/AdditionalPatterns/UnitOfWork/UnitOfWorkLibrary/UnitOfWorkLibrary.csproj", "AdditionalPatterns/UnitOfWork/UnitOfWorkLibrary/"]
22+
COPY ["src/BehavioralPatterns/ChainOfResponsibility/ChainOfResponsibilityLibrary/ChainOfResponsibilityLibrary.csproj", "BehavioralPatterns/ChainOfResponsibility/ChainOfResponsibilityLibrary/"]
23+
COPY ["src/BehavioralPatterns/Command/CommandLibrary/CommandLibrary.csproj", "BehavioralPatterns/Command/CommandLibrary/"]
24+
COPY ["src/BehavioralPatterns/Iterator/IteratorLibrary/IteratorLibrary.csproj", "BehavioralPatterns/Iterator/IteratorLibrary/"]
25+
COPY ["src/BehavioralPatterns/Mediator/MediatorLibrary/MediatorLibrary.csproj", "BehavioralPatterns/Mediator/MediatorLibrary/"]
26+
COPY ["src/BehavioralPatterns/Memento/MementoLibrary/MementoLibrary.csproj", "BehavioralPatterns/Memento/MementoLibrary/"]
27+
COPY ["src/BehavioralPatterns/Observer/ObserverLibrary/ObserverLibrary.csproj", "BehavioralPatterns/Observer/ObserverLibrary/"]
28+
COPY ["src/BehavioralPatterns/State/StateLibrary/StateLibrary.csproj", "BehavioralPatterns/State/StateLibrary/"]
29+
COPY ["src/BehavioralPatterns/Strategy/StrategyLibrary/StrategyLibrary.csproj", "BehavioralPatterns/Strategy/StrategyLibrary/"]
30+
COPY ["src/BehavioralPatterns/TemplateMethod/TemplateMethodLibrary/TemplateMethodLibrary.csproj", "BehavioralPatterns/TemplateMethod/TemplateMethodLibrary/"]
31+
COPY ["src/BehavioralPatterns/Visitor/VisitorLibrary/VisitorLibrary.csproj", "BehavioralPatterns/Visitor/VisitorLibrary/"]
32+
COPY ["src/CreationalPatterns/AbstractFactory/MealSimpleFactory/MealSimpleFactory.csproj", "CreationalPatterns/AbstractFactory/MealSimpleFactory/"]
33+
COPY ["src/CreationalPatterns/AbstractFactory/RestaurantAbstractFactory/RestaurantAbstractFactory.csproj", "CreationalPatterns/AbstractFactory/RestaurantAbstractFactory/"]
34+
COPY ["src/CreationalPatterns/Builder/CustomSandwichBuilder/CustomSandwichBuilder.csproj", "CreationalPatterns/Builder/CustomSandwichBuilder/"]
35+
COPY ["src/CreationalPatterns/FactoryMethod/RestaurantManagement/RestaurantManagement.csproj", "CreationalPatterns/FactoryMethod/RestaurantManagement/"]
36+
COPY ["src/CreationalPatterns/Prototype/PrototypeLibrary/PrototypeLibrary.csproj", "CreationalPatterns/Prototype/PrototypeLibrary/"]
37+
COPY ["src/CreationalPatterns/Singleton/Greeter/Greeter.csproj", "CreationalPatterns/Singleton/Greeter/"]
38+
COPY ["src/StructuralPatterns/Adapter/AdapterLibrary/AdapterLibrary.csproj", "StructuralPatterns/Adapter/AdapterLibrary/"]
39+
COPY ["src/StructuralPatterns/Bridge/BridgeLibrary/BridgeLibrary.csproj", "StructuralPatterns/Bridge/BridgeLibrary/"]
40+
COPY ["src/StructuralPatterns/Composite/CompositeLibrary/CompositeLibrary.csproj", "StructuralPatterns/Composite/CompositeLibrary/"]
41+
COPY ["src/StructuralPatterns/Decorator/DecoratorLibrary/DecoratorLibrary.csproj", "StructuralPatterns/Decorator/DecoratorLibrary/"]
42+
COPY ["src/StructuralPatterns/Facade/FacadeLibrary/FacadeLibrary.csproj", "StructuralPatterns/Facade/FacadeLibrary/"]
43+
COPY ["src/StructuralPatterns/Flyweight/FlyweightLibrary/FlyweightLibrary.csproj", "StructuralPatterns/Flyweight/FlyweightLibrary/"]
44+
COPY ["src/StructuralPatterns/Proxy/ProxyLibrary/ProxyLibrary.csproj", "StructuralPatterns/Proxy/ProxyLibrary/"]
45+
46+
# Restore the NuGet packages for the entire solution
47+
RUN dotnet restore
48+
49+
# Copy the source code for the entire solution
50+
COPY src/ .
51+
52+
# Build and publish the main project
53+
RUN dotnet publish DesignPatternsLibrary/DesignPatternsLibrary.csproj -c Release -o /app/publish
54+
55+
# Generate the runtime image
56+
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS final
57+
WORKDIR /app
58+
COPY --from=build /app/publish .
59+
ENTRYPOINT ["dotnet", "DesignPatternsLibrary.dll"]

src/DesignPatternsLibrary/DesignPatternsLibrary.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@
55
<TargetFramework>net6.0</TargetFramework>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
8+
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
89
</PropertyGroup>
910

11+
<ItemGroup>
12+
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.6" />
13+
</ItemGroup>
14+
1015
<ItemGroup>
1116
<ProjectReference Include="..\AdditionalPatterns\EventAggregator\StoreManagement\StoreManagement.csproj" />
1217
<ProjectReference Include="..\AdditionalPatterns\FluentInterface\FluentInterfaceLibrary\FluentInterfaceLibrary.csproj" />
@@ -28,6 +33,7 @@
2833
<ProjectReference Include="..\BehavioralPatterns\Strategy\StrategyLibrary\StrategyLibrary.csproj" />
2934
<ProjectReference Include="..\BehavioralPatterns\TemplateMethod\TemplateMethodLibrary\TemplateMethodLibrary.csproj" />
3035
<ProjectReference Include="..\BehavioralPatterns\Visitor\VisitorLibrary\VisitorLibrary.csproj" />
36+
<ProjectReference Include="..\BuildingBlocks\BuildingBlocks.csproj" />
3137
<ProjectReference Include="..\CreationalPatterns\AbstractFactory\MealSimpleFactory\MealSimpleFactory.csproj" />
3238
<ProjectReference Include="..\CreationalPatterns\AbstractFactory\RestaurantAbstractFactory\RestaurantAbstractFactory.csproj" />
3339
<ProjectReference Include="..\CreationalPatterns\Builder\CustomSandwichBuilder\CustomSandwichBuilder.csproj" />
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"profiles": {
3+
"DesignPatternsLibrary": {
4+
"commandName": "Project"
5+
},
6+
"Container (Dockerfile)": {
7+
"commandName": "Docker"
8+
}
9+
}
10+
}

0 commit comments

Comments
 (0)