Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

프론트엔드 CI / CD 스크립트 추가 #105

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
21e297a
feat: cicd 추가
ay-eonii Jul 17, 2024
69b87d9
fix: working-directory 수정
ay-eonii Jul 17, 2024
9085cab
fix: working-directory 수정
ay-eonii Jul 17, 2024
66cfc9b
Merge pull request #53 from woowacourse-teams/feature/#52
ay-eonii Jul 17, 2024
e517fc2
fix: working-directory 수정
ay-eonii Jul 17, 2024
a62e041
Merge pull request #54 from woowacourse-teams/feature/#52
ay-eonii Jul 17, 2024
39b91d5
fix: docker-compose 서비스명 변경
ay-eonii Jul 17, 2024
05be066
Merge pull request #55 from woowacourse-teams/feature/#52
ay-eonii Jul 17, 2024
8c546ba
fix: Moim ID 누락 수정
ksk0605 Jul 17, 2024
dc0b48f
refactor: response 필드명 수정
ksk0605 Jul 17, 2024
17769b0
refactor: 현재 참여 수 추가
hoyeonyy Jul 17, 2024
f35d194
Merge pull request #59 from woowacourse-teams/fix/#57
ksk0605 Jul 17, 2024
e6f69be
feat: 모임 상세 조회 서비스 기능 구현
hoyeonyy Jul 17, 2024
edec1a4
feat: 모임 상세 조회 API 구현
hoyeonyy Jul 17, 2024
24d1634
merge: 최신 변경사항 반영
hoyeonyy Jul 17, 2024
515b539
refactor: 파라미터명 변경
hoyeonyy Jul 17, 2024
175812b
Merge pull request #60 from woowacourse-teams/feature/#56
hoyeonyy Jul 17, 2024
56b25b7
feat: 모임 참여 기능 구현
Mingyum-Kim Jul 17, 2024
ef8a9d8
Merge branch 'develop-backend' of https://github.com/woowacourse-team…
Mingyum-Kim Jul 17, 2024
9ed8e7d
feat: 모임에 참여하는 기능 구현 및 테스트
Mingyum-Kim Jul 17, 2024
46df875
fix: docker build platform 변경
ay-eonii Jul 17, 2024
63af698
fix: 모임 참여 시 최대 인원 수보다 많아지는 경우 예외처리
Mingyum-Kim Jul 17, 2024
a9b8b32
Merge pull request #61 from woowacourse-teams/feature/#58
Mingyum-Kim Jul 17, 2024
5cd9f10
fix: docker build platform 변경
ay-eonii Jul 17, 2024
fbbc1b0
Merge branch 'develop-backend' of https://github.com/woowacourse-team…
ay-eonii Jul 17, 2024
f4e6fc6
fix: docker build platform 변경
ay-eonii Jul 17, 2024
afecfcc
fix: build 파일 경로 수정
ay-eonii Jul 17, 2024
8b122ab
Merge pull request #63 from woowacourse-teams/feature/#52
ay-eonii Jul 17, 2024
8b78d9f
Merge pull request #70 from woowacourse-teams/develop-backend
hoyeonyy Jul 18, 2024
c9be58d
feat: nginx 설정 파일 업로드
pricelees Jul 24, 2024
ef3a954
feat: 도커 이미지 생성을 위한 Dockerfile 추가
pricelees Jul 24, 2024
a519f2b
feat: github actions ci / cd 스크립트 추가
pricelees Jul 24, 2024
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
27 changes: 27 additions & 0 deletions .github/workflows/cd-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: cd-dev

on:
push:
branches:
- develop-backend

jobs:
deploy:
runs-on: self-hosted

steps:
- name: change permission
run: |
sudo chown -R ubuntu:ubuntu /home/ubuntu/actions-runner/_work/2024-mouda

- name: DockerHub login
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Docker Compose up
run: |
docker compose -f ./backend/docker-compose.yml down mouda-be
docker compose -f ./backend/docker-compose.yml pull mouda-be
docker compose -f ./backend/docker-compose.yml up -d mouda-be
37 changes: 37 additions & 0 deletions .github/workflows/cd-frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: frontend-deploy

