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