bpa 7 months ago
parent
commit
287dd44efa
9 changed files with 301 additions and 16 deletions
  1. +25
    -0
      .dockerignore
  2. +7
    -0
      BPA.SAAS.KitChenManageOrder.Web.Entry/BPA.SAAS.KitChenManageOrder.Web.Entry.csproj
  3. +1
    -1
      BPA.SAAS.KitChenManageOrder.Web.Entry/BPA.SAAS.KitChenManageOrder.Web.Entry.csproj.user
  4. +25
    -0
      BPA.SAAS.KitChenManageOrder.Web.Entry/Dockerfile
  5. +20
    -15
      BPA.SAAS.KitChenManageOrder.Web.Entry/Properties/launchSettings.json
  6. +26
    -0
      Dockerfile
  7. +126
    -0
      Jenkinsfile
  8. +7
    -0
      NuGet.config
  9. +64
    -0
      k8s_kitchenmanage.yaml

+ 25
- 0
.dockerignore 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

+ 7
- 0
BPA.SAAS.KitChenManageOrder.Web.Entry/BPA.SAAS.KitChenManageOrder.Web.Entry.csproj View File

@@ -6,9 +6,16 @@
<ImplicitUsings>enable</ImplicitUsings>
<SatelliteResourceLanguages>en-US</SatelliteResourceLanguages>
<PublishReadyToRunComposite>true</PublishReadyToRunComposite>
<UserSecretsId>46d3a2fa-2085-4d29-b0b9-cef32825c463</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>


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



<ItemGroup>
<ProjectReference Include="..\BPA.SAAS.KitChenManageOrder.Web.Core\BPA.SAAS.KitChenManageOrder.Web.Core.csproj" />


+ 1
- 1
BPA.SAAS.KitChenManageOrder.Web.Entry/BPA.SAAS.KitChenManageOrder.Web.Entry.csproj.user View File

@@ -4,6 +4,6 @@
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup>
<ActiveDebugProfile>BPA.SAAS.KitChenManageOrder.Web.Entry</ActiveDebugProfile>
<ActiveDebugProfile>Docker</ActiveDebugProfile>
</PropertyGroup>
</Project>

+ 25
- 0
BPA.SAAS.KitChenManageOrder.Web.Entry/Dockerfile View File

@@ -0,0 +1,25 @@
#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/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["BPA.SAAS.KitChenManageOrder.Web.Entry/BPA.SAAS.KitChenManageOrder.Web.Entry.csproj", "BPA.SAAS.KitChenManageOrder.Web.Entry/"]
COPY ["BPA.SAAS.KitChenManageOrder.Web.Core/BPA.SAAS.KitChenManageOrder.Web.Core.csproj", "BPA.SAAS.KitChenManageOrder.Web.Core/"]
COPY ["BPA.SAAS.KitChenManageOrder.Application/BPA.SAAS.KitChenManageOrder.Application.csproj", "BPA.SAAS.KitChenManageOrder.Application/"]
COPY ["BPA.SAAS.KitChenManageOrder.Core/BPA.SAAS.KitChenManageOrder.Core.csproj", "BPA.SAAS.KitChenManageOrder.Core/"]
RUN dotnet restore "BPA.SAAS.KitChenManageOrder.Web.Entry/BPA.SAAS.KitChenManageOrder.Web.Entry.csproj"
COPY . .
WORKDIR "/src/BPA.SAAS.KitChenManageOrder.Web.Entry"
RUN dotnet build "BPA.SAAS.KitChenManageOrder.Web.Entry.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "BPA.SAAS.KitChenManageOrder.Web.Entry.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "BPA.SAAS.KitChenManageOrder.Web.Entry.dll"]

+ 20
- 15
BPA.SAAS.KitChenManageOrder.Web.Entry/Properties/launchSettings.json View File

@@ -1,31 +1,36 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:53785",
"sslPort": 44342
}
},
{
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"BPA.SAAS.KitChenManageOrder.Web.Entry": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "",
"applicationUrl": "http://192.168.1.19:5005",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"dotnetRunMessages": true,
"applicationUrl": "http://192.168.1.19:5005"
},
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
"publishAllPorts": true,
"useSSL": true
}
},
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:53785",
"sslPort": 44342
}
}
}

+ 26
- 0
Dockerfile View File

@@ -0,0 +1,26 @@
#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/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["NuGet.config", "."]
COPY ["BPA.SAAS.KitChenManageOrder.Web.Entry/BPA.SAAS.KitChenManageOrder.Web.Entry.csproj", "BPA.SAAS.KitChenManageOrder.Web.Entry/"]
COPY ["BPA.SAAS.KitChenManageOrder.Web.Core/BPA.SAAS.KitChenManageOrder.Web.Core.csproj", "BPA.SAAS.KitChenManageOrder.Web.Core/"]
COPY ["BPA.SAAS.KitChenManageOrder.Application/BPA.SAAS.KitChenManageOrder.Application.csproj", "BPA.SAAS.KitChenManageOrder.Application/"]
COPY ["BPA.SAAS.KitChenManageOrder.Core/BPA.SAAS.KitChenManageOrder.Core.csproj", "BPA.SAAS.KitChenManageOrder.Core/"]
RUN dotnet restore "BPA.SAAS.KitChenManageOrder.Web.Entry/BPA.SAAS.KitChenManageOrder.Web.Entry.csproj" --configfile "NuGet.config"
COPY . .
WORKDIR "/src/BPA.SAAS.KitChenManageOrder.Web.Entry"
RUN dotnet build "BPA.SAAS.KitChenManageOrder.Web.Entry.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "BPA.SAAS.KitChenManageOrder.Web.Entry.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "BPA.SAAS.KitChenManageOrder.Web.Entry.dll"]

