Skip to content
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
26 changes: 0 additions & 26 deletions .docker/docker-compose-override.yml

This file was deleted.

15 changes: 0 additions & 15 deletions .docker/docker-compose.yml

This file was deleted.

9 changes: 4 additions & 5 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ on:
push:
branches:
- dev
# - feat/ci_cd # 테스트 용
# - feat/ci_cd # 테스트용

pull_request:
branches:
- dev
types:
- closed


jobs:
test:
name: Run Tests
Expand All @@ -33,8 +32,8 @@ jobs:
- name: Give permission to gradlew
run: chmod +x ./gradlew

- name: Run tests with coverage
run: ./gradlew clean test jacocoTestReport
- name: Run tests with coverage verification
run: ./gradlew clean testCoverage

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
Expand All @@ -45,7 +44,7 @@ jobs:

notify:
name: Send Notification
needs: test # job
needs: test
runs-on: ubuntu-latest

steps:
Expand Down
42 changes: 21 additions & 21 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@ on:
push:
branches:
- main
# - feat/ci_cd # 테스트

jobs:
deploy:
runs-on: ubuntu-latest
env:
AWS_REGION: ${{ secrets.AWS_REGION }}
IMAGE_TAG: ${{ github.sha }}
# ECR_REGISTRY: ${{ secrets.ECR_REGISTRY }}
# IMAGE_URI: ${{ secrets.ECR_REGISTRY }}/${{ secrets.ECR_REPOSITORY }}:${{ github.sha }}
VERSION_LABEL: v-${{ github.run_number }}

steps:
- name: Checkout code
Expand All @@ -38,27 +36,29 @@ jobs:
docker build -t $IMAGE_URI .
docker push $IMAGE_URI

- name: Render task definition using sed
run: sed "s|__IMAGE_URI__|${{ env.IMAGE_URI }}|g" ecs-task-def-template.json > ecs-task-def.json
- name: Replace image URI in Dockerrun.aws.json
run: |
sed -i "s|__IMAGE_URI__|${{ secrets.ECR_REGISTRY }}/${{ secrets.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}|g" Dockerrun.aws.json

# - name: debug task definition
# run: cat ecs-task-def.json # 디버그용
- name: Zip deployment package
run: zip deploy.zip Dockerrun.aws.json

- name: Render updated task definition
id: render-task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: ecs-task-def.json
container-name: ilil-books-app
image: ${{ env.IMAGE_URI }}
- name: Upload to S3
run: |
aws s3 cp deploy.zip s3://${{ secrets.AWS_S3_BUCKET_NAME }}/deploy-${{ github.run_number }}.zip

- name: Deploy to ECS
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ecs-task-def.json
service: ililbooks-service
cluster: ilil-books
wait-for-service-stability: true
- name: Create new application version
run: |
aws elasticbeanstalk create-application-version \
--application-name ${{ secrets.EB_APP_NAME }} \
--version-label ${{ env.VERSION_LABEL }} \
--source-bundle S3Bucket=${{ secrets.AWS_S3_BUCKET_NAME }},S3Key=deploy-${{ github.run_number }}.zip

- name: Deploy to Elastic Beanstalk
run: |
aws elasticbeanstalk update-environment \
--environment-name ${{ secrets.EB_ENV_NAME }} \
--version-label ${{ env.VERSION_LABEL }}

- name: Notify via Slack
uses: rtCamp/action-slack-notify@v2
Expand Down
7 changes: 2 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# TODO 전승민 dockerfile
# Build 스테이지
FROM gradle:8.10.2-jdk17 AS builder
# 작업 디렉토리 설정
Expand All @@ -7,7 +6,8 @@ WORKDIR /apps
COPY . /apps
# 어플리케이션 빌드
RUN chmod +x gradlew
RUN ./gradlew build -x test # 테스트용
RUN ./gradlew build

# 실행 스테이지
# OpenJDK 17 slim 기반 이미지 사용
FROM amazoncorretto:17.0.12
Expand All @@ -17,9 +17,6 @@ LABEL type="application"
WORKDIR /apps
# 애플리케이션 jar 파일을 컨테이너로 복사
COPY --from=builder /apps/build/libs/ilil-books-0.0.1-SNAPSHOT.jar /apps/app.jar
#COPY wait-for-it.sh /apps/wait-for-it.sh
#RUN chmod +x /apps/wait-for-it.sh

# 애플리케이션이 사용할 포트 노출
EXPOSE 8081
# 애플리케이션을 실행하기 위한 엔트리포인트 정의
Expand Down
12 changes: 12 additions & 0 deletions Dockerrun.aws.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"AWSEBDockerrunVersion": "1",
"Image": {
"Name": "__IMAGE_URI__",
"Update": "true"
},
"Ports": [
{
"ContainerPort": 8081
}
]
}
38 changes: 1 addition & 37 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,6 @@
version: '3.8'
services:

# app:
# build:
# context: .
# dockerfile: Dockerfile
# container_name: ililBooks
# ports:
# - "8080:8080"
# depends_on:
## - db
## - elasticsearch
## - redis
# elasticsearch:
# condition: service_healthy
# db:
# condition: service_healthy
# redis:
# condition: service_started
# environment:
# - SPRING_DATASOURCE_URL=${DB_URL_DOCKER}
# - SPRING_DATASOURCE_USERNAME=${DB_USER}
# - SPRING_DATASOURCE_PASSWORD=${DB_PASSWORD}
# - JWT_SECRET_KEY=${JWT_SECRET_KEY}
# - BOOK_API_KEY=${BOOK_API_KEY}
# - SPRING_PROFILES_ACTIVE=docker
# - AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} # 추가
# - AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} # 추가
# - AWS_S3_BUCKET_NAME=${AWS_S3_BUCKET_NAME} # 추가
# - AWS_REGION=${AWS_REGION}
# networks:
# - esnet
#
# env_file:
# - .env # .env 파일 로드


db:
image: mysql:8.0
container_name: mysql-db
Expand All @@ -59,11 +24,10 @@ services:
container_name: redis
ports:
- "6379:6379"
# command: redis-server --requirepass ${REDIS_PASSWORD}
networks:
- esnet
healthcheck:
test: [ "CMD", "redis-cli", "-a", "ping" ] # ${REDIS_PASSWORD}"
test: [ "CMD", "redis-cli", "-a", "ping" ]
interval: 10s
timeout: 5s
retries: 5
Expand Down
28 changes: 0 additions & 28 deletions ecs-task-def-template.json

This file was deleted.

16 changes: 0 additions & 16 deletions scripts/start.sh

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import static org.springframework.data.web.config.EnableSpringDataWebSupport.PageSerializationMode.VIA_DTO;

@SpringBootApplication
@EnableScheduling
@EnableSpringDataWebSupport(pageSerializationMode = VIA_DTO)
@EnableElasticsearchRepositories(basePackages = "com.example.ililbooks.domain.search.repository")
@EnableScheduling
public class IlilBooksApplication {
public static void main(String[] args) {
SpringApplication.run(IlilBooksApplication.class, args);
Expand Down
13 changes: 0 additions & 13 deletions src/test/resources/application-test.yml

This file was deleted.

Loading