Skip to content

Commit 3ad3884

Browse files
committed
feat: github actions를 통한 배포 설정
1 parent 3ac2fd4 commit 3ad3884

5 files changed

Lines changed: 133 additions & 1 deletion

File tree

.github/workflows/cd-workflow.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: RecipAI CD with Gradle and Docker
2+
3+
on:
4+
push:
5+
branches:
6+
- 'develop'
7+
- 'main'
8+
pull_request:
9+
branches:
10+
- 'develop'
11+
- 'main'
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
build:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- uses: actions/checkout@v3
22+
23+
- name: ☕️ set up JDK 21
24+
uses: actions/setup-java@v3
25+
with:
26+
java-version: '21'
27+
distribution: 'temurin'
28+
server-id: github
29+
setting-path: ${{ github.workspace }}
30+
31+
- name: 👏🏻 grant execute permission for gradlew
32+
run: chmod +x gradlew
33+
34+
- name: 🐘 build with Gradle (without test)
35+
run: ./gradlew clean build -x test --stacktrace
36+
37+
- name: 🐳 Docker build & push
38+
run: |
39+
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
40+
docker build -f Dockerfile-dev -t ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_IMAGE }} .
41+
docker push ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_IMAGE }}
42+
43+
- name: 🚀 deploy to dev-server
44+
uses: appleboy/ssh-action@master
45+
with:
46+
host: ${{ secrets.EC2_HOST }}
47+
username: ${{ secrets.EC2_USERNAME }}
48+
key: ${{ secrets.EC2_KEY }}
49+
port: ${{ secrets.EC2_PORT }}
50+
envs: GITHUB_SHA
51+
script: |
52+
echo "✋🏻Stopping existing container"
53+
sudo docker stop recipAI
54+
sudo docker rm recipAI
55+
56+
sudo docker ps -a
57+
58+
echo "🥳Pulling new image"
59+
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_IMAGE }}
60+
61+
echo "🌱Running new container"
62+
sudo docker run -d -p 8080:8080 --name recipAI ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_IMAGE }}
63+
64+
echo "🚮Cleaning up old images"
65+
sudo docker image prune -f

.github/workflows/ci-workflow.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: RecipAI CI with Gradle
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
- 'develop'
8+
pull_request:
9+
branches:
10+
- 'main'
11+
- 'develop'
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
build:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- uses: actions/checkout@v3
22+
23+
- name: ☕️ set up JDK 21
24+
uses: actions/setup-java@v3
25+
with:
26+
java-version: '21'
27+
distribution: 'temurin'
28+
server-id: github
29+
setting-path: ${{ github.workspace }}
30+
31+
- name: 👏🏻 grant execute permission for gradlew
32+
run: chmod +x gradlew
33+
34+
- name: 🐘 build with Gradle
35+
run: ./gradlew clean build

Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM amazoncorretto:21
2+
EXPOSE 8080
3+
COPY ./build/libs/*.jar ./app.jar
4+
ENTRYPOINT ["java", "-jar", "app.jar"]

src/main/resources/application.properties

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
spring:
2+
servlet:
3+
multipart:
4+
max-file-size: 10MB
5+
max-request-size: 10MB
6+
datasource:
7+
driver-class-name: org.h2.Driver
8+
# url: jdbc:h2:~/recipAI
9+
url: jdbc:h2:tcp://localhost/~/recipAI
10+
username: sa
11+
password:
12+
jpa:
13+
hibernate:
14+
ddl-auto: create
15+
properties:
16+
hibernate:
17+
dialect: org.hibernate.dialect.H2Dialect
18+
format_sql: true
19+
default_batch_fetch_size: 100
20+
jdbc:
21+
batch_size: 50 # insert 시 적용되는 batch size
22+
order_inserts: true # insert 순서를 최적화하여 성능 향상
23+
order_updates: true # update 순서도 최적화
24+
show-sql: true
25+
logging:
26+
level:
27+
org.springframework.messaging: DEBUG
28+
org.springframework.web.socket: DEBUG
29+
root: INFO

0 commit comments

Comments
 (0)