+ 126
- 0
Jenkinsfile View File

@@ -0,0 +1,126 @@

pipeline{
agent any
parameters {
choice(
description: 'saasdev1:开发环境1 \n saastest1:测试环境2 \n dev3:生产环境',
name: 'environment',
choices: ['saasdev1', 'saastest1', 'dev3']
)

choice(
description: '执行操作(发布|回滚)',
name: 'operation',
choices: ['develop', 'rollback']
)

choice(
description: '分支名',
name: 'branchName',
choices: ['master']
)

string(
name: 'tag',
defaultValue: '',
description: '版本tag'
)

}

stages
{
stage('Prepare') {
steps {
script{
echo "1.Prepare Stage"
echo "当前环境${params.environment}"
if(params.operation=='develop')
{
checkout scm
script {
build_tag = sh(returnStdout: true, script: 'git rev-parse --short HEAD').trim()
if (env.BRANCH_NAME != 'master') {
build_tag = "${env.BRANCH_NAME}-${build_tag}"
}
}
}
else{
script {
if(params.branchName!= 'master')
{
build_tag = "${params.branchName}-${params.tag}"
}
else
{
build_tag="${params.tag}"
}
}
}
}
}
}
stage('Test') {
steps {
script{
echo "2.Test Stage"
}
}
}
stage('Build') {
steps {
script{
echo "3.Build Docker Image Stage"
if(params.operation=='develop')
{

sh "docker build -t 10.2.1.24:10242/bpa/kitchenmanageorder:${build_tag} ."
}
}
}
}
stage('Push') {
steps {
script{
echo "4.Push Docker Image Stage"
withCredentials([usernamePassword(credentialsId: 'harbor', passwordVariable: 'harborPassword', usernameVariable: 'harborUser')]) {
sh "docker login -u ${harborUser} -p ${harborPassword} 10.2.1.24:10242"
if(params.operation=='develop')
{
sh "docker push 10.2.1.24:10242/bpa/kitchenmanageorder:${build_tag}"
}
}
}
}

}
stage('Deploy') {

steps {
script{
echo "5. Deploy Stage"
// if(params.environment=='test')
// {
// input "确认要部署线上环境吗?"
// }
//sh "sed -i 's/<BUILD_TAG>/${build_tag}/' k8s_kitchenmanageorder.yaml"
// sh "sed -i 's/<BRANCH_NAME>/${env.BRANCH_NAME}/' k8s_kitchenmanageorder.yaml"
// sh "sed -i 's/<NAMESPACES>/${params.environment}/' k8s_kitchenmanageorder.yaml"
// sh "kubectl apply -f k8s_kitchenmanageorder.yaml --record"


}
}
}
}
}

+ 7
- 0
NuGet.config View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json"/>
<add key="bpa" value="http://10.2.1.25:10243/repository/bpa/index.json"/>
</packageSources>
</configuration>

+ 64
- 0
k8s_kitchenmanage.yaml View File

@@ -0,0 +1,64 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: kitchenmanage
namespace: kube-<NAMESPACES>
spec:
selector:
matchLabels:
app: kitchenmanage
replicas: 1
template:
metadata:
labels:
app: kitchenmanage
spec:
containers:
- image: 10.2.1.24:10242/bpa/kitchenmanage:<BUILD_TAG>
imagePullPolicy: IfNotPresent
name: kitchenmanage
env:
- name: branch
value: <BRANCH_NAME>
- name: TZ
value: Asia/Shanghai
ports:
- containerPort: 80
protocol: TCP
volumeMounts:
- mountPath: "/app/appsettings.json"
name: kitchenmanage-config
readOnly: true
subPath: appsetting
- mountPath: "/etc/localtime"
name: timezone
resources:
requests:
cpu: "100m"
memory: "112Mi"
limits:
cpu: "500m"
memory: "512Mi"
volumes:
- name: kitchenmanage-config
configMap:
name: kitchenmanage-config
- name: timezone
hostPath:
path: /usr/share/zoneinfo/Asia/Shanghai
---
kind: Service
apiVersion: v1
metadata:
labels:
app: kitchenmanage
name: kitchenmanage
namespace: kube-<NAMESPACES>
spec:
type: ClusterIP
ports:
- port: 80
name: http
selector:
app: kitchenmanage

Loading…
Cancel
Save