Skip to content

Commit

Permalink
added docker files
Browse files Browse the repository at this point in the history
  • Loading branch information
bezzad committed Jun 7, 2023
1 parent 4231b9e commit 0925d30
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 1 deletion.
25 changes: 25 additions & 0 deletions src/.dockerignore
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions src/Captcha.Net.Sample/Captcha.Net.Sample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Captcha.Net\Captcha.Net.csproj" />
</ItemGroup>
Expand Down
21 changes: 21 additions & 0 deletions src/Captcha.Net.Sample/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/runtime:6.0 AS base
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["Captcha.Net.Sample/Captcha.Net.Sample.csproj", "Captcha.Net.Sample/"]
COPY ["Captcha.Net/Captcha.Net.csproj", "Captcha.Net/"]
RUN dotnet restore "Captcha.Net.Sample/Captcha.Net.Sample.csproj"
COPY . .
WORKDIR "/src/Captcha.Net.Sample"
RUN dotnet build "Captcha.Net.Sample.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "Captcha.Net.Sample.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Captcha.Net.Sample.dll"]
2 changes: 1 addition & 1 deletion src/Captcha.Net.Sample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
var captchaGenerator = new CaptchaGenerator();
var currentDirectory = Directory.CreateDirectory("captcha");

for (int i = 0; i < 100; i++)
for (int i = 0; i < 1000; i++)
{
var key = captchaGenerator.GenerateCaptchaCode();
var result = captchaGenerator.GenerateCaptchaImage(200, 100, key);
Expand Down
3 changes: 3 additions & 0 deletions src/Captcha.Net.Sample/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"WSL": {
"commandName": "WSL2",
"distributionName": ""
},
"Docker": {
"commandName": "Docker"
}
}
}

0 comments on commit 0925d30

Please sign in to comment.