@@ -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 |
@@ -0,0 +1,153 @@ | |||
pipeline{ | |||
agent any | |||
parameters { | |||
choice( | |||
description: 'wfzapi:开发环境1', | |||
name: 'environment', | |||
choices: ['hkerp'] | |||
) | |||
choice( | |||
description: '前端or后端', | |||
name: 'projectqh', | |||
choices: ['backend','frontend'] | |||
) | |||
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') | |||
{ | |||
if(params.projectqh=='backend') | |||
{ | |||
sh "docker build -f backend/dockerfile -t 10.2.1.24:10242/bpa/wfzap:${build_tag} ." | |||
} | |||
else if(params.projectqh=='frontend') | |||
{ | |||
sh "docker build -f frontend/dockerfile -t 10.2.1.24:10242/bpa/wfzapi:${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') | |||
{ | |||
if(params.projectqh=='backend') | |||
{ | |||
sh "docker push 10.2.1.24:10242/bpa/wfzapi:${build_tag}" | |||
} | |||
else if(params.projectqh=='frontend') | |||
{ | |||
sh "docker push 10.2.1.24:10242/bpa/wfzweb:${build_tag}" | |||
} | |||
} | |||
} | |||
} | |||
} | |||
} | |||
stage('Deploy') { | |||
steps { | |||
script{ | |||
echo "5. Deploy Stage" | |||
// if(params.environment=='test') | |||
// { | |||
// input "确认要部署线上环境吗?" | |||
// } | |||
if(params.projectqh=='backend') | |||
{ | |||
sh "sed -i 's/<BUILD_TAG>/${build_tag}/' k8s_wfzapi.yaml" | |||
sh "sed -i 's/<BRANCH_NAME>/${env.BRANCH_NAME}/' k8s_wfzapi.yaml" | |||
sh "sed -i 's/<NAMESPACES>/${params.environment}/' k8s_wfzapi.yaml" | |||
sh "kubectl apply -f k8s_wfzapi.yaml --record" | |||
} | |||
else if(params.projectqh=='frontend') | |||
{ | |||
sh "sed -i 's/<BUILD_TAG>/${build_tag}/' k8s_wfzweb.yaml" | |||
sh "sed -i 's/<BRANCH_NAME>/${env.BRANCH_NAME}/' k8s_wfzweb.yaml" | |||
sh "sed -i 's/<NAMESPACES>/${params.environment}/' k8s_wfzweb.yaml" | |||
sh "kubectl apply -f k8s_wfzweb.yaml --record" | |||
} | |||
} | |||
} | |||
} | |||
} | |||
} |
@@ -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 |
@@ -6,9 +6,16 @@ | |||
<ImplicitUsings>enable</ImplicitUsings> | |||
<SatelliteResourceLanguages>en-US</SatelliteResourceLanguages> | |||
<PublishReadyToRunComposite>true</PublishReadyToRunComposite> | |||
<UserSecretsId>83c45a54-1a85-4886-9b4b-458e06c3071c</UserSecretsId> | |||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.14.0" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<ProjectReference Include="..\BPA.MES.Base.Web.Core\BPA.MES.Base.Web.Core.csproj" /> | |||
</ItemGroup> | |||
@@ -4,6 +4,6 @@ | |||
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor> | |||
</PropertyGroup> | |||
<PropertyGroup> | |||
<ActiveDebugProfile>BPA.MES.Base.Web.Entry</ActiveDebugProfile> | |||
<ActiveDebugProfile>Docker</ActiveDebugProfile> | |||
</PropertyGroup> | |||
</Project> |
@@ -0,0 +1,24 @@ | |||
#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:6.0 AS base | |||
WORKDIR /app | |||
EXPOSE 80 | |||
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build | |||
WORKDIR /src | |||
COPY ["BPA.MES.Base.Web.Entry/BPA.MES.Base.Web.Entry.csproj", "BPA.MES.Base.Web.Entry/"] | |||
COPY ["BPA.MES.Base.Web.Core/BPA.MES.Base.Web.Core.csproj", "BPA.MES.Base.Web.Core/"] | |||
COPY ["BPA.MES.Base.Application/BPA.MES.Base.Application.csproj", "BPA.MES.Base.Application/"] | |||
COPY ["BPA.MES.Base.Core/BPA.MES.Base.Core.csproj", "BPA.MES.Base.Core/"] | |||
RUN dotnet restore "BPA.MES.Base.Web.Entry/BPA.MES.Base.Web.Entry.csproj" | |||
COPY . . | |||
WORKDIR "/src/BPA.MES.Base.Web.Entry" | |||
RUN dotnet build "BPA.MES.Base.Web.Entry.csproj" -c Release -o /app/build | |||
FROM build AS publish | |||
RUN dotnet publish "BPA.MES.Base.Web.Entry.csproj" -c Release -o /app/publish | |||
FROM base AS final | |||
WORKDIR /app | |||
COPY --from=publish /app/publish . | |||
ENTRYPOINT ["dotnet", "BPA.MES.Base.Web.Entry.dll"] |
@@ -1,4 +1,4 @@ | |||
{ | |||
{ | |||
"$schema": "http://json.schemastore.org/launchsettings.json", | |||
"iisSettings": { | |||
"windowsAuthentication": false, | |||
@@ -12,20 +12,25 @@ | |||
"IIS Express": { | |||
"commandName": "IISExpress", | |||
"launchBrowser": true, | |||
"launchUrl": "", | |||
"environmentVariables": { | |||
"ASPNETCORE_ENVIRONMENT": "Development" | |||
} | |||
}, | |||
"BPA.MES.Base.Web.Entry": { | |||
"commandName": "Project", | |||
"dotnetRunMessages": true, | |||
"launchBrowser": true, | |||
"launchUrl": "", | |||
"applicationUrl": "https://localhost:5001;http://localhost:5000", | |||
"environmentVariables": { | |||
"ASPNETCORE_ENVIRONMENT": "Development" | |||
} | |||
}, | |||
"applicationUrl": "http://localhost:5001;http://localhost:5000", | |||
"dotnetRunMessages": true | |||
}, | |||
"Docker": { | |||
"commandName": "Docker", | |||
"launchBrowser": true, | |||
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", | |||
"publishAllPorts": true, | |||
"useSSL": true | |||
} | |||
} | |||
} |
@@ -0,0 +1,24 @@ | |||
#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:6.0 AS base | |||
WORKDIR /app | |||
EXPOSE 80 | |||
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build | |||
WORKDIR /src | |||
COPY ["BPA.MES.Base.Web.Entry/BPA.MES.Base.Web.Entry.csproj", "BPA.MES.Base.Web.Entry/"] | |||
COPY ["BPA.MES.Base.Web.Core/BPA.MES.Base.Web.Core.csproj", "BPA.MES.Base.Web.Core/"] | |||
COPY ["BPA.MES.Base.Application/BPA.MES.Base.Application.csproj", "BPA.MES.Base.Application/"] | |||
COPY ["BPA.MES.Base.Core/BPA.MES.Base.Core.csproj", "BPA.MES.Base.Core/"] | |||
RUN dotnet restore "BPA.MES.Base.Web.Entry/BPA.MES.Base.Web.Entry.csproj" | |||
COPY . . | |||
WORKDIR "/src/BPA.MES.Base.Web.Entry" | |||
RUN dotnet build "BPA.MES.Base.Web.Entry.csproj" -c Release -o /app/build | |||
FROM build AS publish | |||
RUN dotnet publish "BPA.MES.Base.Web.Entry.csproj" -c Release -o /app/publish | |||
FROM base AS final | |||
WORKDIR /app | |||
COPY --from=publish /app/publish . | |||
ENTRYPOINT ["dotnet", "BPA.MES.Base.Web.Entry.dll"] |
@@ -0,0 +1,13 @@ | |||
server { | |||
listen 80; | |||
server_name localhost; | |||
location / { | |||
root /usr/share/nginx/html; | |||
index index.html index.htm; | |||
try_files $uri $uri/ /index.html; | |||
} | |||
} | |||
@@ -0,0 +1,4 @@ | |||
FROM nginx:latest | |||
COPY ./public /usr/share/nginx/html/ | |||
COPY ./default.conf /etc/nginx/conf.d/ | |||
EXPOSE 80 |
@@ -0,0 +1,64 @@ | |||
apiVersion: apps/v1 | |||
kind: Deployment | |||
metadata: | |||
name: wfzapi | |||
namespace: kube-<NAMESPACES> | |||
spec: | |||
selector: | |||
matchLabels: | |||
app: wfzapi | |||
replicas: 1 | |||
template: | |||
metadata: | |||
labels: | |||
app: wfzapi | |||
spec: | |||
containers: | |||
- image: 10.2.1.24:10242/bpa/wfzapi:<BUILD_TAG> | |||
imagePullPolicy: IfNotPresent | |||
name: wfzapi | |||
env: | |||
- name: branch | |||
value: <BRANCH_NAME> | |||
- name: TZ | |||
value: Asia/Shanghai | |||
ports: | |||
- containerPort: 80 | |||
protocol: TCP | |||
volumeMounts: | |||
- mountPath: "/app/appsettings.json" | |||
name: wfzapi-config | |||
readOnly: true | |||
subPath: appsettings | |||
- mountPath: "/etc/localtime" | |||
name: timezone | |||
resources: | |||
requests: | |||
cpu: "100m" | |||
memory: "112Mi" | |||
limits: | |||
cpu: "500m" | |||
memory: "512Mi" | |||
volumes: | |||
- name: wfzapi-config | |||
configMap: | |||
name: wfzapi-config | |||
- name: timezone | |||
hostPath: | |||
path: /usr/share/zoneinfo/Asia/Shanghai | |||
--- | |||
kind: Service | |||
apiVersion: v1 | |||
metadata: | |||
labels: | |||
app: wfzapi | |||
name: wfzapi | |||
namespace: kube-<NAMESPACES> | |||
spec: | |||
type: ClusterIP | |||
ports: | |||
- port: 80 | |||
name: http | |||
selector: | |||
app: wfzapi |
@@ -0,0 +1,64 @@ | |||
apiVersion: apps/v1 | |||
kind: Deployment | |||
metadata: | |||
name: wfzweb | |||
namespace: kube-<NAMESPACES> | |||
spec: | |||
selector: | |||
matchLabels: | |||
app: wfzweb | |||
replicas: 1 | |||
template: | |||
metadata: | |||
labels: | |||
app: wfzweb | |||
spec: | |||
containers: | |||
- image: 10.2.1.24:10242/bpa/wfzweb:<BUILD_TAG> | |||
imagePullPolicy: IfNotPresent | |||
name: wfzweb | |||
env: | |||
- name: branch | |||
value: <BRANCH_NAME> | |||
- name: TZ | |||
value: Asia/Shanghai | |||
ports: | |||
- containerPort: 80 | |||
protocol: TCP | |||
volumeMounts: | |||
- mountPath: "/app/appsettings.json" | |||
name: wfzweb-config | |||
readOnly: true | |||
subPath: appsettings | |||
- mountPath: "/etc/localtime" | |||
name: timezone | |||
resources: | |||
requests: | |||
cpu: "100m" | |||
memory: "112Mi" | |||
limits: | |||
cpu: "500m" | |||
memory: "512Mi" | |||
volumes: | |||
- name: wfzweb-config | |||
configMap: | |||
name: wfzweb-config | |||
- name: timezone | |||
hostPath: | |||
path: /usr/share/zoneinfo/Asia/Shanghai | |||
--- | |||
kind: Service | |||
apiVersion: v1 | |||
metadata: | |||
labels: | |||
app: wfzweb | |||
name: wfzweb | |||
namespace: kube-<NAMESPACES> | |||
spec: | |||
type: ClusterIP | |||
ports: | |||
- port: 80 | |||
name: http | |||
selector: | |||
app: wfzweb |