forked from zhontai/Admin.Core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
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,5 @@ | ||
{ | ||
"yaml.schemas": { | ||
"https://json.schemastore.org/github-workflow.json": "file:///e%3A/Coding/02Github/qccoding/Homely/Qc.Homely.Api/.github/workflows/deploy.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,55 @@ | ||
# deploy.yml | ||
name: 后端测试环境直接部署 | ||
# 手动构建 | ||
#on: workflow_dispatch | ||
on: | ||
push: | ||
branches: | ||
- master | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
# 拉取仓库文件 | ||
- name: 拉取master分支代码 | ||
uses: actions/checkout@v3 | ||
with: | ||
# 默认当前分支 | ||
ref: "master" | ||
# action命令,安装Dotnet7 | ||
- name: 安装 Dotnet7 | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: 7.0.400 | ||
# 执行打包命令 | ||
- run: dotnet --version && dotnet publish ./src/hosts/ZhonTai.Host -c Release -o ./publish_output --self-contained true --runtime linux-x64 --framework net7.0 | ||
# 将dist复制到docker目录中 | ||
- run: cp ./publish_output ./docker -rf | ||
# 使用 ssh 将api-dist文件拷贝到 linux | ||
- name: 使用ssh部署 | ||
uses: easingthemes/ssh-deploy@v4.1.8 | ||
with: | ||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} | ||
ARGS: "-rlgoDzvc -i --delete" | ||
SOURCE: "docker" | ||
REMOTE_HOST: ${{ secrets.REMOTE_HOST }} | ||
REMOTE_USER: ${{ secrets.REMOTE_USER }} | ||
TARGET: ${{ secrets.REMOTE_TARGET }} | ||
EXCLUDE: "/node_modules/" | ||
SCRIPT_BEFORE: | | ||
mkdir ${{ secrets.REMOTE_TARGET }} -p | ||
SCRIPT_AFTER: | | ||
cd ${{ secrets.REMOTE_TARGET }} | ||
cd docker | ||
docker build --rm -f ./Dockerfile -t zhontai/apihost:latest . | ||
# 检查容器是否存在 | ||
if docker container ls -a | grep -q "my-zhontai-apihost"; then | ||
echo "容器已存在" | ||
# 停止并移除容器 | ||
docker stop my-zhontai-apihost | ||
docker rm my-zhontai-apihost | ||
fi | ||
# 容器挂载的路径 | ||
mkdir /app/zhontai/volumns/upload -p | ||
docker run --name my-zhontai-apihost -d -p 9902:80 -e ASPNETCORE_ENVIRONMENT=Testing -v /app/zhontai/volumns/admindb.db:/app/admindb.db -v /app/zhontai/volumns/upload:/app/wwwroot/upload zhontai/apihost:latest | ||
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,13 @@ | ||
# 使用 ASP.NET Core 运行时镜像作为最终镜像 | ||
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS runtime | ||
|
||
WORKDIR /app | ||
|
||
# 复制构建好的应用程序文件 | ||
COPY ./publish_output /app | ||
|
||
# 设置运行时环境变量 | ||
ENV ASPNETCORE_URLS=http://+:80 | ||
|
||
# 指定容器启动时要执行的命令 | ||
ENTRYPOINT ["dotnet", "ZhonTai.Host.dll"] |