## 背景 教程镜像的 Dockerfile 放在仓库根目录,而 web-runner 的在 `apps/web-runner/` 下,两个位置不一致。 ## 变更内容 - `Dockerfile` 移到 `apps/tutorial/Dockerfile`,内容不变,git 识别为 100% 重命名。 - 构建上下文仍是仓库根目录,因为依赖层要读根上的 `yarn.lock` 与各 workspace 清单。本地用 `docker build -f apps/tutorial/Dockerfile .`。 - 工作流矩阵里 tutorial 的 dockerfile 路径同步改为 `apps/tutorial/Dockerfile`。 - `apps/tutorial/.env.development` 的注释改为「由本目录 Dockerfile 构建时注入」。 ## 自测结果 - **CI 同构布局下用 kaniko 构建**(`idealjs/ci-runner:1.0.3` 作 job 容器,`/workspace` 以 bind mount 挂入,`--dockerfile=apps/tutorial/Dockerfile --context=.`):构建成功,镜像工作目录为 `/workspace`,带 `Host: stack.idealjs.com` 请求返回 200,`dist` 里的运行时地址为 `https://stack-runner.idealjs.com`。 - **本地 `docker build`**:通过,15 步全部命中缓存,与迁移前的镜像一致。 - 仓库内对根目录 `Dockerfile` 的引用只有工作流矩阵一处,已同步。 - `yarn format:check` 通过。 Reviewed-on: #80 Co-authored-by: arnold.cui-agent <arnold.cui-agent@idealjs.com>
54 lines
1.9 KiB
YAML
54 lines
1.9 KiB
YAML
name: Build Images
|
||
|
||
on:
|
||
push:
|
||
branches: [main]
|
||
workflow_dispatch:
|
||
|
||
env:
|
||
YARN_NPM_REGISTRY_SERVER: https://registry.npmmirror.com
|
||
API: https://gitea.idealjs.com/api/v1/repos/idealjs/stack
|
||
|
||
jobs:
|
||
build:
|
||
name: Build ${{ matrix.name }} (kaniko)
|
||
runs-on: ci
|
||
strategy:
|
||
matrix:
|
||
include:
|
||
- name: tutorial
|
||
dockerfile: apps/tutorial/Dockerfile
|
||
image: idealjs/stack
|
||
- name: web-runner
|
||
dockerfile: apps/web-runner/Dockerfile
|
||
image: idealjs/stack-runner
|
||
steps:
|
||
- name: 拉源码(actions/checkout)
|
||
uses: actions/checkout@v4
|
||
|
||
- name: 写阿里云认证(公网 + VPC 双端点)
|
||
env:
|
||
ALIYUN_DOCKER_USERNAME: ${{ secrets.ALIYUN_DOCKER_USERNAME }}
|
||
ALIYUN_DOCKER_PASSWORD: ${{ secrets.ALIYUN_DOCKER_PASSWORD }}
|
||
run: |
|
||
mkdir -p /kaniko/.docker
|
||
AUTH=$(printf '%s:%s' "$ALIYUN_DOCKER_USERNAME" "$ALIYUN_DOCKER_PASSWORD" | base64 | tr -d '\n')
|
||
printf '{"auths":{"registry.cn-hangzhou.aliyuncs.com":{"auth":"%s"},"registry-vpc.cn-hangzhou.aliyuncs.com":{"auth":"%s"}}}' \
|
||
"$AUTH" "$AUTH" > /kaniko/.docker/config.json
|
||
|
||
- name: 构建并推阿里云(公网 + VPC 双端点)
|
||
env:
|
||
DOCKER_CONFIG: /kaniko/.docker
|
||
run: |
|
||
/kaniko/executor --force \
|
||
--dockerfile=${{ matrix.dockerfile }} --context=. \
|
||
--destination=registry.cn-hangzhou.aliyuncs.com/${{ matrix.image }}:${{ github.sha }} \
|
||
--destination=registry-vpc.cn-hangzhou.aliyuncs.com/${{ matrix.image }}:${{ github.sha }} \
|
||
--destination=registry.cn-hangzhou.aliyuncs.com/${{ matrix.image }}:latest \
|
||
--destination=registry-vpc.cn-hangzhou.aliyuncs.com/${{ matrix.image }}:latest
|
||
|
||
- name: 清理(对称删认证与产物)
|
||
if: always()
|
||
run: |
|
||
rm -f /kaniko/.docker/config.json
|