Addet docker support
This commit is contained in:
35
PointOfSale/.dockerignore
Normal file
35
PointOfSale/.dockerignore
Normal file
@@ -0,0 +1,35 @@
|
||||
**/.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
|
||||
!**/.gitignore
|
||||
!.git/HEAD
|
||||
!.git/config
|
||||
!.git/packed-refs
|
||||
!.git/refs/heads/**
|
||||
database-backup/
|
||||
.env
|
||||
|
||||
database-data/
|
||||
|
||||
7
PointOfSale/.gitignore
vendored
7
PointOfSale/.gitignore
vendored
@@ -360,3 +360,10 @@ MigrationBackup/
|
||||
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
|
||||
# Local Docker database data and secrets
|
||||
.env
|
||||
database-backup/
|
||||
|
||||
database-data/
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -58,3 +58,7 @@ namespace Pos
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Database.Models;
|
||||
using Database.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@@ -32,9 +32,9 @@ namespace Database
|
||||
{
|
||||
LoadConfig l = new LoadConfig();
|
||||
IConfiguration config = l.ByEnvironment();
|
||||
string connectionString = config["SqlServer"].ToString();
|
||||
string connectionString = System.Environment.GetEnvironmentVariable("SqlServer") ?? config["SqlServer"].ToString();
|
||||
optionsBuilder
|
||||
.UseSqlServer(connectionString)
|
||||
.UseSqlServer(connectionString, sqlOptions => sqlOptions.EnableRetryOnFailure())
|
||||
.UseLoggerFactory(LoggerFactory.Create(b => b
|
||||
.AddFilter(level => level >= LogLevel.Information)))
|
||||
.EnableSensitiveDataLogging()
|
||||
@@ -43,3 +43,6 @@ namespace Database
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
34
PointOfSale/Pos.Web/Dockerfile
Normal file
34
PointOfSale/Pos.Web/Dockerfile
Normal file
@@ -0,0 +1,34 @@
|
||||
# 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.
|
||||
|
||||
# This stage is used when running from VS in fast mode (Default for Debug configuration)
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS base
|
||||
USER $APP_UID
|
||||
WORKDIR /app
|
||||
EXPOSE 8080
|
||||
EXPOSE 8081
|
||||
|
||||
|
||||
# This stage is used to build the service project
|
||||
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
WORKDIR /src
|
||||
COPY ["Pos.Web/Pos.Web.csproj", "Pos.Web/"]
|
||||
COPY ["Pos.Models/Pos.Models.csproj", "Pos.Models/"]
|
||||
COPY ["Pos.ServiceDefaults/Pos.ServiceDefaults.csproj", "Pos.ServiceDefaults/"]
|
||||
COPY ["Pos.Service/Pos.Service.csproj", "Pos.Service/"]
|
||||
COPY ["Pos.Ui/Database/Database.csproj", "Pos.Ui/Database/"]
|
||||
RUN dotnet restore "./Pos.Web/Pos.Web.csproj"
|
||||
COPY . .
|
||||
WORKDIR "/src/Pos.Web"
|
||||
RUN dotnet build "./Pos.Web.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||
|
||||
# This stage is used to publish the service project to be copied to the final stage
|
||||
FROM build AS publish
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
RUN dotnet publish "./Pos.Web.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||
|
||||
# This stage is used in production or when running from VS in regular mode (Default when not using the Debug configuration)
|
||||
FROM base AS final
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
ENTRYPOINT ["dotnet", "Pos.Web.dll"]
|
||||
@@ -5,11 +5,14 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<BlazorDisableThrowNavigationException>true</BlazorDisableThrowNavigationException>
|
||||
<UserSecretsId>1b2d8446-d538-488a-94a9-4568bdc91cd3</UserSecretsId>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.FluentUI.AspNetCore.Components" Version="5.0.0-rc.4-26180.1" />
|
||||
<PackageReference Include="Microsoft.FluentUI.AspNetCore.Components.Icons" Version="4.14.2" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.23.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,23 +1,36 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "http://localhost:5281",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "https://localhost:7102;http://localhost:5281",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "http://localhost:5281"
|
||||
},
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "https://localhost:7102;http://localhost:5281"
|
||||
},
|
||||
"Container (Dockerfile)": {
|
||||
"commandName": "Docker",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_HTTPS_PORTS": "8081",
|
||||
"ASPNETCORE_HTTP_PORTS": "8080",
|
||||
"SqlServer": "Server=host.docker.internal;Database=PointOfSale;Trusted_Connection=True;TrustServerCertificate=True;"
|
||||
},
|
||||
"publishAllPorts": true,
|
||||
"useSSL": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"$schema": "https://json.schemastore.org/launchsettings.json"
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 18
|
||||
VisualStudioVersion = 18.4.11620.152
|
||||
@@ -25,6 +25,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pos.Models", "Pos.Models\Po
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pos.ServiceDefaults", "Pos.ServiceDefaults\Pos.ServiceDefaults.csproj", "{EDC882E6-4983-35BD-3357-E433A3E64369}"
|
||||
EndProject
|
||||
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{B7F5A7E1-7A2B-4F3A-9D77-5C9C8A4B2E31}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -67,6 +69,10 @@ Global
|
||||
{EDC882E6-4983-35BD-3357-E433A3E64369}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EDC882E6-4983-35BD-3357-E433A3E64369}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EDC882E6-4983-35BD-3357-E433A3E64369}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B7F5A7E1-7A2B-4F3A-9D77-5C9C8A4B2E31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B7F5A7E1-7A2B-4F3A-9D77-5C9C8A4B2E31}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B7F5A7E1-7A2B-4F3A-9D77-5C9C8A4B2E31}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B7F5A7E1-7A2B-4F3A-9D77-5C9C8A4B2E31}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
8
PointOfSale/docker-compose.dcproj
Normal file
8
PointOfSale/docker-compose.dcproj
Normal file
@@ -0,0 +1,8 @@
|
||||
<Project ToolsVersion="Current" Sdk="Microsoft.Docker.Sdk">
|
||||
<PropertyGroup>
|
||||
<ProjectVersion>2.1</ProjectVersion>
|
||||
<DockerDevelopmentMode>Regular</DockerDevelopmentMode>
|
||||
<DockerTargetOS>Linux</DockerTargetOS>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
35
PointOfSale/docker-compose.yml
Normal file
35
PointOfSale/docker-compose.yml
Normal file
@@ -0,0 +1,35 @@
|
||||
services:
|
||||
db:
|
||||
image: mcr.microsoft.com/mssql/server:2022-latest
|
||||
environment:
|
||||
ACCEPT_EULA: "Y"
|
||||
MSSQL_PID: "Developer"
|
||||
MSSQL_SA_PASSWORD: "${MSSQL_SA_PASSWORD}"
|
||||
ports:
|
||||
- "11433:1433"
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P \"$${MSSQL_SA_PASSWORD}\" -C -Q \"SELECT 1\" || exit 1"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 30
|
||||
start_period: 10s
|
||||
volumes:
|
||||
- mssql-system:/var/opt/mssql
|
||||
- ./database-data/data:/var/opt/mssql/data
|
||||
- ./database-backup:/var/opt/mssql/backup:ro
|
||||
|
||||
pointofsale:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Pos.Web/Dockerfile
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
ports:
|
||||
- "8080:8080"
|
||||
environment:
|
||||
ASPNETCORE_ENVIRONMENT: Production
|
||||
SqlServer: "Server=db,1433;Database=pointofsale;User Id=sa;Password=${MSSQL_SA_PASSWORD};TrustServerCertificate=True;"
|
||||
|
||||
volumes:
|
||||
mssql-system:
|
||||
Reference in New Issue
Block a user