Skip to content
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

[Server] git actions를 사용한 배포 자동화 #46

Merged
merged 21 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 13 additions & 43 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle

name: Java CD with Gradle

on:
Expand All @@ -30,19 +23,26 @@ jobs:
java-version: '17'
distribution: 'temurin'

# Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies.
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md
- name: Setup Gradle
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0

- name: make application-prod.yml
run: |
cd ./Server/banchango/src/main/resources
touch ./application-prod.properties
echo "${{ secrets.APPLICATION_PROD }}" > ./application-prod.properties

- name: Grant execute permission for gradlew
run: chmod +x gradlew
run: chmod +x ./Server/banchango/gradlew

- name: Build with Gradle
run: ./gradlew clean build -x test
run: |
cd Server/banchango
./gradlew clean build -x test

- name: Docker build
run: |
cd Server/banchango
docker login -u ${{ secrets.SERVER_DOCKER_USERNAME }} -p ${{ secrets.SERVER_DOCKER_PASSWORD }}
docker build -t app .
docker tag app ${{ secrets.SERVER_DOCKER_USERNAME }}/banchango:latest
Expand All @@ -58,36 +58,6 @@ jobs:
script: |
docker pull ${{ secrets.SERVER_DOCKER_USERNAME }}/banchango:latest
docker stop $(docker ps -a -q)
docker run -d --log-driver=syslog -p 8080:8080 ${{ secrets.SERVER_DOCKER_USERNAME }}/bnchango:latest
docker run -d --log-driver=syslog -p 8080:8080 ${{ secrets.SERVER_DOCKER_USERNAME }}/banchango:latest
docker rm $(docker ps --filter 'status=exited' -a -q)
docker image prune -a -f

# NOTE: The Gradle Wrapper is the default and recommended way to run Gradle (https://docs.gradle.org/current/userguide/gradle_wrapper.html).
# If your project does not have the Gradle Wrapper configured, you can use the following configuration to run Gradle with a specified version.
#
# - name: Setup Gradle
# uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
# with:
# gradle-version: '8.9'
#
# - name: Build with Gradle 8.9
# run: gradle build

dependency-submission:

runs-on: ubuntu-latest
permissions:
contents: write

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

# Generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies.
# See: https://github.com/gradle/actions/blob/main/dependency-submission/README.md
- name: Generate and submit dependency graph
uses: gradle/actions/dependency-submission@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
16 changes: 16 additions & 0 deletions Server/banchango/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#경량 리눅스 배포판, 도커 이미지 크기를 줄이는데 유용함
FROM openjdk:17-alpine

#도커 이미지 내의 작업 디렉토리 정의
WORKDIR /banchango/

#빌드 인자 기본값 정의
ARG JAR_FILE=/build/libs/banchango-0.0.1-SNAPSHOT.jar

#호스트 시스템에서 빌드된 Jar파일을 도커 이미지 내부로 옮김
COPY ${JAR_FILE} /banchango.jar

#컨테이너 실행 명령어
#ex) java -jar -Dspring.profiles.active=prod /sejongmate.jar
ENTRYPOINT ["java","-jar","/banchango.jar"]
#
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ public class HealthCheckController {
@GetMapping
@Operation(summary = "health-check")
public ResponseEntity healthCheck() {
return ResponseEntity.ok("OK");
return ResponseEntity.ok("Wellcome");
}
}
12 changes: 0 additions & 12 deletions Server/banchango/src/main/resources/application-prod.properties

This file was deleted.

1 change: 0 additions & 1 deletion Server/banchango/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ spring.profiles.active=prod

app.cors.allowedOrigins=http://localhost:3000,http://localhost:8080
app.oauth2.authorizedRedirectUris=http://localhost:3000/oauth2/redirect,myandroidapp://oauth2/redirect,myiosapp://oauth2/redirect