<aside> ✏️

이 문서는 EC2 위에 Docker 기반으로 Jenkins, Nginx, Certbot을 구성하고, Unity CLI 빌드 → Firebase App Distribution 배포 → Slack 알림까지 자동화하는 실전형 파이프라인 구축 가이드이다.

</aside>

📐 아키텍처

[ GitHub Push ] 
	→ Webhook 
	→ Nginx (443/80) 
	→ Jenkins (Docker, HTTPS) 
	→ Unity 빌드 
	→ Firebase 배포 
	→ Slack 알림

📁 디렉토리 구조

infra/  
├── docker-compose.yml  
├── .env  
├── jenkins/  
│   └── jenkins_home/  
├── nginx/  
│   ├── nginx.conf  
│   ├── ssl/  
│   └── healthcheck.conf  
├── certbot/  
│   └── init-letsencrypt.sh  
scripts/  
├── build.sh  
├── deploy.sh  
├── notify.sh  
unity-project/  
└── BuildScript.cs

🧩 Jenkinsfile 예시

pipeline {  
    agent any  
    environment {  
        SLACK_CHANNEL = "#cicd"  
        UNITY_PROJECT_PATH = "unity-project"  
        BUILD_OUTPUT_PATH = "build/output.apk"  
        FIREBASE_APP_ID = credentials('firebase_app_id')  
        FIREBASE_TOKEN = credentials('firebase_token')  
        SLACK_WEBHOOK = credentials('slack_webhook')  
    }  
    triggers {  
        githubPush()  
    }  
    stages {  
        stage('Checkout') {  
            steps {  
                git url: '<https://github.com/your-org/unity-game-repo.git>', branch: 'main'  
            }  
        }  
        stage('Unity Build') {  
            steps {  
                sh "chmod +x ./scripts/build.sh"  
                sh "./scripts/build.sh $UNITY_PROJECT_PATH"  
            }  
        }  
        stage('Distribute to Firebase') {  
            steps {  
                sh "chmod +x ./scripts/deploy.sh"  
                sh "./scripts/deploy.sh $FIREBASE_APP_ID $BUILD_OUTPUT_PATH $FIREBASE_TOKEN"  
            }  
        }  
    }  
    post {  
        success {  
            sh "scripts/notify.sh success"  
        }  
        failure {  
            sh "scripts/notify.sh failure"  
        }  
    }  
}

🔐 Jenkins Credentials 설정

firebase_app_id: Secret Text, Firebase App ID
firebase_token: Secret Text, Firebase CLI 로그인 토큰
slack_webhook: Secret Text, Slack Webhook URL

✅ 실행 절차 요약

  1. .env 작성
  2. init-letsencrypt.sh 실행 → 인증서 발급
  3. docker-compose up -d