perf(blog): cache CI builds and raise memory limits to 10Gi
This commit is contained in:
1 parent
bb34391305
commit
83efb25978
3 files changed
+93
-31
No files matched your search
+19
-7
@@ -7,7 +7,7 @@
|
||||
```text
|
||||
signed Gitea push
|
||||
-> blog-clone (정확한 SHA와 브랜치 최신 커밋 확인)
|
||||
-> blog-quality (fmt + Rust tests/architecture + SSR/WASM check)
|
||||
-> blog-quality (Dockerfile quality: fmt + SSR tests/architecture + WASM check)
|
||||
-> blog-build-arm64 (rootless BuildKit -> Harbor)
|
||||
-> blog-update-gitops (환경별 digest/source revision/replica 커밋)
|
||||
-> Argo CD 자동 Sync
|
||||
@@ -25,21 +25,33 @@ signed Gitea push
|
||||
서명된 webhook 수신을 담당합니다. 클러스터 범위 권한과 공통 리소스 정책은 platform에 둡니다.
|
||||
|
||||
PipelineRun은 공유 `tekton-ci`의 ARM64 노드, 10 GiB `local-path` PVC를 사용합니다.
|
||||
최대 시간은 90분(Tasks 85분)입니다. quality의 Cargo jobs는 1이며 메모리 요청은 6Gi,
|
||||
제한은 8Gi입니다. debug symbols와 incremental cache를 줄입니다.
|
||||
최대 시간은 90분(Tasks 85분)입니다. quality의 메모리 요청은 6Gi, 이미지 빌드는 2Gi이며
|
||||
두 빌드의 메모리 제한은 10Gi입니다. Cargo jobs는 1이며 incremental은 끕니다.
|
||||
quality는 dev/test debug symbols도 끕니다.
|
||||
공통 quota와 완료 실행 정리는 platform-state 소유입니다.
|
||||
|
||||
quality는 앱 저장소의 `sh tools/ci/check.sh`를 실행합니다. Rust 1.100.0,
|
||||
rustfmt, wasm32 target으로 `ssr`와 `hydrate`를 분리 검증하고 아키텍처 검사·전체 Rust
|
||||
테스트를 실행합니다. MongoDB/Infisical에는 연결하지 않습니다. 상호작용·라우팅·폼·
|
||||
quality는 rootless BuildKit으로 앱 Dockerfile의 `quality` target을 명시적으로 빌드합니다.
|
||||
내부의 `sh tools/ci/check.sh`는 Rust 1.100.0으로 fmt·SSR 전체 테스트(아키텍처 포함)·
|
||||
WASM check를 실행합니다. SSR 컴파일은 테스트가 담당하며 중복 check는 실행하지 않습니다.
|
||||
MongoDB/Infisical에는 연결하지 않습니다. 상호작용·라우팅·폼·
|
||||
hydration 변경 시 필요한 Playwright 검증은 앱 README의 별도 절차로 실행합니다.
|
||||
이 초안은 DB 기반 브라우저 테스트를 자동화하지 않습니다.
|
||||
|
||||
빌드는 같은 SHA를 별도 디렉터리에 clone하고 앱 Dockerfile을 실행합니다.
|
||||
빌드는 같은 SHA를 별도 디렉터리에 clone하고 앱 Dockerfile의 `runtime` target을 실행합니다.
|
||||
공통 도구 → cargo-chef 의존성 → WASM → SSR 순서로 빌드하며 서버와 WASM 컴파일은 겹치지 않습니다.
|
||||
`sha-<40자리 소스 SHA>-<PipelineRun UID>` 태그로 push한 뒤 실제 digest를 배포합니다.
|
||||
이미지에는 SSR 바이너리·site·라이선스가 들어가며 Node와 dev-ui는 포함하지 않습니다.
|
||||
DB/Entra ID Secret은 quality, Docker build, WASM 번들에서 사용하지 않습니다.
|
||||
|
||||
두 BuildKit 작업은 `registry.dahyeon.us/dahyeon/blog`의
|
||||
`cache-quality-arm64-<staging|prod>` / `cache-release-arm64-<staging|prod>` 태그를
|
||||
`mode=max`로 저장합니다. 같은 브랜치의 두 캐시를 읽어 도구 레이어도 재사용하되,
|
||||
검사의 dev-ui/test 산출물과 배포의 release 산출물은 별도 의존성 단계로 관리합니다.
|
||||
변경 없는 검사 입력은 성공한 quality 레이어를 재사용할 수 있습니다.
|
||||
최초 실행은 캐시가 없어도 진행합니다. 캐시 태그는 덮어쓰기를 허용하고 Harbor 정리 정책에서
|
||||
유지해야 합니다. 동시 실행이 같은 캐시 태그를 갱신하면 마지막 실행의 캐시가 남습니다.
|
||||
캐시는 일반 빌드 레이어에 저장하며 임시 BuildKit의 cache mount나 실행별 PVC에 의존하지 않습니다.
|
||||
|
||||
GitOps push 직전에 소스 브랜치 최신 SHA를 다시 확인합니다. service-state가 병렬
|
||||
실행으로 앞서간 경우 자동 rebase나 force push 없이 실패하므로 최신 소스로 재실행합니다.
|
||||
어느 Task든 실패하면 후속 GitOps 변경은 실행하지 않습니다.
|
||||
|
||||
@@ -35,9 +35,14 @@ spec:
|
||||
- clone
|
||||
taskRef:
|
||||
name: blog-quality
|
||||
params:
|
||||
- name: environment
|
||||
value: staging
|
||||
workspaces:
|
||||
- name: source
|
||||
workspace: source
|
||||
- name: dockerconfig
|
||||
workspace: harbor-dockerconfig
|
||||
- name: build-arm64
|
||||
runAfter:
|
||||
- quality
|
||||
@@ -48,6 +53,8 @@ spec:
|
||||
value: $(params.git-revision)
|
||||
- name: image
|
||||
value: registry.dahyeon.us/dahyeon/blog:sha-$(params.git-revision)-$(context.pipelineRun.uid)
|
||||
- name: environment
|
||||
value: staging
|
||||
workspaces:
|
||||
- name: credentials
|
||||
workspace: gitea-credentials
|
||||
@@ -108,9 +115,14 @@ spec:
|
||||
- clone
|
||||
taskRef:
|
||||
name: blog-quality
|
||||
params:
|
||||
- name: environment
|
||||
value: prod
|
||||
workspaces:
|
||||
- name: source
|
||||
workspace: source
|
||||
- name: dockerconfig
|
||||
workspace: harbor-dockerconfig
|
||||
- name: build-arm64
|
||||
runAfter:
|
||||
- quality
|
||||
@@ -121,6 +133,8 @@ spec:
|
||||
value: $(params.git-revision)
|
||||
- name: image
|
||||
value: registry.dahyeon.us/dahyeon/blog:sha-$(params.git-revision)-$(context.pipelineRun.uid)
|
||||
- name: environment
|
||||
value: prod
|
||||
workspaces:
|
||||
- name: credentials
|
||||
workspace: gitea-credentials
|
||||
|
||||
+60
-24
@@ -70,43 +70,67 @@ kind: Task
|
||||
metadata:
|
||||
name: blog-quality
|
||||
spec:
|
||||
description: Check formatting, architecture, Rust tests, SSR, and WASM without runtime credentials.
|
||||
description: Run the Dockerfile quality target with a branch-scoped registry cache and no runtime credentials.
|
||||
params:
|
||||
- name: environment
|
||||
type: string
|
||||
default: staging
|
||||
workspaces:
|
||||
- name: source
|
||||
stepTemplate:
|
||||
workingDir: $(workspaces.source.path)
|
||||
env:
|
||||
- name: CI
|
||||
value: "true"
|
||||
readOnly: true
|
||||
- name: dockerconfig
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: buildkit-state
|
||||
emptyDir: {}
|
||||
steps:
|
||||
- name: verify-rust
|
||||
image: docker.io/library/rust:1.100.0-trixie@sha256:e19840879045c951c905d0eaa9887f3439c62000e429963371b376bac8d38c31
|
||||
image: docker.io/moby/buildkit:v0.31.1-rootless@sha256:946cf909534b789c9b84af75e6d4f8cb23c3b9cb387daec5ba0f4878a3e4647c
|
||||
computeResources:
|
||||
requests:
|
||||
cpu: 500m
|
||||
memory: 6Gi
|
||||
limits:
|
||||
cpu: "4"
|
||||
memory: 8Gi
|
||||
memory: 10Gi
|
||||
securityContext:
|
||||
privileged: false
|
||||
allowPrivilegeEscalation: true
|
||||
runAsNonRoot: true
|
||||
runAsUser: 1000
|
||||
runAsGroup: 1000
|
||||
seccompProfile:
|
||||
type: Unconfined
|
||||
appArmorProfile:
|
||||
type: Unconfined
|
||||
volumeMounts:
|
||||
- name: buildkit-state
|
||||
mountPath: /home/user/.local/share/buildkit
|
||||
env:
|
||||
- name: PATH
|
||||
value: /usr/local/cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
- name: CARGO_HOME
|
||||
value: /usr/local/cargo
|
||||
- name: CARGO_BUILD_JOBS
|
||||
value: "1"
|
||||
- name: CARGO_INCREMENTAL
|
||||
value: "0"
|
||||
- name: CARGO_PROFILE_DEV_DEBUG
|
||||
value: "0"
|
||||
- name: CARGO_PROFILE_TEST_DEBUG
|
||||
value: "0"
|
||||
- name: BUILDKITD_FLAGS
|
||||
value: --oci-worker-no-process-sandbox
|
||||
- name: DOCKER_CONFIG
|
||||
value: $(workspaces.dockerconfig.path)
|
||||
- name: SOURCE_DIR
|
||||
value: $(workspaces.source.path)
|
||||
- name: DEPLOY_ENV
|
||||
value: $(params.environment)
|
||||
- name: CACHE_REPOSITORY
|
||||
value: registry.dahyeon.us/dahyeon/blog
|
||||
script: |
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
rustup component add rustfmt
|
||||
rustup target add wasm32-unknown-unknown
|
||||
sh tools/ci/check.sh
|
||||
case "$DEPLOY_ENV" in staging|prod) ;; *) echo 'Invalid deployment environment' >&2; exit 1;; esac
|
||||
buildctl-daemonless.sh build \
|
||||
--frontend dockerfile.v0 \
|
||||
--local context="$SOURCE_DIR" \
|
||||
--local dockerfile="$SOURCE_DIR" \
|
||||
--opt filename=Dockerfile \
|
||||
--opt target=quality \
|
||||
--opt platform=linux/arm64 \
|
||||
--import-cache "type=registry,ref=$CACHE_REPOSITORY:cache-quality-arm64-$DEPLOY_ENV" \
|
||||
--import-cache "type=registry,ref=$CACHE_REPOSITORY:cache-release-arm64-$DEPLOY_ENV" \
|
||||
--export-cache "type=registry,ref=$CACHE_REPOSITORY:cache-quality-arm64-$DEPLOY_ENV,mode=max,image-manifest=true,oci-mediatypes=true"
|
||||
---
|
||||
apiVersion: tekton.dev/v1
|
||||
kind: Task
|
||||
@@ -119,6 +143,9 @@ spec:
|
||||
type: string
|
||||
- name: image
|
||||
type: string
|
||||
- name: environment
|
||||
type: string
|
||||
default: staging
|
||||
results:
|
||||
- name: image-url
|
||||
description: Published repository and unique tag.
|
||||
@@ -193,7 +220,7 @@ spec:
|
||||
memory: 2Gi
|
||||
limits:
|
||||
cpu: "4"
|
||||
memory: 8Gi
|
||||
memory: 10Gi
|
||||
securityContext:
|
||||
privileged: false
|
||||
allowPrivilegeEscalation: true
|
||||
@@ -218,18 +245,27 @@ spec:
|
||||
value: $(workspaces.dockerconfig.path)
|
||||
- name: IMAGE
|
||||
value: $(params.image)
|
||||
- name: DEPLOY_ENV
|
||||
value: $(params.environment)
|
||||
- name: CACHE_REPOSITORY
|
||||
value: registry.dahyeon.us/dahyeon/blog
|
||||
- name: METADATA_FILE
|
||||
value: /workspace/build/build-metadata.json
|
||||
script: |
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
printf '%s\n' "$IMAGE" | grep -Eq '^registry\.dahyeon\.us/dahyeon/blog:sha-[0-9a-f]{40}-[a-zA-Z0-9-]+$'
|
||||
case "$DEPLOY_ENV" in staging|prod) ;; *) echo 'Invalid deployment environment' >&2; exit 1;; esac
|
||||
buildctl-daemonless.sh build \
|
||||
--frontend dockerfile.v0 \
|
||||
--local context=/workspace/build/source \
|
||||
--local dockerfile=/workspace/build/source \
|
||||
--opt filename=Dockerfile \
|
||||
--opt target=runtime \
|
||||
--opt platform=linux/arm64 \
|
||||
--import-cache "type=registry,ref=$CACHE_REPOSITORY:cache-release-arm64-$DEPLOY_ENV" \
|
||||
--import-cache "type=registry,ref=$CACHE_REPOSITORY:cache-quality-arm64-$DEPLOY_ENV" \
|
||||
--export-cache "type=registry,ref=$CACHE_REPOSITORY:cache-release-arm64-$DEPLOY_ENV,mode=max,image-manifest=true,oci-mediatypes=true" \
|
||||
--output "type=image,name=$IMAGE,push=true" \
|
||||
--metadata-file "$METADATA_FILE"
|
||||
- name: record-digest
|
||||
|
||||
Reference in new issue
Block a user