Skip to content

Commit 3c3968f

Browse files
authored
Merge pull request #98 from billilge/deploy/#97
deploy(#97): 개발버전 서버 배포
2 parents 12f5380 + 1d45d1b commit 3c3968f

File tree

4 files changed

+149
-1
lines changed

4 files changed

+149
-1
lines changed

.github/workflows/ci-cd_dev.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Development Server CI/CD with Gradle and Docker
2+
3+
on:
4+
push:
5+
branches: [ "develop" ]
6+
pull_request:
7+
branches: [ "develop" ]
8+
9+
jobs:
10+
build-docker-image:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Set up JDK 17
17+
uses: actions/setup-java@v4
18+
with:
19+
java-version: '17'
20+
distribution: 'temurin'
21+
22+
- name: Create Firebase Config Directory
23+
run: |
24+
mkdir -p src/main/resources/firebase
25+
echo "${{ secrets.FIREBASE_SERVICE_KEY }}" | base64 --decode > src/main/resources/firebase/firebaseServiceKey.json
26+
shell: bash
27+
28+
- name: Setup Gradle
29+
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
30+
31+
- name: Build with Gradle Wrapper
32+
run: ./gradlew clean build -x test
33+
34+
# Docker 관련 작업들은 push 시에만 실행되도록 설정
35+
- name: docker image build
36+
if: github.event_name == 'push'
37+
run: docker build -f Dockerfile-dev -t ${{ secrets.DOCKER_USERNAME }}/billilge-dev:latest .
38+
39+
# DockerHub 로그인
40+
- name: docker login
41+
if: github.event_name == 'push'
42+
uses: docker/login-action@v3
43+
with:
44+
username: ${{ secrets.DOCKER_USERNAME }}
45+
password: ${{ secrets.DOCKER_PASSWORD }}
46+
47+
# Docker Hub 이미지 푸시
48+
- name: docker Hub push
49+
if: github.event_name == 'push'
50+
run: docker push ${{ secrets.DOCKER_USERNAME }}/billilge-dev:latest
51+
52+
run-docker-image-on-ec2:
53+
needs: build-docker-image
54+
#push 했을 때만 배포가 진행되도록
55+
if: github.event_name == 'push'
56+
runs-on: self-hosted
57+
steps:
58+
- name: docker pull
59+
run: sudo docker pull ${{ secrets.DOCKER_USERNAME }}/billilge-dev:latest
60+
61+
- name: docker stop container
62+
run: sudo docker stop springboot || true
63+
64+
- name: docker run new container
65+
run: sudo docker run --env-file /home/ubuntu/billilge.env --name springboot --rm -d -p 8080:8080 ${{ secrets.DOCKER_USERNAME }}/billilge-dev:latest
66+
67+
- name: delete old docker image
68+
run: sudo docker image prune -f
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI/CD with Gradle and Docker
1+
name: Production Server CI/CD with Gradle and Docker
22

33
on:
44
push:

Dockerfile-dev

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Dockerfile
2+
3+
# jdk17 Image Start
4+
FROM openjdk:17
5+
6+
# jar 파일 복제
7+
COPY build/libs/*.jar app.jar
8+
9+
# 실행 명령어
10+
ENTRYPOINT ["java", "-Duser.timezone=Asia/Seoul", "-Dspring.profiles.active=dev", "-jar", "app.jar"]
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
spring:
2+
application:
3+
name: backend
4+
5+
datasource:
6+
url: jdbc:mysql://${DEV_DB_URL}?useSSL=false&serverTimezone=Asia/Seoul&characterEncoding=UTF-8&allowPublicKeyRetrieval=true
7+
driver-class-name: com.mysql.cj.jdbc.Driver
8+
username: ${DEV_DB_USERNAME}
9+
password: ${DEV_DB_PASSWORD}
10+
11+
security:
12+
oauth2:
13+
client:
14+
registration:
15+
# 구글 로그인 추가
16+
google:
17+
client-id: ${DEV_OAUTH2_GOOGLE_CLIENT_ID}
18+
client-secret: ${DEV_OAUTH2_GOOGLE_CLIENT_SECRET}
19+
scope:
20+
- email
21+
- profile
22+
jpa:
23+
properties:
24+
hibernate:
25+
format_sql: true
26+
dialect: org.hibernate.dialect.MySQLDialect
27+
dialect.storage_engine: innodb
28+
show-sql: true
29+
hibernate:
30+
ddl-auto: update
31+
32+
servlet:
33+
multipart:
34+
max-file-size: 5MB
35+
max-request-size: 10MB
36+
resolve-lazily: true
37+
38+
39+
jwt:
40+
secret_key: ${DEV_JWT_SECRET_KEY}
41+
issuer: ${DEV_JWT_ISSUER}
42+
43+
login:
44+
admin-password: ${DEV_LOGIN_ADMIN_PASSWORD}
45+
redirect:
46+
url: ${DEV_LOGIN_REDIRECT_URL}
47+
48+
cors:
49+
allowed-origins: ${DEV_CORS_ALLOWED_ORIGINS}
50+
51+
exam-period:
52+
start-date: ${DEV_EXAM_PERIOD_START_DATE}
53+
end-date: ${DEV_EXAM_PERIOD_END_DATE}
54+
55+
cloud:
56+
aws:
57+
s3:
58+
bucket: ${DEV_S3_BUCKET}
59+
base-url: ${DEV_S3_BASE_URL}
60+
credentials:
61+
access-key: ${DEV_S3_ACCESS_KEY}
62+
secret-key: ${DEV_S3_SECRET_KEY}
63+
region:
64+
static: us-west-2
65+
stack:
66+
auto: false
67+
68+
swagger:
69+
server:
70+
base-url: ${DEV_SWAGGER_SERVER_BASE_URL}

0 commit comments

Comments
 (0)