feat: add container CI/CD workflow
This commit is contained in:
@@ -0,0 +1,22 @@
|
|||||||
|
name: Frontend CI/CD
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "v*"
|
||||||
|
workflow_dispatch: {}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-test-publish-and-deploy:
|
||||||
|
uses: OrgTJWater/ci-templates/.gitea/workflows/container-cd.yml@main
|
||||||
|
with:
|
||||||
|
image_name: gitea.waternetwork.cn/orgtjwater/next-tjwater-frontend
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
build_context: .
|
||||||
|
test_target: build
|
||||||
|
deploy_service: frontend
|
||||||
|
deploy_host: 192.168.1.114
|
||||||
|
secrets:
|
||||||
|
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
||||||
|
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
||||||
|
DEV_DEPLOY_SSH_KEY: ${{ secrets.DEV_DEPLOY_SSH_KEY }}
|
||||||
+4
-2
@@ -1,4 +1,4 @@
|
|||||||
FROM node:24-alpine AS build
|
FROM node:24-alpine@sha256:d32cdf619f63fe0471182d08996dd516c6275bb5fd31ae06e55a570bd9e1ad43 AS build
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN corepack enable
|
RUN corepack enable
|
||||||
@@ -9,7 +9,7 @@ RUN pnpm install --frozen-lockfile
|
|||||||
COPY . .
|
COPY . .
|
||||||
RUN pnpm build
|
RUN pnpm build
|
||||||
|
|
||||||
FROM caddy:2.10.2-alpine
|
FROM caddy:2.10.2-alpine@sha256:4c6e91c6ed0e2fa03efd5b44747b625fec79bc9cd06ac5235a779726618e530d
|
||||||
|
|
||||||
RUN apk add --no-cache jq nodejs
|
RUN apk add --no-cache jq nodejs
|
||||||
COPY Caddyfile /etc/caddy/Caddyfile
|
COPY Caddyfile /etc/caddy/Caddyfile
|
||||||
@@ -19,5 +19,7 @@ COPY --from=build /app/dist-server/edge-tts-server.cjs /usr/local/lib/tjwater-fr
|
|||||||
RUN chmod 755 /usr/local/bin/tjwater-frontend-entrypoint
|
RUN chmod 755 /usr/local/bin/tjwater-frontend-entrypoint
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
||||||
|
CMD wget --quiet --spider http://127.0.0.1/ || exit 1
|
||||||
ENTRYPOINT ["/usr/local/bin/tjwater-frontend-entrypoint"]
|
ENTRYPOINT ["/usr/local/bin/tjwater-frontend-entrypoint"]
|
||||||
CMD ["caddy", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"]
|
CMD ["caddy", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"]
|
||||||
|
|||||||
@@ -70,6 +70,17 @@ docker run --rm -p 8080:80 --env-file .env.local next-tjwater
|
|||||||
|
|
||||||
启动后访问 `http://localhost:8080`。
|
启动后访问 `http://localhost:8080`。
|
||||||
|
|
||||||
|
## CI/CD
|
||||||
|
|
||||||
|
Gitea Actions 通过 `.gitea/workflows/package.yml` 复用
|
||||||
|
`OrgTJWater/ci-templates` 的容器发布流程。手动触发只构建镜像并在 Dev
|
||||||
|
服务器运行候选验证;从 `main` 创建并推送 `v*` tag 后,候选验证通过才会
|
||||||
|
提升为正式 `frontend` 服务。
|
||||||
|
|
||||||
|
仓库需要配置 `REGISTRY_USERNAME`、`REGISTRY_PASSWORD` 和
|
||||||
|
`DEV_DEPLOY_SSH_KEY` 三个 Gitea Secrets。生产运行时配置由 Dev 服务器的
|
||||||
|
`env/frontend.env` 注入,不写入镜像或仓库 Secret。
|
||||||
|
|
||||||
## 项目结构
|
## 项目结构
|
||||||
|
|
||||||
```text
|
```text
|
||||||
|
|||||||
Reference in New Issue
Block a user