Skip to content

Commit c336bad

Browse files
authored
Merge pull request #2 from Cotatus/feature/1-cicd
Feat : CICD 파이프라인 작성 완료
2 parents ba9cea5 + 245696d commit c336bad

File tree

5 files changed

+98
-3
lines changed

5 files changed

+98
-3
lines changed

.github/workflows/cicd.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
8+
jobs:
9+
build-and-push:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout Code
14+
uses: actions/checkout@v4
15+
16+
17+
- name: Set up JDK 21
18+
uses: actions/setup-java@v4
19+
with:
20+
distribution: corretto
21+
java-version: '21'
22+
23+
24+
- name: Build JAR
25+
run: ./gradlew clean bootJar --no-daemon
26+
27+
28+
- name: Configure AWS credentials
29+
uses: aws-actions/configure-aws-credentials@v4
30+
with:
31+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
32+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
33+
aws-region: ap-northeast-2
34+
35+
36+
- name: Login to Amazon ECR
37+
id: login-ecr
38+
uses: aws-actions/amazon-ecr-login@v2
39+
40+
41+
- name: Build and Push Docker Image
42+
env:
43+
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
44+
ECR_REPOSITORY: cotatus-app
45+
IMAGE_TAG: ${{ github.sha }}
46+
run: |
47+
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:latest .
48+
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:latest $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
49+
50+
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
51+
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ out/
3535

3636
### VS Code ###
3737
.vscode/
38-
39-
###
40-
/src/main/resources/*.properties
38+
docker-compose.yml
39+
/src/main/resources/application-local.properties
40+
/src/main/resources/application.properties

Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM amazoncorretto:21-alpine3.22-jdk
2+
3+
RUN addgroup -S app && adduser -S app -G app
4+
WORKDIR /home/app
5+
6+
COPY build/libs/*.jar app.jar
7+
RUN chown -R app:app /home/app
8+
9+
USER app
10+
11+
ENTRYPOINT ["java", "-Dspring.profiles.active=prod", "-jar", "app.jar"]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
spring.application.name=cotatus
2+
3+
spring.datasource.url=jdbc:postgresql://localhost:5432/cotatus
4+
spring.datasource.username=test
5+
spring.datasource.password=testpw
6+
spring.datasource.driver-class-name=org.postgresql.Driver
7+
8+
spring.jpa.hibernate.ddl-auto=update
9+
spring.jpa.show-sql=true
10+
spring.jpa.properties.hibernate.format_sql=true
11+
12+
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
13+
14+
spring.data.redis.host=localhost
15+
spring.data.redis.port=6379
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
spring.application.name=cotatus
2+
3+
spring.datasource.url=jdbc:postgresql://${DB_HOST}:5432/cotatus
4+
spring.datasource.username=${DB_USERNAME}
5+
spring.datasource.password=${DB_PASSWORD}
6+
spring.datasource.driver-class-name=org.postgresql.Driver
7+
8+
spring.jpa.hibernate.ddl-auto=update
9+
spring.jpa.show-sql=true
10+
spring.jpa.properties.hibernate.format_sql=true
11+
12+
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
13+
14+
spring.data.redis.host=${SPRING_DATA_REDIS_HOST}
15+
spring.data.redis.port=${SPRING_DATA_REDIS_PORT}
16+
spring.data.redis.ssl.enabled=true
17+
18+
swagger.server-url=https://api.eventee.cloud

0 commit comments

Comments
 (0)