on:
push:
branches:
- develop-frontend

jobs:
deploy:
runs-on: self-hosted

steps:
- name: Log in to Dockerhub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: allow ubuntu to access actions-runner
run: |
sudo chown -R ubuntu:ubuntu ~/actions-runner

- name: grant permission to docker-compose
run: |
sudo chmod +x ./frontend/docker-compose-fe.yml

- name: docker compose down
run: |
docker compose -f ./frontend/docker-compose-fe.yml down

- name: docker compose pull
run: |
docker compose -f ~/frontend/docker-compose-fe.yml pull

- name: docker compose up
run: |
docker compose -f ~/frontend/docker-compose-fe.yml up -d
42 changes: 42 additions & 0 deletions .github/workflows/ci-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: ci-dev

on:
pull_request:
branches:
- develop-backend

jobs:
build:
runs-on: ubuntu-24.04

defaults:
run:
shell: bash
working-directory: ./backend

steps:
- name: 레포지토리 체크아웃
uses: actions/checkout@v4

- name: JDK 17을 설치
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'corretto'

- name: gradlew 권한 부여
run: chmod +x ./gradlew

- name: Gradle 빌드
run: ./gradlew clean build -x test

- name: DockerHub 로그인
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: 도커 이미지 빌드 및 푸시
run: |
docker buildx build ./ --platform=linux/arm64 -t 2024mouda/mouda-be:latest
docker push 2024mouda/mouda-be:latest
49 changes: 49 additions & 0 deletions .github/workflows/ci-frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: frontend-integration

on:
pull_request:
branches:
- develop-frontend

jobs:
build:
runs-on: ubuntu-latest

defaults:
run:
shell: bash
working-directory: ./frontend

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: develop-frontend

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20.15.0'

- name: Create .env file
run: |
echo "BASE_URL=${{ secrets.BASE_URL }}" > .env

- name: Install Dependencies
run: npm install --frozen-lockfile

- name: Build static file
run: npm run build

- name: Build Docker image
run: |
docker buildx build ./ --platform=linux/arm64 -t ${{ secrets.DOCKER_USERNAME }}/mouda-fe:latest

- name: Log in to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Push Docker image to DockerHub
run: docker push ${{ secrets.DOCKER_USERNAME }}/mouda-fe:latest
9 changes: 9 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM openjdk:17-jdk

ARG JAR_FILE=./build/libs/backend-0.0.1-SNAPSHOT.jar

COPY ${JAR_FILE} /app.jar

EXPOSE 8080

ENTRYPOINT ["java", "-jar", "/app.jar"]
11 changes: 11 additions & 0 deletions backend/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: "3.7" # 파일 규격 버전
services:
mouda-be:
build: .
container_name: mouda-be # 컨테이너 이름 설정
ports:
- "8080:8080"
command:
- run
- --cors
- "*"
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import mouda.backend.common.RestResponse;
import mouda.backend.moim.domain.Moim;
import mouda.backend.moim.dto.request.MoimCreateRequest;
import mouda.backend.moim.dto.request.MoimJoinRequest;
import mouda.backend.moim.dto.response.MoimDetailsFindResponse;
import mouda.backend.moim.dto.response.MoimFindAllResponses;
import mouda.backend.moim.service.MoimService;

Expand Down Expand Up @@ -45,12 +47,31 @@ public ResponseEntity<RestResponse<MoimFindAllResponses>> findAllMoim() {
return ResponseEntity.ok().body(new RestResponse<>(moimService.findAllMoim()));
}

@Operation(summary = "모임 상세 조회", description = "모임 상세 조회한다.")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "모임 상세 조회 성공!"),
})
@GetMapping("/{moimId}")
public ResponseEntity<RestResponse<MoimDetailsFindResponse>> findMoimDetails(@PathVariable long moimId) {
return ResponseEntity.ok().body(new RestResponse<>(moimService.findMoimDetails(moimId)));
}

