更改docker
Build and publish Jiaowu packages and container image / Test, package and publish (push) Failing after 21m12s
Build and publish Jiaowu packages and container image / Test, package and publish (push) Failing after 21m12s
This commit is contained in:
@@ -14,5 +14,6 @@
|
||||
.env.*
|
||||
!.env.example
|
||||
!.env.docker.example
|
||||
certs
|
||||
src/Jiaowu.Api/data
|
||||
src/Jiaowu.Api/wwwroot
|
||||
|
||||
@@ -98,8 +98,8 @@ jobs:
|
||||
uses: https://github.com/docker/login-action@v3
|
||||
with:
|
||||
registry: git.biss.click
|
||||
username: ${{ gitea.actor }}
|
||||
password: ${{ secrets.GITEA_TOKEN }}
|
||||
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||
|
||||
- name: Generate image tags and labels
|
||||
id: metadata
|
||||
|
||||
@@ -16,3 +16,4 @@ src/Jiaowu.Api/wwwroot/
|
||||
.env.*
|
||||
!.env.example
|
||||
!.env.docker.example
|
||||
certs/
|
||||
|
||||
@@ -182,6 +182,70 @@ git.biss.click/biss/academic-affairs-system
|
||||
会创建 Gitea Release;手动运行只保留工作流产物并推送
|
||||
`manual-<run-number>`、`sha-<commit>` 镜像标签。
|
||||
|
||||
### 简单 Compose:连接外部 MySQL
|
||||
|
||||
已有独立 MySQL 8.4 时,使用
|
||||
[`compose.app.example.yml`](compose.app.example.yml)。该文件只有一个 `app` 服务,
|
||||
不会创建 MySQL 容器或数据库卷。先将 `.env.example` 复制为 `.env`,填写外部数据库、
|
||||
JWT、域名和跨域配置:
|
||||
|
||||
```powershell
|
||||
Copy-Item -LiteralPath '.env.example' -Destination '.env'
|
||||
```
|
||||
|
||||
`.env` 中的 MySQL 主机必须是**容器可以访问的地址**,不能把宿主机数据库写成
|
||||
`localhost`。Docker Desktop 可按实际环境使用 `host.docker.internal`;远程数据库应
|
||||
填写其 DNS 名称。使用私有 CA 时,把证书放到 `certs/mysql-ca.pem`,并取消 Compose
|
||||
文件底部的只读挂载配置注释。
|
||||
|
||||
本地构建、迁移和启动:
|
||||
|
||||
```powershell
|
||||
$composeFile = 'compose.app.example.yml'
|
||||
|
||||
$buildArgs = @('--file', $composeFile, 'build', 'app')
|
||||
& docker compose @buildArgs
|
||||
if ($LASTEXITCODE -ne 0) { throw 'Docker 镜像构建失败。' }
|
||||
|
||||
$migrateArgs = @('--file', $composeFile, 'run', '--rm', 'app', '--migrate-only')
|
||||
& docker compose @migrateArgs
|
||||
if ($LASTEXITCODE -ne 0) { throw '数据库迁移失败。' }
|
||||
|
||||
$upArgs = @('--file', $composeFile, 'up', '--detach', 'app')
|
||||
& docker compose @upArgs
|
||||
if ($LASTEXITCODE -ne 0) { throw '应用启动失败。' }
|
||||
```
|
||||
|
||||
Linux/macOS 使用相同的 Compose 文件:
|
||||
|
||||
```bash
|
||||
cp .env.example .env
|
||||
docker compose -f compose.app.example.yml build app
|
||||
docker compose -f compose.app.example.yml run --rm app --migrate-only
|
||||
docker compose -f compose.app.example.yml up -d app
|
||||
```
|
||||
|
||||
如使用 Gitea 已发布镜像,可在 `.env` 末尾添加
|
||||
`JIAOWU_IMAGE=git.biss.click/biss/academic-affairs-system:1.0.0`,然后跳过 `build`。
|
||||
宿主机端口可通过 `JIAOWU_PORT` 调整,默认是 8080。
|
||||
|
||||
只有连接到专用空演示数据库时,才执行:
|
||||
|
||||
```powershell
|
||||
$demoArgs = @(
|
||||
'--file', 'compose.app.example.yml'
|
||||
'run', '--rm', 'app'
|
||||
'--seed-demo-data', '--confirm-production-demo-data'
|
||||
)
|
||||
& docker compose @demoArgs
|
||||
if ($LASTEXITCODE -ne 0) { throw '演示数据写入失败。' }
|
||||
```
|
||||
|
||||
该命令不会启动长期运行的 Web 容器。演示数据写入成功后删除 `.env` 中临时使用的
|
||||
`SeedAdmin__*` 配置,再执行正常的 `up --detach app`。
|
||||
|
||||
### 一体化 Compose:MySQL 8.4 演示环境
|
||||
|
||||
仓库提供跨 Windows、Linux 和 macOS Docker Desktop 使用的
|
||||
[`compose.example.yml`](compose.example.yml)。它包含 MySQL 8.4、一次性数据库迁移、
|
||||
Web 服务和一个默认关闭的演示数据工具服务。数据库数据保存在命名卷中,MySQL 端口不
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
name: jiaowu
|
||||
|
||||
services:
|
||||
app:
|
||||
image: "${JIAOWU_IMAGE:-jiaowu:local}"
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
env_file:
|
||||
- .env
|
||||
ports:
|
||||
- "${JIAOWU_PORT:-8080}:8080"
|
||||
restart: unless-stopped
|
||||
init: true
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
|
||||
# 如果 .env 中的 SslCa=/etc/jiaowu/mysql-ca.pem,请把 CA 放到
|
||||
# ./certs/mysql-ca.pem,并取消下面三行注释。
|
||||
# volumes:
|
||||
# - type: bind
|
||||
# source: ./certs/mysql-ca.pem
|
||||
# target: /etc/jiaowu/mysql-ca.pem
|
||||
# read_only: true
|
||||
Reference in New Issue
Block a user