add docker support

This commit is contained in:
2021-02-23 10:46:33 +08:00
parent f7384b9afc
commit 0f98c15cd4
11 changed files with 110 additions and 16 deletions

8
.gitignore vendored
View File

@@ -1,7 +1,3 @@
.vs/
Domain/bin/
Domain/obj/
Infrastructure/bin/
Infrastructure/obj/
QRCodeService/bin/
QRCodeService/obj/
bin/
obj/

25
Docker/.dockerignore Normal file
View File

@@ -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

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" Sdk="Microsoft.Docker.Sdk">
<PropertyGroup Label="Globals">
<ProjectVersion>2.1</ProjectVersion>
<DockerTargetOS>Linux</DockerTargetOS>
<ProjectGuid>67e556aa-3e56-4b78-9521-6a5abed7eeea</ProjectGuid>
<DockerLaunchAction>LaunchBrowser</DockerLaunchAction>
<DockerServiceUrl>{Scheme}://localhost:{ServicePort}/swagger</DockerServiceUrl>
<DockerServiceName>qrcodeservice</DockerServiceName>
</PropertyGroup>
<ItemGroup>
<None Include="docker-compose.override.yml">
<DependentUpon>docker-compose.yml</DependentUpon>
</None>
<None Include="docker-compose.yml" />
<None Include=".dockerignore" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,8 @@
version: '3.4'
services:
qrcodeservice:
environment:
- ASPNETCORE_ENVIRONMENT=Development
ports:
- "80"

View File

@@ -0,0 +1,8 @@
version: '3.4'
services:
qrcodeservice:
image: ${DOCKER_REGISTRY-}qrcodeservice
build:
context: .
dockerfile: QRCodeService/Dockerfile

View File

@@ -3,11 +3,13 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30804.86
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QRCodeService", "QRCodeService\QRCodeService.csproj", "{CF4EF394-9502-4720-8E32-30132C5A7B40}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QRCodeService", "QRCodeService\QRCodeService.csproj", "{CF4EF394-9502-4720-8E32-30132C5A7B40}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Domain", "Domain\Domain.csproj", "{FB39ABD1-A7B6-479D-9552-D81D8360E48B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Domain", "Domain\Domain.csproj", "{FB39ABD1-A7B6-479D-9552-D81D8360E48B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Infrastructure", "Infrastructure\Infrastructure.csproj", "{3A7EB8BC-4099-461F-9E2D-D34AEC5FC056}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Infrastructure", "Infrastructure\Infrastructure.csproj", "{3A7EB8BC-4099-461F-9E2D-D34AEC5FC056}"
EndProject
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "Docker\docker-compose.dcproj", "{67E556AA-3E56-4B78-9521-6A5ABED7EEEA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -27,6 +29,10 @@ Global
{3A7EB8BC-4099-461F-9E2D-D34AEC5FC056}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3A7EB8BC-4099-461F-9E2D-D34AEC5FC056}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3A7EB8BC-4099-461F-9E2D-D34AEC5FC056}.Release|Any CPU.Build.0 = Release|Any CPU
{67E556AA-3E56-4B78-9521-6A5ABED7EEEA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{67E556AA-3E56-4B78-9521-6A5ABED7EEEA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{67E556AA-3E56-4B78-9521-6A5ABED7EEEA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{67E556AA-3E56-4B78-9521-6A5ABED7EEEA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

23
QRCodeService/Dockerfile Normal file
View File

@@ -0,0 +1,23 @@
#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:5.0-buster-slim AS base
WORKDIR /app
EXPOSE 80
FROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim AS build
WORKDIR /src
COPY ["QRCodeService/QRCodeService.csproj", "QRCodeService/"]
COPY ["Domain/Domain.csproj", "Domain/"]
COPY ["Infrastructure/Infrastructure.csproj", "Infrastructure/"]
RUN dotnet restore "QRCodeService/QRCodeService.csproj"
COPY . .
WORKDIR "/src/QRCodeService"
RUN dotnet build "QRCodeService.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "QRCodeService.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "QRCodeService.dll"]

View File

@@ -1,5 +1,4 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
@@ -8,6 +7,7 @@
"sslPort": 0
}
},
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
@@ -19,13 +19,19 @@
},
"QRCodeService": {
"commandName": "Project",
"dotnetRunMessages": "true",
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"dotnetRunMessages": "true",
"applicationUrl": "http://localhost:5000"
},
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
"publishAllPorts": true
}
}
}
}

View File

@@ -2,6 +2,8 @@
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
</PropertyGroup>
<ItemGroup>
@@ -11,6 +13,7 @@
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="9.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.1" NoWarn="NU1605" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="5.0.1" NoWarn="NU1605" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.9" />
<PackageReference Include="MySqlConnector" Version="1.2.0" />
<PackageReference Include="QRCoder" Version="1.4.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />

View File

@@ -4,7 +4,7 @@
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup>
<ActiveDebugProfile>QRCodeService</ActiveDebugProfile>
<ActiveDebugProfile>Docker</ActiveDebugProfile>
<Controller_SelectedScaffolderID>ApiControllerEmptyScaffolder</Controller_SelectedScaffolderID>
<Controller_SelectedScaffolderCategoryPath>root/Common/Api</Controller_SelectedScaffolderCategoryPath>
</PropertyGroup>

1
README.md Normal file
View File

@@ -0,0 +1 @@
施工图审查系统二维码短链生成服务