From 10a2cb6170e1c74d301a6963d33976e13a4f1818 Mon Sep 17 00:00:00 2001 From: mirageoasis Date: Mon, 16 Oct 2023 14:50:45 +0900 Subject: [PATCH 01/18] =?UTF-8?q?feat=20:=20front=20dev=20url=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/ceos/backend/global/config/WebSecurityConfig.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/ceos/backend/global/config/WebSecurityConfig.java b/src/main/java/ceos/backend/global/config/WebSecurityConfig.java index 0de5b0a4..b3aa748e 100644 --- a/src/main/java/ceos/backend/global/config/WebSecurityConfig.java +++ b/src/main/java/ceos/backend/global/config/WebSecurityConfig.java @@ -50,6 +50,9 @@ public class WebSecurityConfig { @Value("${server.admin_url}") private String ADMIN_URL; + @Value("${server.dev_url}") + private String DEV_URL; + @Value("${swagger.user}") private String swaggerUser; @@ -188,7 +191,8 @@ private CorsConfiguration getDefaultCorsConfiguration() { "http://localhost:3001", USER_URL, ADMIN_URL, - SERVER_URL)); + SERVER_URL, + DEV_URL)); configuration.setAllowedHeaders(List.of("*")); configuration.setAllowedMethods(List.of("*")); configuration.setAllowCredentials(true); From 49ee6bea5d6edf6731a509b7a4ba89c052d693b6 Mon Sep 17 00:00:00 2001 From: JeongHyun Lee <86969518+hyunihs@users.noreply.github.com> Date: Mon, 23 Oct 2023 22:32:34 +0900 Subject: [PATCH 02/18] =?UTF-8?q?add:=20=EC=95=84=EC=9D=B4=EB=94=94?= =?UTF-8?q?=EC=96=B4=ED=86=A4,=20=ED=95=B4=EC=BB=A4=ED=86=A4=20=EB=82=A0?= =?UTF-8?q?=EC=A7=9C=20=EC=B6=94=EA=B0=80=20(#157)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/domain/recruitment/domain/Recruitment.java | 10 ++++++++++ .../backend/domain/recruitment/dto/RecruitmentDTO.java | 8 ++++++++ .../domain/recruitment/dto/UserRecruitmentDTO.java | 8 ++++++++ .../ceos/backend/global/config/WebSecurityConfig.java | 2 +- 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/main/java/ceos/backend/domain/recruitment/domain/Recruitment.java b/src/main/java/ceos/backend/domain/recruitment/domain/Recruitment.java index 5149eb29..830812f8 100644 --- a/src/main/java/ceos/backend/domain/recruitment/domain/Recruitment.java +++ b/src/main/java/ceos/backend/domain/recruitment/domain/Recruitment.java @@ -49,6 +49,10 @@ public class Recruitment extends BaseEntity { @NotNull private LocalDate otDate; + @NotNull private LocalDate ideathonDate; + + @NotNull private LocalDate hackathonDate; + @NotNull private LocalDate demodayDate; private LocalDateTime applicationExcelCreatedAt; @@ -68,6 +72,8 @@ private Recruitment( LocalDate resultDateFinal, String openChatUrl, LocalDate otDate, + LocalDate ideathonDate, + LocalDate hackathonDate, LocalDate demodayDate, LocalDateTime applicationExcelCreatedAt) { this.generation = generation; @@ -82,6 +88,8 @@ private Recruitment( this.resultDateFinal = resultDateFinal; this.openChatUrl = openChatUrl; this.otDate = otDate; + this.ideathonDate = ideathonDate; + this.hackathonDate = hackathonDate; this.demodayDate = demodayDate; this.applicationExcelCreatedAt = applicationExcelCreatedAt; } @@ -99,6 +107,8 @@ public void updateRecruitment(RecruitmentDTO recruitmentDTO) { this.resultDateFinal = recruitmentDTO.getResultDateFinal(); this.openChatUrl = recruitmentDTO.getOpenChatUrl(); this.otDate = recruitmentDTO.getOtDate(); + this.ideathonDate = recruitmentDTO.getIdeathonDate(); + this.hackathonDate = recruitmentDTO.getHackathonDate(); this.demodayDate = recruitmentDTO.getDemodayDate(); } diff --git a/src/main/java/ceos/backend/domain/recruitment/dto/RecruitmentDTO.java b/src/main/java/ceos/backend/domain/recruitment/dto/RecruitmentDTO.java index fd73857f..c64f8da3 100644 --- a/src/main/java/ceos/backend/domain/recruitment/dto/RecruitmentDTO.java +++ b/src/main/java/ceos/backend/domain/recruitment/dto/RecruitmentDTO.java @@ -20,6 +20,8 @@ public class RecruitmentDTO { private LocalDate resultDateFinal; private String openChatUrl; private LocalDate otDate; + private LocalDate ideathonDate; + private LocalDate hackathonDate; private LocalDate demodayDate; @Builder @@ -36,6 +38,8 @@ public RecruitmentDTO( LocalDate resultDateFinal, String openChatUrl, LocalDate otDate, + LocalDate ideathonDate, + LocalDate hackathonDate, LocalDate demodayDate) { this.generation = generation; this.prodStudyUrl = prodStudyUrl; @@ -49,6 +53,8 @@ public RecruitmentDTO( this.resultDateFinal = resultDateFinal; this.openChatUrl = openChatUrl; this.otDate = otDate; + this.ideathonDate = ideathonDate; + this.hackathonDate = hackathonDate; this.demodayDate = demodayDate; } @@ -66,6 +72,8 @@ public static RecruitmentDTO from(Recruitment recruitment) { .resultDateFinal(recruitment.getResultDateFinal()) .openChatUrl(recruitment.getOpenChatUrl()) .otDate(recruitment.getOtDate()) + .ideathonDate(recruitment.getIdeathonDate()) + .hackathonDate(recruitment.getHackathonDate()) .demodayDate(recruitment.getDemodayDate()) .build(); } diff --git a/src/main/java/ceos/backend/domain/recruitment/dto/UserRecruitmentDTO.java b/src/main/java/ceos/backend/domain/recruitment/dto/UserRecruitmentDTO.java index 4b64ed45..753db16c 100644 --- a/src/main/java/ceos/backend/domain/recruitment/dto/UserRecruitmentDTO.java +++ b/src/main/java/ceos/backend/domain/recruitment/dto/UserRecruitmentDTO.java @@ -19,6 +19,8 @@ public class UserRecruitmentDTO { private LocalDate endDateInterview; private LocalDate resultDateFinal; private LocalDate otDate; + private LocalDate ideathonDate; + private LocalDate hackathonDate; private LocalDate demodayDate; @Builder @@ -34,6 +36,8 @@ public UserRecruitmentDTO( LocalDate endDateInterview, LocalDate resultDateFinal, LocalDate otDate, + LocalDate ideathonDate, + LocalDate hackathonDate, LocalDate demodayDate) { this.generation = generation; this.prodStudyUrl = prodStudyUrl; @@ -46,6 +50,8 @@ public UserRecruitmentDTO( this.endDateInterview = endDateInterview; this.resultDateFinal = resultDateFinal; this.otDate = otDate; + this.ideathonDate = ideathonDate; + this.hackathonDate = hackathonDate; this.demodayDate = demodayDate; } @@ -62,6 +68,8 @@ public static UserRecruitmentDTO from(Recruitment recruitment) { .endDateInterview(recruitment.getEndDateInterview()) .resultDateFinal(recruitment.getResultDateFinal()) .otDate(recruitment.getOtDate()) + .ideathonDate(recruitment.getIdeathonDate()) + .hackathonDate(recruitment.getHackathonDate()) .demodayDate(recruitment.getDemodayDate()) .build(); } diff --git a/src/main/java/ceos/backend/global/config/WebSecurityConfig.java b/src/main/java/ceos/backend/global/config/WebSecurityConfig.java index b3aa748e..725e7df7 100644 --- a/src/main/java/ceos/backend/global/config/WebSecurityConfig.java +++ b/src/main/java/ceos/backend/global/config/WebSecurityConfig.java @@ -85,7 +85,7 @@ public class WebSecurityConfig { private final String[] GetPermittedPatterns = { "/awards/**", - "/recruitments/**", + "/recruitments", "/projects/**", "/activities/**", "/managements/**", From e5dcc1cf613b23716b6e37681e28a467c5e19b59 Mon Sep 17 00:00:00 2001 From: suhhyun <97878992+suhhyun524@users.noreply.github.com> Date: Wed, 8 Nov 2023 19:54:18 +0900 Subject: [PATCH 03/18] =?UTF-8?q?[refact]=20=ED=99=88=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A7=80=20=EC=88=98=EC=A0=95=EC=82=AC=ED=95=AD=20=EB=B0=98?= =?UTF-8?q?=EC=98=81=20(#159)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [fix] 시간 단위 수정 및 테스트 코드 작성 * [fix] 서류합격 validation 수정 * [fix] Type 변경 --- .../validator/ApplicationValidator.java | 3 +- .../application/vo/ApplicantInfoVo.java | 4 +-- .../recruitment/domain/Recruitment.java | 36 +++++++++---------- .../recruitment/dto/RecruitmentDTO.java | 25 ++++++------- .../recruitment/dto/UserRecruitmentDTO.java | 25 ++++++------- .../validator/RecruitmentValidator.java | 12 +++---- .../recruitments/domain/SettingsTest.java | 25 +++++++------ 7 files changed, 68 insertions(+), 62 deletions(-) diff --git a/src/main/java/ceos/backend/domain/application/validator/ApplicationValidator.java b/src/main/java/ceos/backend/domain/application/validator/ApplicationValidator.java index f1e879b2..1590793f 100644 --- a/src/main/java/ceos/backend/domain/application/validator/ApplicationValidator.java +++ b/src/main/java/ceos/backend/domain/application/validator/ApplicationValidator.java @@ -1,5 +1,6 @@ package ceos.backend.domain.application.validator; +import static ceos.backend.domain.application.domain.Pass.PASS; import ceos.backend.domain.application.domain.Application; import ceos.backend.domain.application.domain.ApplicationQuestion; @@ -119,7 +120,7 @@ public void validateInterviewTimeExist(String uuid, String email) { () -> { throw ApplicantNotFound.EXCEPTION; }); - if (application.getInterviewDatetime() == null) { + if (application.getDocumentPass() == PASS && application.getInterviewDatetime() == null) { throw NotSetInterviewTime.EXCEPTION; } } diff --git a/src/main/java/ceos/backend/domain/application/vo/ApplicantInfoVo.java b/src/main/java/ceos/backend/domain/application/vo/ApplicantInfoVo.java index d8c50888..b4fde7b1 100644 --- a/src/main/java/ceos/backend/domain/application/vo/ApplicantInfoVo.java +++ b/src/main/java/ceos/backend/domain/application/vo/ApplicantInfoVo.java @@ -12,7 +12,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Positive; +import jakarta.validation.constraints.PositiveOrZero; import java.time.LocalDate; import lombok.Builder; import lombok.Getter; @@ -56,7 +56,7 @@ public class ApplicantInfoVo { @Schema(defaultValue = "99999999", description = "지원자 남은 학기 수") @NotNull(message = "지원자 남은 학기 수를 입력해주세요") - @Positive + @PositiveOrZero private int semestersLeftNumber; @Builder diff --git a/src/main/java/ceos/backend/domain/recruitment/domain/Recruitment.java b/src/main/java/ceos/backend/domain/recruitment/domain/Recruitment.java index 830812f8..69e3436d 100644 --- a/src/main/java/ceos/backend/domain/recruitment/domain/Recruitment.java +++ b/src/main/java/ceos/backend/domain/recruitment/domain/Recruitment.java @@ -33,17 +33,17 @@ public class Recruitment extends BaseEntity { @NotNull private String devStudyUrl; - @NotNull private LocalDate startDateDoc; + @NotNull private LocalDateTime startDateDoc; - @NotNull private LocalDate endDateDoc; + @NotNull private LocalDateTime endDateDoc; - @NotNull private LocalDate resultDateDoc; + @NotNull private LocalDateTime resultDateDoc; - @NotNull private LocalDate startDateInterview; + @NotNull private LocalDateTime startDateInterview; - @NotNull private LocalDate endDateInterview; + @NotNull private LocalDateTime endDateInterview; - @NotNull private LocalDate resultDateFinal; + @NotNull private LocalDateTime resultDateFinal; @NotNull private String openChatUrl; @@ -64,12 +64,12 @@ private Recruitment( String prodStudyUrl, String designStudyUrl, String devStudyUrl, - LocalDate startDateDoc, - LocalDate endDateDoc, - LocalDate resultDateDoc, - LocalDate startDateInterview, - LocalDate endDateInterview, - LocalDate resultDateFinal, + LocalDateTime startDateDoc, + LocalDateTime endDateDoc, + LocalDateTime resultDateDoc, + LocalDateTime startDateInterview, + LocalDateTime endDateInterview, + LocalDateTime resultDateFinal, String openChatUrl, LocalDate otDate, LocalDate ideathonDate, @@ -123,7 +123,7 @@ public void validateGeneration(int generation) { } } - public void validateBetweenStartDateDocAndEndDateDoc(LocalDate now) { + public void validateBetweenStartDateDocAndEndDateDoc(LocalDateTime now) { if (now.compareTo(this.getStartDateDoc()) < 0) { throw NotApplicationDuration.EXCEPTION; } @@ -132,7 +132,7 @@ public void validateBetweenStartDateDocAndEndDateDoc(LocalDate now) { } } - public void validateFinalResultAbleDuration(LocalDate now) { + public void validateFinalResultAbleDuration(LocalDateTime now) { if (now.compareTo(this.resultDateFinal.plusDays(5)) >= 0) { throw NotFinalResultCheckDuration.EXCEPTION; } @@ -141,7 +141,7 @@ public void validateFinalResultAbleDuration(LocalDate now) { } } - public void validateBetweenStartDateDocAndResultDateDoc(LocalDate now) { + public void validateBetweenStartDateDocAndResultDateDoc(LocalDateTime now) { if (now.compareTo(this.startDateDoc) < 0) { throw NotDocumentPassDuration.EXCEPTION; } @@ -150,7 +150,7 @@ public void validateBetweenStartDateDocAndResultDateDoc(LocalDate now) { } } - public void validateBetweenResultDateDocAndResultDateFinal(LocalDate now) { + public void validateBetweenResultDateDocAndResultDateFinal(LocalDateTime now) { if (now.compareTo(this.resultDateDoc) < 0) { throw NotFinalPassDuration.EXCEPTION; } @@ -159,13 +159,13 @@ public void validateBetweenResultDateDocAndResultDateFinal(LocalDate now) { } } - public void validateBeforeStartDateDoc(LocalDate now) { + public void validateBeforeStartDateDoc(LocalDateTime now) { if (now.compareTo(this.startDateDoc) >= 0) { throw AlreadyApplicationDuration.EXCEPTION; } } - public void validAmenablePeriod(LocalDate now) { + public void validAmenablePeriod(LocalDateTime now) { if (now.compareTo(this.startDateDoc) >= 0 && now.compareTo(this.resultDateFinal) <= 0) { throw NotAllowedToModify.EXCEPTION; } diff --git a/src/main/java/ceos/backend/domain/recruitment/dto/RecruitmentDTO.java b/src/main/java/ceos/backend/domain/recruitment/dto/RecruitmentDTO.java index c64f8da3..c177e48c 100644 --- a/src/main/java/ceos/backend/domain/recruitment/dto/RecruitmentDTO.java +++ b/src/main/java/ceos/backend/domain/recruitment/dto/RecruitmentDTO.java @@ -3,6 +3,7 @@ import ceos.backend.domain.recruitment.domain.Recruitment; import java.time.LocalDate; +import java.time.LocalDateTime; import lombok.Builder; import lombok.Getter; @@ -12,12 +13,12 @@ public class RecruitmentDTO { private String prodStudyUrl; private String designStudyUrl; private String devStudyUrl; - private LocalDate startDateDoc; - private LocalDate endDateDoc; - private LocalDate resultDateDoc; - private LocalDate startDateInterview; - private LocalDate endDateInterview; - private LocalDate resultDateFinal; + private LocalDateTime startDateDoc; + private LocalDateTime endDateDoc; + private LocalDateTime resultDateDoc; + private LocalDateTime startDateInterview; + private LocalDateTime endDateInterview; + private LocalDateTime resultDateFinal; private String openChatUrl; private LocalDate otDate; private LocalDate ideathonDate; @@ -30,12 +31,12 @@ public RecruitmentDTO( String prodStudyUrl, String designStudyUrl, String devStudyUrl, - LocalDate startDateDoc, - LocalDate endDateDoc, - LocalDate resultDateDoc, - LocalDate startDateInterview, - LocalDate endDateInterview, - LocalDate resultDateFinal, + LocalDateTime startDateDoc, + LocalDateTime endDateDoc, + LocalDateTime resultDateDoc, + LocalDateTime startDateInterview, + LocalDateTime endDateInterview, + LocalDateTime resultDateFinal, String openChatUrl, LocalDate otDate, LocalDate ideathonDate, diff --git a/src/main/java/ceos/backend/domain/recruitment/dto/UserRecruitmentDTO.java b/src/main/java/ceos/backend/domain/recruitment/dto/UserRecruitmentDTO.java index 753db16c..d13b1a6d 100644 --- a/src/main/java/ceos/backend/domain/recruitment/dto/UserRecruitmentDTO.java +++ b/src/main/java/ceos/backend/domain/recruitment/dto/UserRecruitmentDTO.java @@ -3,6 +3,7 @@ import ceos.backend.domain.recruitment.domain.Recruitment; import java.time.LocalDate; +import java.time.LocalDateTime; import lombok.Builder; import lombok.Getter; @@ -12,12 +13,12 @@ public class UserRecruitmentDTO { private String prodStudyUrl; private String designStudyUrl; private String devStudyUrl; - private LocalDate startDateDoc; - private LocalDate endDateDoc; - private LocalDate resultDateDoc; - private LocalDate startDateInterview; - private LocalDate endDateInterview; - private LocalDate resultDateFinal; + private LocalDateTime startDateDoc; + private LocalDateTime endDateDoc; + private LocalDateTime resultDateDoc; + private LocalDateTime startDateInterview; + private LocalDateTime endDateInterview; + private LocalDateTime resultDateFinal; private LocalDate otDate; private LocalDate ideathonDate; private LocalDate hackathonDate; @@ -29,12 +30,12 @@ public UserRecruitmentDTO( String prodStudyUrl, String designStudyUrl, String devStudyUrl, - LocalDate startDateDoc, - LocalDate endDateDoc, - LocalDate resultDateDoc, - LocalDate startDateInterview, - LocalDate endDateInterview, - LocalDate resultDateFinal, + LocalDateTime startDateDoc, + LocalDateTime endDateDoc, + LocalDateTime resultDateDoc, + LocalDateTime startDateInterview, + LocalDateTime endDateInterview, + LocalDateTime resultDateFinal, LocalDate otDate, LocalDate ideathonDate, LocalDate hackathonDate, diff --git a/src/main/java/ceos/backend/domain/recruitment/validator/RecruitmentValidator.java b/src/main/java/ceos/backend/domain/recruitment/validator/RecruitmentValidator.java index 1910a5e1..c8f731f0 100644 --- a/src/main/java/ceos/backend/domain/recruitment/validator/RecruitmentValidator.java +++ b/src/main/java/ceos/backend/domain/recruitment/validator/RecruitmentValidator.java @@ -2,7 +2,7 @@ import ceos.backend.domain.recruitment.helper.RecruitmentHelper; -import java.time.LocalDate; +import java.time.LocalDateTime; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; @@ -14,26 +14,26 @@ public class RecruitmentValidator { public void validateBetweenStartDateDocAndEndDateDoc() { recruitmentHelper .takeRecruitment() - .validateBetweenStartDateDocAndEndDateDoc(LocalDate.now()); + .validateBetweenStartDateDocAndEndDateDoc(LocalDateTime.now()); } public void validateBeforeStartDateDoc() { - recruitmentHelper.takeRecruitment().validateBeforeStartDateDoc(LocalDate.now()); + recruitmentHelper.takeRecruitment().validateBeforeStartDateDoc(LocalDateTime.now()); } public void validateBetweenResultDateDocAndResultDateFinal() { recruitmentHelper .takeRecruitment() - .validateBetweenResultDateDocAndResultDateFinal(LocalDate.now()); + .validateBetweenResultDateDocAndResultDateFinal(LocalDateTime.now()); } public void validateFinalResultAbleDuration() { - recruitmentHelper.takeRecruitment().validateFinalResultAbleDuration(LocalDate.now()); + recruitmentHelper.takeRecruitment().validateFinalResultAbleDuration(LocalDateTime.now()); } public void validateBetweenStartDateDocAndResultDateDoc() { recruitmentHelper .takeRecruitment() - .validateBetweenStartDateDocAndResultDateDoc(LocalDate.now()); + .validateBetweenStartDateDocAndResultDateDoc(LocalDateTime.now()); } } diff --git a/src/test/java/ceos/backend/domain/recruitments/domain/SettingsTest.java b/src/test/java/ceos/backend/domain/recruitments/domain/SettingsTest.java index 869547e7..a0f52b95 100644 --- a/src/test/java/ceos/backend/domain/recruitments/domain/SettingsTest.java +++ b/src/test/java/ceos/backend/domain/recruitments/domain/SettingsTest.java @@ -5,7 +5,7 @@ import ceos.backend.domain.admin.exception.NotAllowedToModify; import ceos.backend.domain.recruitment.domain.Recruitment; import ceos.backend.domain.recruitment.helper.RecruitmentHelper; -import java.time.LocalDate; +import java.time.LocalDateTime; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -23,13 +23,15 @@ void validAmenablePeriod_X() { Recruitment recruitment = recruitmentHelper.takeRecruitment(); // when - LocalDate startDateDoc = recruitment.getStartDateDoc(); - LocalDate date = - LocalDate.of( + LocalDateTime startDateDoc = recruitment.getStartDateDoc(); + + LocalDateTime date = + LocalDateTime.of( startDateDoc.getYear(), startDateDoc.getMonth(), - startDateDoc.getDayOfMonth() + 1); - + startDateDoc.getDayOfMonth(), + startDateDoc.getHour(), + startDateDoc.getMinute() + 1); // then assertThrows( NotAllowedToModify.class, @@ -46,13 +48,14 @@ void validAmenablePeriod_O() { Recruitment recruitment = recruitmentHelper.takeRecruitment(); // when - LocalDate startDateDoc = recruitment.getStartDateDoc(); - LocalDate date = - LocalDate.of( + LocalDateTime startDateDoc = recruitment.getStartDateDoc(); + LocalDateTime date = + LocalDateTime.of( startDateDoc.getYear(), startDateDoc.getMonth(), - startDateDoc.getDayOfMonth() - 1); - + startDateDoc.getDayOfMonth(), + startDateDoc.getHour(), + startDateDoc.getMinute() - 1); // then recruitment.validAmenablePeriod(date); } From 638d1ce65d8ea9eb32e6caeabea0619af0a1b48b Mon Sep 17 00:00:00 2001 From: Seo Chanhyeok Date: Mon, 18 Dec 2023 15:47:49 +0900 Subject: [PATCH 04/18] =?UTF-8?q?[refact]=20github=20actions=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy_dev.yml | 172 ++++++++++++++++++++----------- 1 file changed, 109 insertions(+), 63 deletions(-) diff --git a/.github/workflows/deploy_dev.yml b/.github/workflows/deploy_dev.yml index 75bf1ed3..543a2adc 100644 --- a/.github/workflows/deploy_dev.yml +++ b/.github/workflows/deploy_dev.yml @@ -10,7 +10,9 @@ permissions: jobs: build: - runs-on: ubuntu-latest + # runs-on을 ubuntu-lastest에서 변경했음 + # 참고자료 https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on + runs-on: linux steps: # 기본 체크아웃 - name: Checkout @@ -23,43 +25,9 @@ jobs: java-version: '17' distribution: 'temurin' - # 그래들 캐싱 - - name: Gradle Caching - uses: actions/cache@v3 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-gradle- - - - name: Make application-secret.yml without env - run: | - touch ./src/main/resources/application-secret.yml - echo "${{ secrets.APPLICATION_SECRET_DEV }}" > ./src/main/resources/application-secret.yml - env: - PROPERTIES_DEV: ${{ secrets.APPLICATION_SECRET_DEV }} - - - name: Make env - run: | - touch .env - echo "${{ secrets.ENV_DEV }}" > .env - env: - PROPERTIES_DEV: ${{ secrets.ENV_DEV }} - - # Gradle build + ## gradle build - name: Build with Gradle - run: ./gradlew build -x test :spotlessApply - - - name: Docker meta - id: docker_meta - uses: crazy-max/ghaction-docker-meta@v1 - with: - images: ceos/ceos-server-dev - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + run: ./gradlew bootJar - name: Login to DockerHub uses: docker/login-action@v1 @@ -72,38 +40,116 @@ jobs: with: context: . file: ./Dockerfile - platforms: linux/amd64 + platforms: linux/x86 # linux/amd64에서 변경 (compatibility) push: true tags: ${{ secrets.DOCKER_USERNAME }}/ceos-backend-dev - - name: create remote directory - uses: appleboy/ssh-action@master - with: - host: ${{ secrets.EC2_HOST_DEV }} - username: ubuntu - key: ${{ secrets.EC2_KEY_DEV }} - script: mkdir -p ~/srv/ubuntu/ceos_web_dev - - - name: copy source via ssh key - uses: burnett01/rsync-deployments@4.1 - with: - switches: -avzr --delete - remote_path: ~/srv/ubuntu/ - remote_host: ${{ secrets.EC2_HOST_DEV }} - remote_user: ubuntu - remote_key: ${{ secrets.EC2_KEY_DEV }} - + # ssh 접근 후 docker 이미지 pull 및 컨테이너 재시작 - name: executing remote ssh commands using password uses: appleboy/ssh-action@master with: host: ${{ secrets.EC2_HOST_DEV }} - username: ubuntu + username: ec2-user # ubuntu 에서 변경 key: ${{ secrets.EC2_KEY_DEV }} script: | - sh ~/srv/ubuntu/config/scripts/deploy.sh - sudo docker stop $(sudo docker ps -a -q) - sudo docker rm $(sudo docker ps -a -q) - sudo docker rmi $(sudo docker images -q) - sudo docker-compose -f ~/srv/ubuntu/docker-compose.dev.yml pull - sudo docker-compose -f ~/srv/ubuntu/docker-compose.dev.yml up --build -d - + cd /home/ec2-user/ceos + + sudo touch .env + echo "${{ secrets.ENV_DEV }}" > .env + + sudo curl -o docker-compose.yml https://raw.githubusercontent.com/CEOS-Developers/CEOS-BE/dev/docker-compose.dev.yml + + sudo chmod 666 /var/run/docker.sock + sudo docker rm -f $(docker ps -qa) + sudo docker pull ${{ secrets.DOCKER_USERNAME }}/ceos-backend-dev + docker-compose -f docker-compose.dev.yml --env-file ./.env up -d + docker image prune -f + + + + +# 주석 처리함 (레거시 코드) +# +# # 그래들 캐싱 +# - name: Gradle Caching +# uses: actions/cache@v3 +# with: +# path: | +# ~/.gradle/caches +# ~/.gradle/wrapper +# key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} +# restore-keys: | +# ${{ runner.os }}-gradle- +# +# - name: Make application-secret.yml without env +# run: | +# touch ./src/main/resources/application-secret.yml +# echo "${{ secrets.APPLICATION_SECRET_DEV }}" > ./src/main/resources/application-secret.yml +# env: +# PROPERTIES_DEV: ${{ secrets.APPLICATION_SECRET_DEV }} +# +# - name: Make env +# run: | +# touch .env +# echo "${{ secrets.ENV_DEV }}" > .env +# env: +# PROPERTIES_DEV: ${{ secrets.ENV_DEV }} +# +# # Gradle build +# - name: Build with Gradle +# run: ./gradlew build -x test :spotlessApply +# +# - name: Docker meta +# id: docker_meta +# uses: crazy-max/ghaction-docker-meta@v1 +# with: +# images: +# +# - name: Set up Docker Buildx +# uses: docker/setup-buildx-action@v1 +# +# - name: Login to DockerHub +# uses: docker/login-action@v1 +# with: +# username: ${{ secrets.DOCKER_USERNAME }} +# password: ${{ secrets.DOCKER_PASSWORD }} +# +# - name: Docker build & push +# uses: docker/build-push-action@v2 +# with: +# context: . +# file: ./Dockerfile +# platforms: linux/amd64 +# push: true +# tags: ${{ secrets.DOCKER_USERNAME }}/ceos-backend-dev +# +# - name: create remote directory +# uses: appleboy/ssh-action@master +# with: +# host: ${{ secrets.EC2_HOST_DEV }} +# username: ubuntu +# key: ${{ secrets.EC2_KEY_DEV }} +# script: mkdir -p ~/srv/ubuntu/ceos_web_dev +# +# - name: copy source via ssh key +# uses: burnett01/rsync-deployments@4.1 +# with: +# switches: -avzr --delete +# remote_path: ~/srv/ubuntu/ +# remote_host: ${{ secrets.EC2_HOST_DEV }} +# remote_user: ubuntu +# remote_key: ${{ secrets.EC2_KEY_DEV }} +# +# - name: executing remote ssh commands using password +# uses: appleboy/ssh-action@master +# with: +# host: ${{ secrets.EC2_HOST_DEV }} +# username: ubuntu +# key: ${{ secrets.EC2_KEY_DEV }} +# script: | +# sh ~/srv/ubuntu/config/scripts/deploy.sh +# sudo docker stop $(sudo docker ps -a -q) +# sudo docker rm $(sudo docker ps -a -q) +# sudo docker rmi $(sudo docker images -q) +# sudo docker-compose -f ~/srv/ubuntu/docker-compose.dev.yml pull +# sudo docker-compose -f ~/srv/ubuntu/docker-compose.dev.yml up --build -d \ No newline at end of file From 8d32cdb65ea5aabfcfcb70933b172011e8011092 Mon Sep 17 00:00:00 2001 From: Seo Chanhyeok Date: Mon, 18 Dec 2023 15:57:48 +0900 Subject: [PATCH 05/18] =?UTF-8?q?[fix]=20platforms=20=EC=9B=90=EB=B3=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy_dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy_dev.yml b/.github/workflows/deploy_dev.yml index 543a2adc..1c367428 100644 --- a/.github/workflows/deploy_dev.yml +++ b/.github/workflows/deploy_dev.yml @@ -40,7 +40,7 @@ jobs: with: context: . file: ./Dockerfile - platforms: linux/x86 # linux/amd64에서 변경 (compatibility) + platforms: linux/amd64 push: true tags: ${{ secrets.DOCKER_USERNAME }}/ceos-backend-dev From 7ed4a75721c7cb7b1705f42ee28be41f46e79ebf Mon Sep 17 00:00:00 2001 From: Seo Chanhyeok Date: Mon, 18 Dec 2023 16:17:17 +0900 Subject: [PATCH 06/18] =?UTF-8?q?[fix]=20=EC=9B=8C=ED=81=AC=ED=94=8C?= =?UTF-8?q?=EB=A1=9C=EC=9A=B0=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy_dev.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy_dev.yml b/.github/workflows/deploy_dev.yml index 1c367428..765526ce 100644 --- a/.github/workflows/deploy_dev.yml +++ b/.github/workflows/deploy_dev.yml @@ -3,16 +3,14 @@ name: Deploy to EC2 on: push: branches: - - dev + - refact/os-migration permissions: contents: read jobs: build: - # runs-on을 ubuntu-lastest에서 변경했음 - # 참고자료 https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on - runs-on: linux + runs-on: ubuntu-latest steps: # 기본 체크아웃 - name: Checkout From 3955b22bdb761d548d9c87bba88e176d51bca864 Mon Sep 17 00:00:00 2001 From: Seo Chanhyeok Date: Mon, 18 Dec 2023 16:21:23 +0900 Subject: [PATCH 07/18] =?UTF-8?q?[fix]=20ssh=20=EC=8A=A4=ED=81=AC=EB=A6=BD?= =?UTF-8?q?=ED=8A=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy_dev.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy_dev.yml b/.github/workflows/deploy_dev.yml index 765526ce..e04003fe 100644 --- a/.github/workflows/deploy_dev.yml +++ b/.github/workflows/deploy_dev.yml @@ -53,9 +53,9 @@ jobs: cd /home/ec2-user/ceos sudo touch .env - echo "${{ secrets.ENV_DEV }}" > .env + echo "${{ secrets.ENV_DEV }}" | sudo tee .env > /dev/null - sudo curl -o docker-compose.yml https://raw.githubusercontent.com/CEOS-Developers/CEOS-BE/dev/docker-compose.dev.yml + sudo curl -o docker-compose.dev.yml https://raw.githubusercontent.com/CEOS-Developers/CEOS-BE/dev/docker-compose.dev.yml sudo chmod 666 /var/run/docker.sock sudo docker rm -f $(docker ps -qa) From baace29b6b7cb2c7c5039e2a84a3d844f70fa534 Mon Sep 17 00:00:00 2001 From: Seo Chanhyeok Date: Mon, 18 Dec 2023 16:37:29 +0900 Subject: [PATCH 08/18] =?UTF-8?q?[feat]=20nginx=20clone=20=EC=97=86?= =?UTF-8?q?=EC=9D=B4=20=EB=8F=84=EC=BB=A4=ED=97=88=EB=B8=8C=EB=A1=9C=20?= =?UTF-8?q?=EB=B0=9B=EC=95=84=EC=98=A4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy_dev.yml | 12 +++++++++++- docker-compose.dev.yml | 4 +--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy_dev.yml b/.github/workflows/deploy_dev.yml index e04003fe..6163c93a 100644 --- a/.github/workflows/deploy_dev.yml +++ b/.github/workflows/deploy_dev.yml @@ -33,7 +33,7 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Docker build & push + - name: Docker app build & push uses: docker/build-push-action@v2 with: context: . @@ -42,6 +42,15 @@ jobs: push: true tags: ${{ secrets.DOCKER_USERNAME }}/ceos-backend-dev + - name: Docker nginx build & push + uses: docker/build-push-action@v2 + with: + context: . + file: ./config/nginx/Dockerfile + platforms: linux/amd64 + push: true + tags: ${{ secrets.DOCKER_USERNAME }}/ceos-nginx-dev + # ssh 접근 후 docker 이미지 pull 및 컨테이너 재시작 - name: executing remote ssh commands using password uses: appleboy/ssh-action@master @@ -60,6 +69,7 @@ jobs: sudo chmod 666 /var/run/docker.sock sudo docker rm -f $(docker ps -qa) sudo docker pull ${{ secrets.DOCKER_USERNAME }}/ceos-backend-dev + sudo docker pull ${{ secrets.DOCKER_USERNAME }}/ceos-nginx-dev docker-compose -f docker-compose.dev.yml --env-file ./.env up -d docker image prune -f diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index a1f97e1f..3704f97f 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -11,12 +11,10 @@ services: - "8080" nginx: + image: ceos17/ceos-nginx-dev depends_on: - backend restart: always - build: - dockerfile: Dockerfile - context: ./config/nginx ports: - "80:80" From 629736d7ce8d2f1b2d36066f25647cabb8965088 Mon Sep 17 00:00:00 2001 From: Seo Chanhyeok Date: Mon, 18 Dec 2023 16:43:48 +0900 Subject: [PATCH 09/18] =?UTF-8?q?[feat]=20nginx=20clone=20=EC=97=86?= =?UTF-8?q?=EC=9D=B4=20=EB=8F=84=EC=BB=A4=ED=97=88=EB=B8=8C=EB=A1=9C=20?= =?UTF-8?q?=EB=B0=9B=EC=95=84=EC=98=A4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/nginx/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/nginx/Dockerfile b/config/nginx/Dockerfile index 30be99d3..d029e059 100644 --- a/config/nginx/Dockerfile +++ b/config/nginx/Dockerfile @@ -1,2 +1,2 @@ FROM nginx:1.23.2 -COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file +COPY ./config/nginx/default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file From cd46ee514835eb5009a2e16270d023e06916b1f3 Mon Sep 17 00:00:00 2001 From: Seo Chanhyeok Date: Mon, 18 Dec 2023 16:56:26 +0900 Subject: [PATCH 10/18] =?UTF-8?q?[feat]=20docker-compose=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=EC=8B=9C=20=EC=9E=90=EB=8F=99=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy_dev.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/deploy_dev.yml b/.github/workflows/deploy_dev.yml index 6163c93a..28014e8a 100644 --- a/.github/workflows/deploy_dev.yml +++ b/.github/workflows/deploy_dev.yml @@ -64,6 +64,7 @@ jobs: sudo touch .env echo "${{ secrets.ENV_DEV }}" | sudo tee .env > /dev/null + sudo rm docker-compose.dev.yml sudo curl -o docker-compose.dev.yml https://raw.githubusercontent.com/CEOS-Developers/CEOS-BE/dev/docker-compose.dev.yml sudo chmod 666 /var/run/docker.sock From c5c7d25a7223eb1ba5bd4dc81354042dfeaf9298 Mon Sep 17 00:00:00 2001 From: Seo Chanhyeok Date: Mon, 18 Dec 2023 23:32:44 +0900 Subject: [PATCH 11/18] =?UTF-8?q?[refact]=20=EB=B0=B0=ED=8F=AC=ED=99=98?= =?UTF-8?q?=EA=B2=BD=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy_dev.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/deploy_dev.yml b/.github/workflows/deploy_dev.yml index 28014e8a..53f39414 100644 --- a/.github/workflows/deploy_dev.yml +++ b/.github/workflows/deploy_dev.yml @@ -64,8 +64,7 @@ jobs: sudo touch .env echo "${{ secrets.ENV_DEV }}" | sudo tee .env > /dev/null - sudo rm docker-compose.dev.yml - sudo curl -o docker-compose.dev.yml https://raw.githubusercontent.com/CEOS-Developers/CEOS-BE/dev/docker-compose.dev.yml + sudo curl -o docker-compose.dev.yml https://raw.githubusercontent.com/CEOS-Developers/CEOS-BE/refact/os-migration/docker-compose.dev.yml sudo chmod 666 /var/run/docker.sock sudo docker rm -f $(docker ps -qa) From 4be1e52357baa87889db9574c0f10db9058edf99 Mon Sep 17 00:00:00 2001 From: Seo Chanhyeok Date: Mon, 18 Dec 2023 23:39:57 +0900 Subject: [PATCH 12/18] =?UTF-8?q?[fix]=20application=5Fsecret=5Fdev=20?= =?UTF-8?q?=EA=B0=80=EC=A0=B8=EC=98=A4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy_dev.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/deploy_dev.yml b/.github/workflows/deploy_dev.yml index 53f39414..e58e254d 100644 --- a/.github/workflows/deploy_dev.yml +++ b/.github/workflows/deploy_dev.yml @@ -33,6 +33,13 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} + - name: Make application-secret.yml without env + run: | + touch ./src/main/resources/application-secret.yml + echo "${{ secrets.APPLICATION_SECRET_DEV }}" > ./src/main/resources/application-secret.yml + env: + PROPERTIES_DEV: ${{ secrets.APPLICATION_SECRET_DEV }} + - name: Docker app build & push uses: docker/build-push-action@v2 with: From faeff14aeef8fc9e029332585c90f1397328c817 Mon Sep 17 00:00:00 2001 From: Seo Chanhyeok Date: Mon, 18 Dec 2023 23:53:18 +0900 Subject: [PATCH 13/18] =?UTF-8?q?[fix]=20application=5Fsecret=5Fdev=20?= =?UTF-8?q?=EA=B0=80=EC=A0=B8=EC=98=A4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy_dev.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/deploy_dev.yml b/.github/workflows/deploy_dev.yml index e58e254d..8cc9e05a 100644 --- a/.github/workflows/deploy_dev.yml +++ b/.github/workflows/deploy_dev.yml @@ -70,6 +70,7 @@ jobs: sudo touch .env echo "${{ secrets.ENV_DEV }}" | sudo tee .env > /dev/null + echo "${{ secrets.APPLICATION_SECRET_DEV }}" | sudo tee test > /dev/null sudo curl -o docker-compose.dev.yml https://raw.githubusercontent.com/CEOS-Developers/CEOS-BE/refact/os-migration/docker-compose.dev.yml From 0da9bb04e284264ef355d71ccc4b98c393b8e862 Mon Sep 17 00:00:00 2001 From: Seo Chanhyeok Date: Tue, 19 Dec 2023 00:01:59 +0900 Subject: [PATCH 14/18] =?UTF-8?q?[fix]=20application=5Fsecret=5Fdev=20?= =?UTF-8?q?=EA=B0=80=EC=A0=B8=EC=98=A4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy_dev.yml | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/deploy_dev.yml b/.github/workflows/deploy_dev.yml index 8cc9e05a..7f58edbb 100644 --- a/.github/workflows/deploy_dev.yml +++ b/.github/workflows/deploy_dev.yml @@ -15,6 +15,9 @@ jobs: # 기본 체크아웃 - name: Checkout uses: actions/checkout@v3 + run: | + touch ./src/main/resources/application-secret.yml + echo "${{ secrets.APPLICATION_SECRET_DEV }}" > ./src/main/resources/application-secret.yml # JDK version 설정 - name: Set up JDK 17 @@ -33,13 +36,6 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Make application-secret.yml without env - run: | - touch ./src/main/resources/application-secret.yml - echo "${{ secrets.APPLICATION_SECRET_DEV }}" > ./src/main/resources/application-secret.yml - env: - PROPERTIES_DEV: ${{ secrets.APPLICATION_SECRET_DEV }} - - name: Docker app build & push uses: docker/build-push-action@v2 with: @@ -70,7 +66,6 @@ jobs: sudo touch .env echo "${{ secrets.ENV_DEV }}" | sudo tee .env > /dev/null - echo "${{ secrets.APPLICATION_SECRET_DEV }}" | sudo tee test > /dev/null sudo curl -o docker-compose.dev.yml https://raw.githubusercontent.com/CEOS-Developers/CEOS-BE/refact/os-migration/docker-compose.dev.yml From e257387a837e4661fd7a54670b29984b430f95ef Mon Sep 17 00:00:00 2001 From: Seo Chanhyeok Date: Tue, 19 Dec 2023 00:02:37 +0900 Subject: [PATCH 15/18] =?UTF-8?q?[fix]=20application=5Fsecret=5Fdev=20?= =?UTF-8?q?=EA=B0=80=EC=A0=B8=EC=98=A4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy_dev.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/deploy_dev.yml b/.github/workflows/deploy_dev.yml index 7f58edbb..5f29fad6 100644 --- a/.github/workflows/deploy_dev.yml +++ b/.github/workflows/deploy_dev.yml @@ -15,6 +15,8 @@ jobs: # 기본 체크아웃 - name: Checkout uses: actions/checkout@v3 + + - name: Make application-secret.yml without env run: | touch ./src/main/resources/application-secret.yml echo "${{ secrets.APPLICATION_SECRET_DEV }}" > ./src/main/resources/application-secret.yml From 958f8ab970668b3747c91956fd7c8dc588694963 Mon Sep 17 00:00:00 2001 From: Seo Chanhyeok Date: Tue, 19 Dec 2023 00:15:47 +0900 Subject: [PATCH 16/18] [fix] docker-push-action version upgrade --- .github/workflows/deploy_dev.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy_dev.yml b/.github/workflows/deploy_dev.yml index 5f29fad6..1477ef33 100644 --- a/.github/workflows/deploy_dev.yml +++ b/.github/workflows/deploy_dev.yml @@ -33,13 +33,13 @@ jobs: run: ./gradlew bootJar - name: Login to DockerHub - uses: docker/login-action@v1 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Docker app build & push - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v5 with: context: . file: ./Dockerfile @@ -48,7 +48,7 @@ jobs: tags: ${{ secrets.DOCKER_USERNAME }}/ceos-backend-dev - name: Docker nginx build & push - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v5 with: context: . file: ./config/nginx/Dockerfile From ac8bd72e4d2d01d9f8843c96e28d8abfa09c8e78 Mon Sep 17 00:00:00 2001 From: Seo Chanhyeok Date: Tue, 19 Dec 2023 00:21:27 +0900 Subject: [PATCH 17/18] =?UTF-8?q?[refact]=20dev=EC=97=90=20=EB=A7=9E?= =?UTF-8?q?=EA=B2=8C=20=EB=B8=8C=EB=9E=9C=EC=B9=98=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy_dev.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy_dev.yml b/.github/workflows/deploy_dev.yml index 1477ef33..a9808cc1 100644 --- a/.github/workflows/deploy_dev.yml +++ b/.github/workflows/deploy_dev.yml @@ -3,7 +3,7 @@ name: Deploy to EC2 on: push: branches: - - refact/os-migration + - dev permissions: contents: read @@ -69,7 +69,7 @@ jobs: sudo touch .env echo "${{ secrets.ENV_DEV }}" | sudo tee .env > /dev/null - sudo curl -o docker-compose.dev.yml https://raw.githubusercontent.com/CEOS-Developers/CEOS-BE/refact/os-migration/docker-compose.dev.yml + sudo curl -o docker-compose.dev.yml https://raw.githubusercontent.com/CEOS-Developers/CEOS-BE/dev/docker-compose.dev.yml sudo chmod 666 /var/run/docker.sock sudo docker rm -f $(docker ps -qa) From 1217f283256cd2478125160e5563666e1c4d25c0 Mon Sep 17 00:00:00 2001 From: Seo Chanhyeok Date: Tue, 19 Dec 2023 09:11:13 +0900 Subject: [PATCH 18/18] =?UTF-8?q?[feat]=20main=20=EB=B8=8C=EB=9E=9C?= =?UTF-8?q?=EC=B9=98=20=EC=9B=8C=ED=81=AC=ED=94=8C=EB=A1=9C=EC=9A=B0=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy_prod.yml | 204 +++++++++++++++++++++--------- 1 file changed, 142 insertions(+), 62 deletions(-) diff --git a/.github/workflows/deploy_prod.yml b/.github/workflows/deploy_prod.yml index f9c5d862..611d6f9e 100644 --- a/.github/workflows/deploy_prod.yml +++ b/.github/workflows/deploy_prod.yml @@ -16,6 +16,11 @@ jobs: - name: Checkout uses: actions/checkout@v3 + - name: Make application-secret.yml without env + run: | + touch ./src/main/resources/application-secret.yml + echo "${{ secrets.APPLICATION_SECRET }}" > ./src/main/resources/application-secret.yml + # JDK version 설정 - name: Set up JDK 17 uses: actions/setup-java@v3 @@ -23,52 +28,18 @@ jobs: java-version: '17' distribution: 'temurin' - # 그래들 캐싱 - - name: Gradle Caching - uses: actions/cache@v3 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-gradle- - - - name: Make application-secret.yml without env - run: | - touch ./src/main/resources/application-secret.yml - echo "${{ secrets.APPLICATION_SECRET }}" > ./src/main/resources/application-secret.yml - env: - PROPERTIES_DEV: ${{ secrets.APPLICATION_SECRET }} - - - name: Make env - run: | - touch .env - echo "${{ secrets.ENV_PROD }}" > .env - env: - PROPERTIES_DEV: ${{ secrets.ENV_PROD }} - - # Gradle build + ## gradle build - name: Build with Gradle - run: ./gradlew build -x test :spotlessApply - - - name: Docker meta - id: docker_meta - uses: crazy-max/ghaction-docker-meta@v1 - with: - images: ceos/ceos-server-dev - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + run: ./gradlew bootJar - name: Login to DockerHub - uses: docker/login-action@v1 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Docker build & push - uses: docker/build-push-action@v2 + - name: Docker app build & push + uses: docker/build-push-action@v5 with: context: . file: ./Dockerfile @@ -76,34 +47,143 @@ jobs: push: true tags: ${{ secrets.DOCKER_USERNAME }}/ceos-backend - - name: create remote directory - uses: appleboy/ssh-action@master + - name: Docker nginx build & push + uses: docker/build-push-action@v5 with: - host: ${{ secrets.EC2_HOST_PROD }} - username: ubuntu - key: ${{ secrets.EC2_KEY_PROD }} - script: mkdir -p ~/srv/ubuntu/ceos_web_dev - - - name: copy source via ssh key - uses: burnett01/rsync-deployments@4.1 - with: - switches: -avzr --delete - remote_path: ~/srv/ubuntu/ - remote_host: ${{ secrets.EC2_HOST_PROD }} - remote_user: ubuntu - remote_key: ${{ secrets.EC2_KEY_PROD }} + context: . + file: ./config/nginx/Dockerfile + platforms: linux/amd64 + push: true + tags: ${{ secrets.DOCKER_USERNAME }}/ceos-nginx + # ssh 접근 후 docker 이미지 pull 및 컨테이너 재시작 - name: executing remote ssh commands using password uses: appleboy/ssh-action@master with: host: ${{ secrets.EC2_HOST_PROD }} - username: ubuntu + username: ec2-user # ubuntu 에서 변경 key: ${{ secrets.EC2_KEY_PROD }} script: | - sh ~/srv/ubuntu/config/scripts/deploy.sh - sudo docker stop $(sudo docker ps -a -q) - sudo docker rm $(sudo docker ps -a -q) - sudo docker rmi $(sudo docker images -q) - sudo docker-compose -f ~/srv/ubuntu/docker-compose.yml pull - sudo docker-compose -f ~/srv/ubuntu/docker-compose.yml up --build -d - + cd /home/ec2-user/ceos + + sudo touch .env + echo "${{ secrets.ENV_PROD }}" | sudo tee .env > /dev/null + + sudo curl -o docker-compose.yml https://raw.githubusercontent.com/CEOS-Developers/CEOS-BE/main/docker-compose.yml + + sudo chmod 666 /var/run/docker.sock + sudo docker rm -f $(docker ps -qa) + sudo docker pull ${{ secrets.DOCKER_USERNAME }}/ceos-backend + sudo docker pull ${{ secrets.DOCKER_USERNAME }}/ceos-nginx + docker-compose -f docker-compose.yml --env-file ./.env up -d + docker image prune -f + +#name: Deploy to EC2 +# +#on: +# push: +# branches: +# - main +# +#permissions: +# contents: read +# +#jobs: +# build: +# runs-on: ubuntu-latest +# steps: +# # 기본 체크아웃 +# - name: Checkout +# uses: actions/checkout@v3 +# +# # JDK version 설정 +# - name: Set up JDK 17 +# uses: actions/setup-java@v3 +# with: +# java-version: '17' +# distribution: 'temurin' +# +# # 그래들 캐싱 +# - name: Gradle Caching +# uses: actions/cache@v3 +# with: +# path: | +# ~/.gradle/caches +# ~/.gradle/wrapper +# key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} +# restore-keys: | +# ${{ runner.os }}-gradle- +# +# - name: Make application-secret.yml without env +# run: | +# touch ./src/main/resources/application-secret.yml +# echo "${{ secrets.APPLICATION_SECRET }}" > ./src/main/resources/application-secret.yml +# env: +# PROPERTIES_DEV: ${{ secrets.APPLICATION_SECRET }} +# +# - name: Make env +# run: | +# touch .env +# echo "${{ secrets.ENV_PROD }}" > .env +# env: +# PROPERTIES_DEV: ${{ secrets.ENV_PROD }} +# +# # Gradle build +# - name: Build with Gradle +# run: ./gradlew build -x test :spotlessApply +# +# - name: Docker meta +# id: docker_meta +# uses: crazy-max/ghaction-docker-meta@v1 +# with: +# images: ceos/ceos-server-dev +# +# - name: Set up Docker Buildx +# uses: docker/setup-buildx-action@v1 +# +# - name: Login to DockerHub +# uses: docker/login-action@v1 +# with: +# username: ${{ secrets.DOCKER_USERNAME }} +# password: ${{ secrets.DOCKER_PASSWORD }} +# +# - name: Docker build & push +# uses: docker/build-push-action@v2 +# with: +# context: . +# file: ./Dockerfile +# platforms: linux/amd64 +# push: true +# tags: ${{ secrets.DOCKER_USERNAME }}/ceos-backend +# +# - name: create remote directory +# uses: appleboy/ssh-action@master +# with: +# host: ${{ secrets.EC2_HOST_PROD }} +# username: ubuntu +# key: ${{ secrets.EC2_KEY_PROD }} +# script: mkdir -p ~/srv/ubuntu/ceos_web_dev +# +# - name: copy source via ssh key +# uses: burnett01/rsync-deployments@4.1 +# with: +# switches: -avzr --delete +# remote_path: ~/srv/ubuntu/ +# remote_host: ${{ secrets.EC2_HOST_PROD }} +# remote_user: ubuntu +# remote_key: ${{ secrets.EC2_KEY_PROD }} +# +# - name: executing remote ssh commands using password +# uses: appleboy/ssh-action@master +# with: +# host: ${{ secrets.EC2_HOST_PROD }} +# username: ubuntu +# key: ${{ secrets.EC2_KEY_PROD }} +# script: | +# sh ~/srv/ubuntu/config/scripts/deploy.sh +# sudo docker stop $(sudo docker ps -a -q) +# sudo docker rm $(sudo docker ps -a -q) +# sudo docker rmi $(sudo docker images -q) +# sudo docker-compose -f ~/srv/ubuntu/docker-compose.yml pull +# sudo docker-compose -f ~/srv/ubuntu/docker-compose.yml up --build -d +#