-
Notifications
You must be signed in to change notification settings - Fork 1
infra: Github Actions Docker Compose 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
Changes from all commits
2c04982
b998a1b
b48f4df
e920f7e
2ea1bae
e8d85f7
a5cda2c
3824768
7ad89ae
0bc81d2
7c9ad1c
fb1169f
4cce7f9
2d927f0
56d5d10
76669a5
b786a9a
b83f70e
7143ae2
53a5bb3
73be8de
443b6b7
67404ac
c6cd3b3
d22fdd0
ae709c9
9ab5c36
030a971
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,51 @@ | ||||
| # ----------------------------- | ||||
| # default | ||||
| # ----------------------------- | ||||
| .git | ||||
| .gitignore | ||||
| *.log | ||||
| *.md | ||||
| .DS_Store | ||||
| *.iml | ||||
|
|
||||
| # ----------------------------- | ||||
| # IDE 관련 | ||||
| # ----------------------------- | ||||
| .idea/ | ||||
| .vscode/ | ||||
| *.swp | ||||
|
|
||||
| # ----------------------------- | ||||
| # OS/툴 관련 캐시 | ||||
| # ----------------------------- | ||||
| Thumbs.db | ||||
| ehthumbs.db | ||||
| desktop.ini | ||||
|
|
||||
| # ----------------------------- | ||||
| # Gradle 빌드 결과물 및 캐시 | ||||
| # ----------------------------- | ||||
| build/ | ||||
| !build/libs/*.jar | ||||
| .gradle/ | ||||
| !gradle/wrapper/gradle-wrapper.jar | ||||
| .gradle/ | ||||
|
|
||||
|
Comment on lines
+32
to
+33
|
||||
| .gradle/ |
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,79 @@ | ||||
| name: Spring CD for Dev Push | ||||
|
|
||||
| on: | ||||
| push: | ||||
| branches: [ dev, main ] | ||||
|
|
||||
| permissions: | ||||
| contents: read | ||||
|
|
||||
| jobs: | ||||
| build-and-deploy: | ||||
| name: Build Docker and Deploy to Remote Server | ||||
| runs-on: ubuntu-latest | ||||
|
|
||||
| steps: | ||||
| - name: Checkout code | ||||
| uses: actions/checkout@v4 | ||||
|
|
||||
| - name: Set up JDK 21 | ||||
| uses: actions/setup-java@v4 | ||||
| with: | ||||
| java-version: '21' | ||||
| distribution: 'temurin' | ||||
|
|
||||
| - name: Grant execute permission for gradlew | ||||
| run: chmod +x ./gradlew | ||||
|
|
||||
| - name: Build JAR | ||||
| run: ./gradlew clean bootJar | ||||
|
|
||||
| - name: Build Docker image | ||||
| run: | | ||||
| docker build -t ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }}:latest . | ||||
| - name: Log in to Docker Hub | ||||
| run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin | ||||
|
|
||||
| - name: Push Docker image | ||||
| run: docker push ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }}:latest | ||||
|
|
||||
| - name: Setup SSH key and config | ||||
| run: | | ||||
| mkdir -p ~/.ssh | ||||
| echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/my-key.pem | ||||
| chmod 400 ~/.ssh/my-key.pem | ||||
| ssh-keyscan -H ${{ secrets.SERVER_HOST }} >> ~/.ssh/known_hosts | ||||
| echo -e "Host *\n ServerAliveInterval 60\n ServerAliveCountMax 3" >> ~/.ssh/config | ||||
| - name: Create app directory on server | ||||
| run: | | ||||
| ssh -i ~/.ssh/my-key.pem ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }} "mkdir -p /home/${{ secrets.SERVER_USER }}/app" | ||||
| - name: Deploy and Restart Container | ||||
| run: | | ||||
| ssh -i ~/.ssh/my-key.pem ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }} << 'EOF' | ||||
| mkdir -p /home/${{ secrets.SERVER_USER }}/app | ||||
|
||||
| mkdir -p /home/${{ secrets.SERVER_USER }}/app |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # Dockerfile | ||
| FROM openjdk:21-jdk-slim | ||
| ARG JAR_FILE=build/libs/*.jar | ||
| COPY ${JAR_FILE} app.jar | ||
| ENTRYPOINT ["java", "-jar", "/app.jar"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| version: "3.8" | ||
|
|
||
| services: | ||
| spring-app: | ||
| image: ${DOCKER_USERNAME}/${DOCKER_REPO}:latest | ||
| container_name: spring-app | ||
| ports: | ||
| - "${SERVER_PORT}:${SERVER_PORT}" | ||
| env_file: | ||
| - .env | ||
| volumes: | ||
| - ./logs:/app/logs | ||
| - ./config:/app/config:ro | ||
| restart: always | ||
| networks: | ||
| - app-network | ||
| healthcheck: | ||
| test: ["CMD", "curl", "-f", "http://localhost:${SERVER_PORT}/actuator/health"] | ||
| interval: 30s | ||
| timeout: 10s | ||
| retries: 3 | ||
| start_period: 30s | ||
| logging: | ||
| driver: "json-file" | ||
| options: | ||
| max-size: "10m" | ||
| max-file: "3" | ||
|
|
||
| networks: | ||
| app-network: | ||
| driver: bridge |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -47,9 +47,9 @@ spring: | |||||||||||||||||
| ignore-accept-header: true | ||||||||||||||||||
|
|
||||||||||||||||||
| jwt: | ||||||||||||||||||
| secret-key: ${JWT_SECRET_KEY:e4f1a5c8d2b7e9f0a6c3d1b8e5f2c7a9d4e6f3b1a2c8d5e9f0b3a7c2d1e8f5a4} | ||||||||||||||||||
| access-token-validity: ${JWT_ACCESS_TOKEN_VALIDITY:3600} # seconds (1 hour) | ||||||||||||||||||
| refresh-token-validity: ${JWT_REFRESH_TOKEN_VALIDITY:86400} # seconds (1 day) | ||||||||||||||||||
| secret-key: ${JWT_SECRET_KEY} | ||||||||||||||||||
| access-token-validity: ${JWT_ACCESS_TOKEN_VALIDITY} # seconds (1 hour) | ||||||||||||||||||
| refresh-token-validity: ${JWT_REFRESH_TOKEN_VALIDITY} # seconds (1 day) | ||||||||||||||||||
|
|
||||||||||||||||||
| springdoc: | ||||||||||||||||||
| swagger-ui: | ||||||||||||||||||
|
|
@@ -94,7 +94,7 @@ openapi: | |||||||||||||||||
| default-timeout-seconds: 5 | ||||||||||||||||||
| auction-history: | ||||||||||||||||||
| delay-ms: 1000 | ||||||||||||||||||
| cron: "0 0 */1 * * *" # 1시간마다 실행 | ||||||||||||||||||
| cron: "0 0 */4 * * *" # 1시간마다 실행 | ||||||||||||||||||
|
||||||||||||||||||
| cron: "0 0 */4 * * *" # 1시간마다 실행 | |
| cron: "0 0 */4 * * *" # 4시간마다 실행 |
Copilot
AI
Jul 24, 2025
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.
The comment is incorrect. The cron expression '0 0 */4 * * *' runs every 4 hours, not every hour. The comment should be '# 4시간마다 실행' to match the actual schedule.
| cron: "0 0 */4 * * *" # 1시간마다 실행 | |
| cron: "0 0 */4 * * *" # 4시간마다 실행 |
Copilot
AI
Jul 30, 2025
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.
The comment says '1시간마다 실행' (runs every hour) but the cron expression '0 0 */4 * * *' actually runs every 4 hours. The comment should be updated to '4시간마다 실행' (runs every 4 hours).
| cron: "0 0 */4 * * *" # 1시간마다 실행 | |
| cron: "0 0 */4 * * *" # 4시간마다 실행 |
Copilot
AI
Jul 31, 2025
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.
The comment says '1시간마다 실행' (runs every 1 hour) but the cron expression '0 0 */4 * * *' runs every 4 hours. The comment should be updated to '4시간마다 실행' to match the actual schedule.
| cron: "0 0 */4 * * *" # 1시간마다 실행 | |
| cron: "0 0 */4 * * *" # 4시간마다 실행 |
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.
The .gradle/ directory is listed twice (lines 30 and 32). Remove the duplicate entry to keep the file clean.