CI 파이프라인 구성
목차
ECR 설정
Terraform ECR 리포지토리 생성
# ecr.tf - ECR 리포지토리 및 정책 설정
# ECR 리포지토리 생성
resource "aws_ecr_repository" "app" {
name = "mycompany/myapp"
image_tag_mutability = "IMMUTABLE" # 이미지 태그 불변성 설정
# 이미지 스캐닝 설정
image_scanning_configuration {
scan_on_push = true # 푸시 시 자동 스캔
}
# 암호화 설정
encryption_configuration {
encryption_type = "KMS"
kms_key = aws_kms_key.ecr.arn
}
tags = {
Environment = "production"
Team = "platform"
}
}
# KMS 키 생성 (ECR 암호화용)
resource "aws_kms_key" "ecr" {
description = "ECR repository encryption key"
deletion_window_in_days = 7
enable_key_rotation = true
tags = {
Name = "ecr-encryption-key"
}
}
# 이미지 수명 주기 정책
resource "aws_ecr_lifecycle_policy" "app" {
repository = aws_ecr_repository.app.name
policy = jsonencode({
rules = [
{
rulePriority = 1
description = "최근 30개의 프로덕션 이미지 유지"
selection = {
tagStatus = "tagged"
tagPrefixList = ["prod-", "release-"]
countType = "imageCountMoreThan"
countNumber = 30
}
action = {
type = "expire"
}
},
{
rulePriority = 2
description = "최근 10개의 개발 이미지 유지"
selection = {
tagStatus = "tagged"
tagPrefixList = ["dev-", "feature-"]
countType = "imageCountMoreThan"
countNumber = 10
}
action = {
type = "expire"
}
},
{
rulePriority = 3
description = "태그 없는 이미지 7일 후 삭제"
selection = {
tagStatus = "untagged"
countType = "sinceImagePushed"
countUnit = "days"
countNumber = 7
}
action = {
type = "expire"
}
},
{
rulePriority = 4
description = "90일 이상된 이미지 삭제"
selection = {
tagStatus = "any"
countType = "sinceImagePushed"
countUnit = "days"
countNumber = 90
}
action = {
type = "expire"
}
}
]
})
}이미지 스캐닝 구성
교차 계정 액세스 정책
멀티 리전 복제 구성
GitLab Runner on EKS
Helm values.yaml 설정
IAM 역할 및 신뢰 정책 (Pod Identity)
.gitlab-ci.yml 예제
S3 캐시 버킷 구성
Runner 토큰 관리
GitHub Self-Hosted Runner
ARC 설치 (Helm)
RunnerDeployment / RunnerSet CRD 예제
Scale-from-Zero 설정
GitHub Actions 워크플로우
Pod Identity 설정
Multi-Platform Build
ARM Runner NodePool (Graviton)
x86 Runner NodePool
GitLab CI 멀티 아키텍처 빌드
GitHub Actions 멀티 아키텍처 빌드
빌드 최적화
BuildKit 캐시 활용
Kaniko 빌드 (Rootless)
레이어 캐싱 전략
빌드 시간 최적화 팁
요약
관련 문서
퀴즈
마지막 업데이트