-
Notifications
You must be signed in to change notification settings - Fork 274
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Update the microservice startup template.
- Loading branch information
Showing
48 changed files
with
511 additions
and
443 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
aspnet-core/templates/micro/PackageName.CompanyName.ProjectName.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> <!-- 或其他适合的框架 --> | ||
<TargetFramework>net9.0</TargetFramework> <!-- 或其他适合的框架 --> | ||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||
<PackageId>LINGYUN.Abp.MicroService.Templates</PackageId> | ||
<Version>8.3.4</Version> | ||
<Version>9.0.4</Version> | ||
<Authors>[email protected]</Authors> | ||
<Description>Abp framework micro-service template</Description> | ||
<PackageLicenseExpression>MIT</PackageLicenseExpression> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
image: mcr.microsoft.com/dotnet/sdk:9.0 | ||
|
||
stages: | ||
- build | ||
- test | ||
- tag | ||
|
||
build_job: | ||
stage: build | ||
script: | ||
- echo "[ProjectName] - Build project..." | ||
- dotnet build --configuration Release | ||
only: | ||
- dev | ||
|
||
test_job: | ||
stage: test | ||
script: | ||
- echo "[ProjectName] - Unit testing..." | ||
- dotnet test --no-build --configuration Release | ||
dependencies: | ||
- build_job | ||
only: | ||
- dev | ||
|
||
tag_job: | ||
stage: tag | ||
only: | ||
- main | ||
script: | ||
- echo "[ProjectName] - Tag project..." | ||
# 获取 common.props 中定义的版本号 | ||
- export VERSION=$(sed -n 's/.*<Version>\([0-9]*\.[0-9]*\.[0-9]*\)<\/Version>.*/\1/p' common.props) | ||
- echo $VERSION | ||
|
||
# 此处 yougitlab.com 替换为自己的 gitlab 服务器 | ||
- git config --global user.email "[email protected]" | ||
- git config --global user.name "GitLab CI Bot" | ||
|
||
- git tag -f $VERSION | ||
# 此处 yougitlab.com 替换为自己的 gitlab 服务器, 如未启用 https, 变更为 http://oauth2:[email protected]/$CI_PROJECT_PATH.git | ||
# 此处 $GITLAB_TOKEN 需要在gitlab服务器中配置 GITLAB_TOKEN 变量 | ||
- git remote set-url origin https://oauth2:[email protected]/$CI_PROJECT_PATH.git | ||
- git push --force origin $VERSION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
aspnet-core/templates/micro/content/deploy/deployment.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# ProjectName Pod | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: project-name-api | ||
labels: | ||
name: project-name-api | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
name: project-name-api | ||
template: | ||
metadata: | ||
labels: | ||
name: project-name-api | ||
spec: | ||
containers: | ||
- name: project-name-api | ||
image: project-name-api:latest | ||
env: | ||
- name: ASPNETCORE_ENVIRONMENT | ||
value: Production | ||
# 时区问题自行修改 | ||
# - name: TZ | ||
# value: "Asia/Shanghai" | ||
ports: | ||
- containerPort: 8080 | ||
imagePullPolicy: Always | ||
livenessProbe: | ||
httpGet: | ||
path: /healthz | ||
port: 8080 | ||
volumeMounts: | ||
# appsettings挂载 | ||
# - mountPath: /app/appsettings.Production.json | ||
# name: volume-cmkw2z | ||
# subPath: appsettings.Production.json | ||
- mountPath: /app/Logs | ||
name: volume-xk3mds | ||
subPath: ./logs | ||
- mountPath: /app/Modules | ||
name: volume-xk3mds | ||
subPath: ./modules | ||
volumes: | ||
# 其他存储挂载自行处理 | ||
- hostPath: | ||
path: /var/opt/project-name | ||
type: DirectoryOrCreate | ||
# 注意变更名称 | ||
name: volume-xk3mds | ||
# appsettings挂载 | ||
# - configMap: | ||
# defaultMode: 420 | ||
# name: project-name-api | ||
# name: volume-cmkw2z | ||
|
||
--- | ||
# ProjectName Service | ||
kind: Service | ||
apiVersion: v1 | ||
metadata: | ||
name: project-name-api | ||
spec: | ||
type: ClusterIP | ||
ports: | ||
- port: 8080 | ||
selector: | ||
name: project-name-api | ||
|
||
--- | ||
# ProjectName Ingress | ||
kind: Ingress | ||
apiVersion: networking.k8s.io/v1 | ||
metadata: | ||
name: project-name-api | ||
spec: | ||
ingressClassName: nginx | ||
rules: | ||
- host: "project-name-api.local" | ||
http: | ||
paths: | ||
- path: /api/project-name | ||
pathType: Prefix | ||
backend: | ||
service: | ||
name: project-name-api | ||
port: | ||
number: 8080 |
9 changes: 9 additions & 0 deletions
9
aspnet-core/templates/micro/content/deploy/docker-compose.override.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
services: | ||
project-name-api: | ||
build: | ||
context: ../host/PackageName.CompanyName.ProjectName.HttpApi.Host/bin/Release/net9.0 | ||
dockerfile: ../host/PackageName.CompanyName.ProjectName.HttpApi.Host/Dockerfile | ||
volumes: | ||
- /var/opt/project-name/logs:/app/Logs | ||
- /var/opt/project-name/modules:/app/Modules | ||
restart: always |
15 changes: 15 additions & 0 deletions
15
aspnet-core/templates/micro/content/deploy/docker-compose.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
services: | ||
project-name-api: | ||
hostname: project-name-api | ||
container_name: project-name-api | ||
environment: | ||
- ASPNETCORE_ENVIRONMENT=Production | ||
# 时区问题自行修改 | ||
# - TZ=Asia/Shanghai | ||
ports: | ||
- "5000:8080" | ||
healthcheck: | ||
test: ["CMD-SHELL", "wget --spider http://localhost/healthz || exit"] | ||
interval: 10s | ||
timeout: 5s | ||
retries: 5 |
Oops, something went wrong.