Skip to content

Commit

Permalink
Merge pull request #155 from urinaner/production
Browse files Browse the repository at this point in the history
[BE] CI / CD 구축
  • Loading branch information
urinaner authored Nov 22, 2024
2 parents 3bf60b9 + 48d6d0e commit 395ce24
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 32 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ name: Backend CI/CD using GitHub Actions & Docker
on:
push:
branches: [ "main" ]
paths:
- 'backend/**'
pull_request:
branches: [ "main" ]
paths:
- 'backend/**'

jobs:
build:
Expand Down Expand Up @@ -70,4 +74,4 @@ jobs:
sudo docker run -d -p 8080:8080 ${{ secrets.DOCKER_USERNAME }}/backend:latest
# 사용하지 않는 이미지 정리
sudo docker image prune -a -f
sudo docker image prune -a -f
35 changes: 5 additions & 30 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,5 @@
# OpenJDK 기반 이미지 설정
FROM bellsoft/liberica-openjdk-alpine:21

# dos2unix 설치 및 bash 설치
RUN apk add --no-cache bash dos2unix

# 작업 디렉터리 설정
WORKDIR /app

# 프로젝트 소스 코드와 Gradle 파일 복사
COPY gradlew ./
COPY gradle/ ./gradle
COPY build.gradle settings.gradle ./
COPY src/ ./src

# 줄바꿈 형식 변경 및 Gradle 실행 권한 추가
RUN dos2unix gradlew
RUN chmod +x ./gradlew

# Gradle 빌드 실행
RUN bash ./gradlew clean build -x test

# 포트 노출
EXPOSE 8080

# 환경 변수 설정
ENV spring.jwt.secret=s5GFED7YjUOFHe3K6jvVk2CalMUU//B2iOBpzSn/WqA=

# 빌드된 JAR 파일 실행
ENTRYPOINT ["java", "-jar", "build/libs/backend-0.0.1-SNAPSHOT.jar"]
#DockerFile
FROM openjdk:21-jdk-slim
ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
public class BoardController {
private final BoardService boardService;

@Operation(summary = "게시판 생성 API", description = "게시판 생성")
@Operation(summary = "게시판 생성 API 입니다.", description = "게시판 생성입니다.")
@PostMapping
public ResponseEntity<Long> createBoard(@RequestBody BoardReqDto boardReqDto) {
Long boardId = boardService.saveBoard(boardReqDto);
Expand Down

0 comments on commit 395ce24

Please sign in to comment.