This commit is contained in:
Mikhail Kuznetsov
2023-05-19 14:07:12 +10:00
parent 868af2dd0e
commit 707f634090
9 changed files with 111 additions and 35 deletions

25
.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

@@ -1,19 +0,0 @@
using PARR.DAL.Models.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models
{
[Table("Tests")]
public class Test : IBase
{
[Key]
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
public DateTimeOffset? DateModified { get; set; }
public required string Name { get; set; }
public string? Description { get; set; }
}
}

View File

@@ -3,9 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33213.308
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PARR.API", "PARR_API\PARR.API.csproj", "{82C57299-DA04-4A99-9C04-614FDDCE7AA1}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PARR.API", "PARR_API\PARR.API.csproj", "{82C57299-DA04-4A99-9C04-614FDDCE7AA1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PARR.DAL", "PARR.DAL\PARR.DAL.csproj", "{CBC557EE-382E-4386-B4D2-2EE3DC9A7CBE}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PARR.DAL", "PARR.DAL\PARR.DAL.csproj", "{CBC557EE-382E-4386-B4D2-2EE3DC9A7CBE}"
EndProject
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{AF6BD539-34B2-4D57-AEB3-F6FDE26B98ED}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -21,6 +23,9 @@ Global
{CBC557EE-382E-4386-B4D2-2EE3DC9A7CBE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CBC557EE-382E-4386-B4D2-2EE3DC9A7CBE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CBC557EE-382E-4386-B4D2-2EE3DC9A7CBE}.Release|Any CPU.Build.0 = Release|Any CPU
{AF6BD539-34B2-4D57-AEB3-F6FDE26B98ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AF6BD539-34B2-4D57-AEB3-F6FDE26B98ED}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AF6BD539-34B2-4D57-AEB3-F6FDE26B98ED}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

22
PARR_API/Dockerfile Normal file
View File

@@ -0,0 +1,22 @@
#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
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["PARR_API/PARR.API.csproj", "PARR_API/"]
COPY ["PARR.DAL/PARR.DAL.csproj", "PARR.DAL/"]
RUN dotnet restore "PARR_API/PARR.API.csproj"
COPY . .
WORKDIR "/src/PARR_API"
RUN dotnet build "PARR.API.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "PARR.API.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "PARR.API.dll"]

View File

@@ -5,6 +5,8 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
@@ -23,6 +25,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.0" />
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="7.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />

View File

@@ -1,23 +1,14 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:59274",
"sslPort": 0
}
},
{
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5104",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:5104"
},
"IIS Express": {
"commandName": "IISExpress",
@@ -26,6 +17,21 @@
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
"publishAllPorts": true
}
},
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:59274",
"sslPort": 0
}
}
}

18
docker-compose.dcproj Normal file
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>af6bd539-34b2-4d57-aeb3-f6fde26b98ed</ProjectGuid>
<DockerLaunchAction>LaunchBrowser</DockerLaunchAction>
<DockerServiceUrl>{Scheme}://localhost:{ServicePort}/swagger</DockerServiceUrl>
<DockerServiceName>parr.api</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:
# parr.api:
# environment:
# - ASPNETCORE_ENVIRONMENT=Development
# ports:
# - "80"

8
docker-compose.yml Normal file
View File

@@ -0,0 +1,8 @@
#version: '3.4'
#services:
# parr.api:
# image: ${DOCKER_REGISTRY-}parrapi
# build:
# context: .
# dockerfile: PARR_API/Dockerfile