-
Notifications
You must be signed in to change notification settings - Fork 0
CI/CD 파이프라인 구성 추가 #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
175eb5e
Merge pull request #18 from DarkMode-Lap/develop
cfcromn ba78090
Merge pull request #27 from DarkMode-Lap/develop
cfcromn cd817cc
Merge pull request #30 from DarkMode-Lap/develop
cfcromn d280c4d
Merge pull request #32 from DarkMode-Lap/develop
cfcromn a145a9f
Develop (#34)
cfcromn 9a8bd2f
Merge pull request #36 from DarkMode-Lap/develop
cfcromn 63b7323
Merge pull request #39 from DarkMode-Lap/develop
cfcromn 8d58f71
add :: CI/CD 파이프라인 구성
chaeeun-09 17c2a41
fix :: Dockerfile 빌드 안정성 및 이미지 레이어 개선
jyx-07 04b19e8
fix: SSH 배포 포트 추가 (24107)
chaeeun-09 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| name: CD | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: false | ||
|
|
||
| env: | ||
| REGISTRY: ghcr.io | ||
| IMAGE_NAME: ${{ github.repository }} | ||
|
|
||
| jobs: | ||
| build-and-push: | ||
| name: Build & Push Docker Image | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
|
|
||
| outputs: | ||
| image-tag: ${{ steps.meta.outputs.tags }} | ||
| image-digest: ${{ steps.push.outputs.digest }} | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Log in to GHCR | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: ${{ env.REGISTRY }} | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Extract Docker metadata | ||
| id: meta | ||
| uses: docker/metadata-action@v5 | ||
| with: | ||
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
| tags: | | ||
| type=sha,prefix=,format=short | ||
| type=raw,value=latest | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: Build and push | ||
| id: push | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| context: . | ||
| push: true | ||
| tags: ${{ steps.meta.outputs.tags }} | ||
| labels: ${{ steps.meta.outputs.labels }} | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max | ||
|
|
||
| deploy: | ||
| name: Deploy to Server | ||
| runs-on: ubuntu-latest | ||
| needs: build-and-push | ||
| environment: production | ||
|
|
||
| steps: | ||
| - name: Deploy via SSH | ||
| uses: appleboy/ssh-action@v1 | ||
| with: | ||
| host: ${{ secrets.DEPLOY_HOST }} | ||
| port: ${{ secrets.DEPLOY_PORT }} | ||
| username: ${{ secrets.DEPLOY_USER }} | ||
| key: ${{ secrets.DEPLOY_SSH_KEY }} | ||
| envs: ENVFILE,GITHUB_TOKEN,ACTOR | ||
| script: | | ||
| IMAGE="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest" | ||
|
|
||
| echo "$GITHUB_TOKEN" | docker login ghcr.io -u "$ACTOR" --password-stdin | ||
|
|
||
| echo "$ENVFILE" > /home/${{ secrets.DEPLOY_USER }}/.aikon.env | ||
| chmod 600 /home/${{ secrets.DEPLOY_USER }}/.aikon.env | ||
|
|
||
| docker pull $IMAGE | ||
|
|
||
| docker stop aikon-app || true | ||
| docker rm aikon-app || true | ||
|
|
||
| docker run -d \ | ||
| --name aikon-app \ | ||
| --restart unless-stopped \ | ||
| -p 8080:8080 \ | ||
| --env-file /home/${{ secrets.DEPLOY_USER }}/.aikon.env \ | ||
| $IMAGE | ||
|
|
||
| docker image prune -f | ||
| env: | ||
| ENVFILE: ${{ secrets.ENVFILE }} | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| ACTOR: ${{ github.actor }} | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # ---- Build Stage ---- | ||
| FROM gradle:9.4.1-jdk21 AS builder | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| COPY gradlew . | ||
| RUN chmod +x gradlew | ||
| COPY gradle gradle | ||
| COPY build.gradle.kts . | ||
| COPY settings.gradle.kts . | ||
|
|
||
| # 의존성만 먼저 캐싱 | ||
| RUN ./gradlew dependencies --no-daemon --parallel -q | ||
|
|
||
| COPY src src | ||
|
|
||
| RUN ./gradlew bootJar --no-daemon --parallel -x test && \ | ||
| find build/libs -name "*.jar" ! -name "*-plain.jar" -exec mv {} build/libs/app.jar \; | ||
|
|
||
| # ---- Runtime Stage ---- | ||
| FROM eclipse-temurin:21-jre-alpine | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| RUN addgroup -S aikon && adduser -S aikon -G aikon | ||
|
|
||
| COPY --chown=aikon:aikon --from=builder /app/build/libs/app.jar app.jar | ||
|
|
||
| USER aikon | ||
|
|
||
| EXPOSE 8080 | ||
|
|
||
| ENTRYPOINT ["java", "-jar", "app.jar"] | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gradlew파일이 복사될 때 실행 권한(+x)이 유실될 수 있습니다. 특히 Windows 환경에서 git 설정(core.filemode)에 따라 권한이 유지되지 않은 채 커밋된 경우, 빌드 단계에서Permission denied에러가 발생하며 빌드가 실패할 수 있습니다.\n\n안전한 빌드를 위해gradlew복사 후 실행 권한을 명시적으로 부여하는 것을 권장합니다.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
17c2a41 에서 반영했습니다. (근거: Docker 공식 Best Practice — 실행 스크립트 파일은 권한 유실에 대비해 COPY 후 명시적으로 chmod +x 지정 권장)