@Operation(summary = "모임 참여", description = "모임에 참여한다.")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "모임 참여 성공!")
})
@PostMapping("/join")
public ResponseEntity<RestResponse<Void>> joinMoim(@RequestBody MoimJoinRequest moimJoinRequest) {
moimService.joinMoim(moimJoinRequest);
return ResponseEntity.ok().build();
}

@Operation(summary = "모임 삭제", description = "해당하는 id의 모임을 삭제한다.")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "모임 삭제 성공!"),
})
@DeleteMapping("/{id}")
public void deleteMoim(@PathVariable long id) {
moimService.deleteMoim(id);
@DeleteMapping("/{moimId}")
public void deleteMoim(@PathVariable long moimId) {
moimService.deleteMoim(moimId);
}
}
9 changes: 9 additions & 0 deletions backend/src/main/java/mouda/backend/moim/domain/Moim.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,18 @@ public class Moim {

private String place;

private int currentPeople;

private int maxPeople;

private String authorNickname;

private String description;

public void join() {
if (currentPeople + 1 > maxPeople) {
throw new IllegalArgumentException();
}
currentPeople++;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package mouda.backend.moim.dto.request;

public record MoimJoinRequest(
Long moimId
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package mouda.backend.moim.dto.response;

import java.time.LocalDate;
import java.time.LocalTime;

import lombok.Builder;
import mouda.backend.moim.domain.Moim;

@Builder
public record MoimDetailsFindResponse(
String title,
LocalDate date,
LocalTime time,
String place,
int currentPeople,
int maxPeople,
String authorNickname,
String description
) {
public static MoimDetailsFindResponse toResponse(Moim moim) {
return MoimDetailsFindResponse.builder()
.title(moim.getTitle())
.date(moim.getDate())
.time(moim.getTime())
.place(moim.getPlace())
.currentPeople(moim.getCurrentPeople())
.maxPeople(moim.getMaxPeople())
.authorNickname(moim.getAuthorNickname())
.description(moim.getDescription())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,24 @@

@Builder
public record MoimFindAllResponse(
long moimId,
String title,
LocalDate date,
LocalTime time,
String place,
int currentPeople,
int maxPeople,
String authorNickname,
String description
) {
public static MoimFindAllResponse toResponse(Moim moim) {
return MoimFindAllResponse.builder()
.moimId(moim.getId())
.title(moim.getTitle())
.date(moim.getDate())
.time(moim.getTime())
.place(moim.getPlace())
.currentPeople(moim.getCurrentPeople())
.maxPeople(moim.getMaxPeople())
.authorNickname(moim.getAuthorNickname())
.description(moim.getDescription())
Expand Down
20 changes: 18 additions & 2 deletions backend/src/main/java/mouda/backend/moim/service/MoimService.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import lombok.RequiredArgsConstructor;
import mouda.backend.moim.domain.Moim;
import mouda.backend.moim.dto.request.MoimCreateRequest;
import mouda.backend.moim.dto.request.MoimJoinRequest;
import mouda.backend.moim.dto.response.MoimDetailsFindResponse;
import mouda.backend.moim.dto.response.MoimFindAllResponse;
import mouda.backend.moim.dto.response.MoimFindAllResponses;
import mouda.backend.moim.repository.MoimRepository;
Expand All @@ -33,10 +35,24 @@ public MoimFindAllResponses findAllMoim() {
);
}

public void deleteMoim(long id) {
@Transactional(readOnly = true)
public MoimDetailsFindResponse findMoimDetails(long id) {
Moim moim = moimRepository.findById(id)
.orElseThrow(IllegalArgumentException::new);

return MoimDetailsFindResponse.toResponse(moim);
}

public void joinMoim(MoimJoinRequest moimJoinRequest) {
Moim moim = moimRepository.findById(moimJoinRequest.moimId())
.orElseThrow(() -> new IllegalArgumentException("모임이 존재하지 않습니다."));
moim.join();
}

public void deleteMoim(long id) {
Moim moim = moimRepository.findById(id)
.orElseThrow(IllegalArgumentException::new);

moimRepository.delete(moim);
}
}
}
Loading
Loading