From 10a5f4ab600445382de3897171282a0219f04df3 Mon Sep 17 00:00:00 2001 From: choisungwook Date: Sat, 22 Jan 2022 00:59:02 +0900 Subject: [PATCH 01/38] =?UTF-8?q?jaypst=20=EC=95=94=ED=98=B8=ED=99=94&?= =?UTF-8?q?=EB=B3=B5=ED=98=B8=ED=99=94=EB=AA=A8=EB=93=88=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/build.gradle | 2 - .../com/infp/ciat/config/JasyptConfig.java | 27 -------- .../src/main/resources/application-dev.yml | 64 ----------------- .../src/main/resources/application-test.yml | 57 --------------- backend/src/main/resources/application.yml | 69 ------------------- .../com/infp/ciat/CiatApplicationTests.java | 7 -- .../category/service/MenuServiceTest.java | 10 +-- .../controller/AccountControllerTest.java | 6 -- .../ciat/user/service/AccountServiceTest.java | 10 +-- 9 files changed, 10 insertions(+), 242 deletions(-) delete mode 100644 backend/src/main/java/com/infp/ciat/config/JasyptConfig.java delete mode 100644 backend/src/main/resources/application-dev.yml delete mode 100644 backend/src/main/resources/application-test.yml delete mode 100644 backend/src/main/resources/application.yml diff --git a/backend/build.gradle b/backend/build.gradle index 953f083a..23f1b5ee 100644 --- a/backend/build.gradle +++ b/backend/build.gradle @@ -23,7 +23,6 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-security' implementation 'org.springframework.boot:spring-boot-starter-oauth2-client' implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.6' - implementation group: 'com.github.ulisesbocchio', name: 'jasypt-spring-boot-starter', version: '3.0.3' implementation 'org.springframework.boot:spring-boot-starter-web' compileOnly 'org.projectlombok:lombok' developmentOnly 'org.springframework.boot:spring-boot-devtools' @@ -43,7 +42,6 @@ dependencies { } test { - environment "jasypt.encryptor.password", System.getenv("jasypt_password") useJUnitPlatform() } diff --git a/backend/src/main/java/com/infp/ciat/config/JasyptConfig.java b/backend/src/main/java/com/infp/ciat/config/JasyptConfig.java deleted file mode 100644 index c09dc92a..00000000 --- a/backend/src/main/java/com/infp/ciat/config/JasyptConfig.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.infp.ciat.config; - -import org.jasypt.encryption.StringEncryptor; -import org.jasypt.encryption.pbe.PooledPBEStringEncryptor; -import org.jasypt.encryption.pbe.config.SimpleStringPBEConfig; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class JasyptConfig { - @Bean("jasyptStringEncryptor") - public StringEncryptor stringEncryptor() { - PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor(); - SimpleStringPBEConfig config = new SimpleStringPBEConfig(); - config.setPassword(System.getProperty("jasypt.encryptor.password")); - config.setAlgorithm("PBEWITHHMACSHA512ANDAES_256"); - config.setKeyObtentionIterations("1000"); - config.setPoolSize("1"); - config.setProviderName("SunJCE"); - config.setSaltGeneratorClassName("org.jasypt.salt.RandomSaltGenerator"); - config.setIvGeneratorClassName("org.jasypt.iv.RandomIvGenerator"); - config.setStringOutputType("base64"); - encryptor.setConfig(config); - - return encryptor; - } -} \ No newline at end of file diff --git a/backend/src/main/resources/application-dev.yml b/backend/src/main/resources/application-dev.yml deleted file mode 100644 index 59b4d8d4..00000000 --- a/backend/src/main/resources/application-dev.yml +++ /dev/null @@ -1,64 +0,0 @@ -server: - port: 9400 - servlet: - session: - cookie: - http-only: false - secure: false -jwt: - secret: ENC(1MBsToCDbYBEvJkfxlSkoBb30kG1MYPqYOcyUcKZOhnodcSkYMncHeTYNyKr0GfYocr9yI3G1cR6DJHykIZTpQ==) - -logging: - level: - com: - infp: - ciat: debug - amazonaws: - util: - EC2MetadataUtils: error -spring: - security: - oauth2: - client: - # registration - registration: - # google oauth2 setting - google: - client-id: ENC(yOSSFYzdF6BFvb+VhuwrUUvnEwhdYJQhPAt7O+I9CP/fGWq0EjmEwnYXmz7Yu/QyS9kwLcV4TyTVvnikUI4PKr+eEk1AUVMKNayFLTnIKA8f4KnP82cNsbQKaM/DN2N7Taw0LJHl4CMP8+QBBRI0JA==) - client-secret: ENC(n093NQezyIRURhvV7DI/t5NrG5WL9f/ks4NkKhEew6X+GBEpCuzW4syxqsRYO3jkqYELcDNz2xPUz3X9Dzp3yW2WLLp8k0Hq5rGyyhTgl5I=) - scope: - - profile - - email - # github oauth2 setting - github: - client-id: ENC(avR1sIiT2FjiEV8Gfc9VsnDj64R1Z76CsfJUkbWraReGvQPXBo27UKP6Pm3rhs18EgqNtD7b2Xm5IwezPSkprA==) - client-secret: ENC(6h5LvXhqQHUPBD6JqnwzNRlFlfA0g4tjqgP0cPxOUUiVBYIylACHiBS++qICPA2pAzubXiXMDxXkwj7GRz6Dofsz2utfQ/YNrlVNsAOYhTE=) - datasource: - url: ENC(SdMJj9dKGhkF+VFShqVQMGHlkmAhjmM0XPWIyA1Nm0FPqORrLWc9cEk29FF6ntVvLLGPdp8cS9F875BZ+hgkEQVZ0gwhz6wN3MlEvggPDp5NnuLWwqZ3KwVznInPehxqZEpa1dbAlFv/5Gmcl8uISQ==) - driver-class-name: ENC(dhW7Cm9yna7f1mV0Bex6qSMlA+AhOuZdUDU18VFe4YTvBz1Rev0UeU1rmcSHlA/wGwM+VqMMAKHs2R+j21LHOA==) - username: ENC(blW7MEaDg8iJTGp5PEETV5e1hIwlMxVZsn1eBI8iZ5/OxhY4dvZKIzb9fE4g0R7y) - password: ENC(u+eGNk3Cmyzf2ZbtQfKWBAmN3bWWVTUMiLK2FbCtp7Iya1hs0x2cs2DqQVtGH4dj0a+NjswWJO8nbBNz10hflg==) - jpa: - open-in-view: false - generate-ddl: true - show-sql: true - hibernate: - ddl-auto: update - database-platform: ENC(HUPevaLfmLDzFPVbGkeMOkOm3Y38mg6zxfNXUJsckzCwJEnVl6rhURSMQSf8lHh8WIBkBvmMNq2CVz0Uhu3fX1AjmQHIpcOOJHONm8X0eHA=) - -#농사로 api service key, public url -nongsaro: - url: http://api.nongsaro.go.kr/service/garden/ - key: ENC(53HGLcuFthBpODy/ksdZzUFiyznV5LG4QhgoFUlZvtIMUEU1Mc7Pwtvqd+h8wDidfZmt+aQLx/jmrpM+u7ZUhg==) - -cloud: - aws: - credentials: - accessKey: ENC(qnoRD48Vb/ynF7VFZA8jn3sH8Pf8F3EMLCuHAwFA5yM+dtFiXPANaTQqO/pBxlM+IFp3yDJsVZYJ25EnB8xJVw==) - secretKey: ENC(vkgcPsB5+80n3xZIS5v3NDUP+zphtLKkOJtRU5Jne7dc3+hjp03xoKMS0gCPipYo3CFsf4d2U6DPO+8WEtHayPdLL6nLsF2lBoDDlTVnboY=) - s3: - bucket: ENC(qiCvK88VEfG/jiQV5q16VvdMW1Suru/f5cmfa53G+inOx1hDi+S+NUAXJCkZuTyq) - region: - static: ap-northeast-2 - stack: - auto: false diff --git a/backend/src/main/resources/application-test.yml b/backend/src/main/resources/application-test.yml deleted file mode 100644 index 561d319b..00000000 --- a/backend/src/main/resources/application-test.yml +++ /dev/null @@ -1,57 +0,0 @@ -spring: - security: - oauth2: - client: - # registration - registration: - # google oauth2 setting - google: - client-id: ENC(yOSSFYzdF6BFvb+VhuwrUUvnEwhdYJQhPAt7O+I9CP/fGWq0EjmEwnYXmz7Yu/QyS9kwLcV4TyTVvnikUI4PKr+eEk1AUVMKNayFLTnIKA8f4KnP82cNsbQKaM/DN2N7Taw0LJHl4CMP8+QBBRI0JA==) - client-secret: ENC(n093NQezyIRURhvV7DI/t5NrG5WL9f/ks4NkKhEew6X+GBEpCuzW4syxqsRYO3jkqYELcDNz2xPUz3X9Dzp3yW2WLLp8k0Hq5rGyyhTgl5I=) - scope: - - profile - - email - # github oauth2 setting - github: - client-id: ENC(avR1sIiT2FjiEV8Gfc9VsnDj64R1Z76CsfJUkbWraReGvQPXBo27UKP6Pm3rhs18EgqNtD7b2Xm5IwezPSkprA==) - client-secret: ENC(6h5LvXhqQHUPBD6JqnwzNRlFlfA0g4tjqgP0cPxOUUiVBYIylACHiBS++qICPA2pAzubXiXMDxXkwj7GRz6Dofsz2utfQ/YNrlVNsAOYhTE=) - datasource: - url: jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE - driver-class-name: org.h2.Driver - username: sa - password: - jpa: - database-platform: org.hibernate.dialect.H2Dialect - show-sql: true - properties: - hibernate: - format_sql: true - ddl-auto: create -jwt: - secret: ENC(1MBsToCDbYBEvJkfxlSkoBb30kG1MYPqYOcyUcKZOhnodcSkYMncHeTYNyKr0GfYocr9yI3G1cR6DJHykIZTpQ==) - -logging: - level: - com: - infp: - ciat: debug - amazonaws: - util: - EC2MetadataUtils: error - -#공공포탈 api service key, public url -nongsaro: - url: http://api.nongsaro.go.kr/service/garden/ - key: ENC(53HGLcuFthBpODy/ksdZzUFiyznV5LG4QhgoFUlZvtIMUEU1Mc7Pwtvqd+h8wDidfZmt+aQLx/jmrpM+u7ZUhg==) - -cloud: - aws: - credentials: - accessKey: ENC(qnoRD48Vb/ynF7VFZA8jn3sH8Pf8F3EMLCuHAwFA5yM+dtFiXPANaTQqO/pBxlM+IFp3yDJsVZYJ25EnB8xJVw==) - secretKey: ENC(vkgcPsB5+80n3xZIS5v3NDUP+zphtLKkOJtRU5Jne7dc3+hjp03xoKMS0gCPipYo3CFsf4d2U6DPO+8WEtHayPdLL6nLsF2lBoDDlTVnboY=) - s3: - bucket: ENC(qiCvK88VEfG/jiQV5q16VvdMW1Suru/f5cmfa53G+inOx1hDi+S+NUAXJCkZuTyq) - region: - static: ap-northeast-2 - stack: - auto: false diff --git a/backend/src/main/resources/application.yml b/backend/src/main/resources/application.yml deleted file mode 100644 index fe291736..00000000 --- a/backend/src/main/resources/application.yml +++ /dev/null @@ -1,69 +0,0 @@ -server: - port: 9400 - servlet: - session: - cookie: - http-only: false - secure: false -jwt: - secret: ENC(1MBsToCDbYBEvJkfxlSkoBb30kG1MYPqYOcyUcKZOhnodcSkYMncHeTYNyKr0GfYocr9yI3G1cR6DJHykIZTpQ==) - -logging: - level: - com: - infp: - ciat: debug - amazonaws: - util: - EC2MetadataUtils: error - -spring: - servlet: - multipart: - max-file-size: 2MB - max-request-size: 2MB - security: - oauth2: - client: - # registration - registration: - # google oauth2 setting - google: - client-id: ENC(yOSSFYzdF6BFvb+VhuwrUUvnEwhdYJQhPAt7O+I9CP/fGWq0EjmEwnYXmz7Yu/QyS9kwLcV4TyTVvnikUI4PKr+eEk1AUVMKNayFLTnIKA8f4KnP82cNsbQKaM/DN2N7Taw0LJHl4CMP8+QBBRI0JA==) - client-secret: ENC(n093NQezyIRURhvV7DI/t5NrG5WL9f/ks4NkKhEew6X+GBEpCuzW4syxqsRYO3jkqYELcDNz2xPUz3X9Dzp3yW2WLLp8k0Hq5rGyyhTgl5I=) - scope: - - profile - - email - # github oauth2 setting - github: - client-id: ENC(avR1sIiT2FjiEV8Gfc9VsnDj64R1Z76CsfJUkbWraReGvQPXBo27UKP6Pm3rhs18EgqNtD7b2Xm5IwezPSkprA==) - client-secret: ENC(6h5LvXhqQHUPBD6JqnwzNRlFlfA0g4tjqgP0cPxOUUiVBYIylACHiBS++qICPA2pAzubXiXMDxXkwj7GRz6Dofsz2utfQ/YNrlVNsAOYhTE=) - datasource: - url: ENC(SdMJj9dKGhkF+VFShqVQMGHlkmAhjmM0XPWIyA1Nm0FPqORrLWc9cEk29FF6ntVvLLGPdp8cS9F875BZ+hgkEQVZ0gwhz6wN3MlEvggPDp5NnuLWwqZ3KwVznInPehxqZEpa1dbAlFv/5Gmcl8uISQ==) - driver-class-name: ENC(dhW7Cm9yna7f1mV0Bex6qSMlA+AhOuZdUDU18VFe4YTvBz1Rev0UeU1rmcSHlA/wGwM+VqMMAKHs2R+j21LHOA==) - username: ENC(blW7MEaDg8iJTGp5PEETV5e1hIwlMxVZsn1eBI8iZ5/OxhY4dvZKIzb9fE4g0R7y) - password: ENC(u+eGNk3Cmyzf2ZbtQfKWBAmN3bWWVTUMiLK2FbCtp7Iya1hs0x2cs2DqQVtGH4dj0a+NjswWJO8nbBNz10hflg==) - jpa: - open-in-view: false - generate-ddl: true - show-sql: true - hibernate: - ddl-auto: update - database-platform: ENC(HUPevaLfmLDzFPVbGkeMOkOm3Y38mg6zxfNXUJsckzCwJEnVl6rhURSMQSf8lHh8WIBkBvmMNq2CVz0Uhu3fX1AjmQHIpcOOJHONm8X0eHA=) - -#공공포탈 api service key, public url -nongsaro: - url: http://api.nongsaro.go.kr/service/garden/ - key: ENC(53HGLcuFthBpODy/ksdZzUFiyznV5LG4QhgoFUlZvtIMUEU1Mc7Pwtvqd+h8wDidfZmt+aQLx/jmrpM+u7ZUhg==) - -cloud: - aws: - credentials: - accessKey: ENC(qnoRD48Vb/ynF7VFZA8jn3sH8Pf8F3EMLCuHAwFA5yM+dtFiXPANaTQqO/pBxlM+IFp3yDJsVZYJ25EnB8xJVw==) - secretKey: ENC(vkgcPsB5+80n3xZIS5v3NDUP+zphtLKkOJtRU5Jne7dc3+hjp03xoKMS0gCPipYo3CFsf4d2U6DPO+8WEtHayPdLL6nLsF2lBoDDlTVnboY=) - s3: - bucket: ENC(qiCvK88VEfG/jiQV5q16VvdMW1Suru/f5cmfa53G+inOx1hDi+S+NUAXJCkZuTyq) - region: - static: ap-northeast-2 - stack: - auto: false diff --git a/backend/src/test/java/com/infp/ciat/CiatApplicationTests.java b/backend/src/test/java/com/infp/ciat/CiatApplicationTests.java index a76c7aca..25d7f805 100644 --- a/backend/src/test/java/com/infp/ciat/CiatApplicationTests.java +++ b/backend/src/test/java/com/infp/ciat/CiatApplicationTests.java @@ -1,6 +1,5 @@ package com.infp.ciat; -import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; @@ -13,10 +12,4 @@ class CiatApplicationTests { void contextLoads() { } - @BeforeAll - public static void beforeAll() { - String jasypt_password = System.getenv("jasypt.encryptor.password"); - System.setProperty("jasypt.encryptor.password", jasypt_password); - } - } diff --git a/backend/src/test/java/com/infp/ciat/category/service/MenuServiceTest.java b/backend/src/test/java/com/infp/ciat/category/service/MenuServiceTest.java index 7476607a..e971d928 100644 --- a/backend/src/test/java/com/infp/ciat/category/service/MenuServiceTest.java +++ b/backend/src/test/java/com/infp/ciat/category/service/MenuServiceTest.java @@ -37,11 +37,11 @@ public class MenuServiceTest { @Autowired private MenuRepository menuRepository; - @BeforeAll - public static void beforeAll() { - String jasypt_password = System.getenv("jasypt.encryptor.password"); - System.setProperty("jasypt.encryptor.password", jasypt_password); - } +// @BeforeAll +// public static void beforeAll() { +// String jasypt_password = System.getenv("jasypt.encryptor.password"); +// System.setProperty("jasypt.encryptor.password", jasypt_password); +// } @BeforeEach void createAccount() { diff --git a/backend/src/test/java/com/infp/ciat/user/controller/AccountControllerTest.java b/backend/src/test/java/com/infp/ciat/user/controller/AccountControllerTest.java index f59ec721..f3f6a74f 100644 --- a/backend/src/test/java/com/infp/ciat/user/controller/AccountControllerTest.java +++ b/backend/src/test/java/com/infp/ciat/user/controller/AccountControllerTest.java @@ -55,12 +55,6 @@ public void setUp() { .build(); } - @BeforeAll - public static void beforeAll() { - String jasypt_password = System.getenv("jasypt.encryptor.password"); - System.setProperty("jasypt.encryptor.password", jasypt_password); - } - @Test // @WithMockUser(roles = "USER") public void signup() throws Exception { diff --git a/backend/src/test/java/com/infp/ciat/user/service/AccountServiceTest.java b/backend/src/test/java/com/infp/ciat/user/service/AccountServiceTest.java index 47a9d094..b2b288c9 100644 --- a/backend/src/test/java/com/infp/ciat/user/service/AccountServiceTest.java +++ b/backend/src/test/java/com/infp/ciat/user/service/AccountServiceTest.java @@ -30,11 +30,11 @@ class AccountServiceTest { @Autowired PasswordEncoder passwordEncoder; - @BeforeAll - public static void beforeAll() { - String jasypt_password = System.getenv("jasypt.encryptor.password"); - System.setProperty("jasypt.encryptor.password", jasypt_password); - } +// @BeforeAll +// public static void beforeAll() { +// String jasypt_password = System.getenv("jasypt.encryptor.password"); +// System.setProperty("jasypt.encryptor.password", jasypt_password); +// } @AfterEach public void aftereach() { From b022f0199c5d6b66a2882a957a6baa72efc7d2b8 Mon Sep 17 00:00:00 2001 From: choisungwook Date: Sat, 22 Jan 2022 00:59:15 +0900 Subject: [PATCH 02/38] =?UTF-8?q?=EC=8A=A4=ED=94=84=EB=A7=81=EB=B6=80?= =?UTF-8?q?=ED=8A=B8=20=ED=94=84=EB=A1=9C=ED=8C=8C=EC=9D=BC=20gitignore=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/.gitignore | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/.gitignore b/backend/.gitignore index c2065bc2..9b3d3c24 100644 --- a/backend/.gitignore +++ b/backend/.gitignore @@ -35,3 +35,9 @@ out/ ### VS Code ### .vscode/ + +# springboot profiles +application.yml +application-dev.yml +application-prd.yml +application-test.yml From dcfc2b7f8c48043e472178157c8e615447770dab Mon Sep 17 00:00:00 2001 From: choisungwook Date: Sat, 22 Jan 2022 13:05:17 +0900 Subject: [PATCH 03/38] test --- .github/workflows/backend-dev-unitest.yaml | 0 .github/workflows/backend-dev.yaml | 66 ++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 .github/workflows/backend-dev-unitest.yaml create mode 100644 .github/workflows/backend-dev.yaml diff --git a/.github/workflows/backend-dev-unitest.yaml b/.github/workflows/backend-dev-unitest.yaml new file mode 100644 index 00000000..e69de29b diff --git a/.github/workflows/backend-dev.yaml b/.github/workflows/backend-dev.yaml new file mode 100644 index 00000000..c761894f --- /dev/null +++ b/.github/workflows/backend-dev.yaml @@ -0,0 +1,66 @@ +name: backend-dev-deploy + +on: + push: + branches: + - "develop" + +jobs: + build: + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./backend + steps: + - uses: actions/checkout@v2 + with: + ssh-key: ${{ secrets.PRIVATEREPO_SSHKEY }} + submodules: 'recursive' + + - name: print + run: | + ls -l ./src/main/resources/CIAT_private/springboot + + - name: copy springboot profile + run: | + cp ./src/main/resources/CIAT_private/springboot/application-dev.yaml ./src/main/resources/application.yaml + + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + java-version: '11' + distribution: 'adopt' + server-id: github # Value of the distributionManagement/repository/id field of the pom.xml + settings-path: ${{ github.workspace }} # location for the settings.xml file + + - name: gradle build + run: | + gradle clean build --exclude-task test + + # - name: Discord Alert Success + # uses: sarisia/actions-status-discord@v1 + # if: success() + # with: + # webhook: ${{ secrets.DISCORD_WEBHOOK }} + # description: "🎉 테스트 되었습니다!" + + # - name: Discord Alert Failure + # uses: sarisia/actions-status-discord@v1 + # if: failure() + # with: + # webhook: ${{ secrets.DISCORD_WEBHOOK }} + # description: "🔥 테스트를 실패하였습니다." + + # - name: Publish Unit Test Results + # uses: EnricoMi/publish-unit-test-result-action@v1 + # if: ${{ always() }} + # with: + # files: build/test-results/*/.xml + + - name: Cleanup Gradle Cache + # Remove some files from the Gradle cache, so they aren't cached by GitHub Actions. + # Restoring these files from a GitHub Actions cache might cause problems for future builds. + if: ${{ always() }} + run: | + rm -f ~/.gradle/caches/modules-2/modules-2.lock + rm -f ~/.gradle/caches/modules-2/gc.properties \ No newline at end of file From 9c251d5ca8b229a3645cfe139a0fcee2c07338e2 Mon Sep 17 00:00:00 2001 From: choisungwook Date: Sat, 22 Jan 2022 13:19:24 +0900 Subject: [PATCH 04/38] =?UTF-8?q?=EB=B0=B1=EC=97=94=EB=93=9C=20Readme=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/Readme.md | 80 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 backend/Readme.md diff --git a/backend/Readme.md b/backend/Readme.md new file mode 100644 index 00000000..847198f6 --- /dev/null +++ b/backend/Readme.md @@ -0,0 +1,80 @@ +# 실행 준비 +* 이 프로젝트에서 연동된 데이터베이스정보 등 등록이 필요합니다. +* CIAT repo에 등록된 멤버는 git submodule에 접근정보를 얻을 수 있습니다. +```sh +git submodule update --recursive --remote --merge --force +``` +## 스프링부트 프로파일 템플릿 +* 이 템플릿은 외부사용자를 위한 설명입니다. +```yaml +server: + port: 9400 + servlet: + session: + cookie: + http-only: false + secure: false +jwt: + secret: + +logging: + level: + com: + infp: + ciat: debug + amazonaws: + util: + EC2MetadataUtils: error + +spring: + servlet: + multipart: + max-file-size: 2MB + max-request-size: 2MB + security: + oauth2: + client: + registration: + google: + client-id: + client-secret: + scope: + - profile + - email + datasource: + url: + driver-class-name: org.mariadb.jdbc.Driver + username: <계정> + password: <비밀번호> + jpa: + open-in-view: false + generate-ddl: true + show-sql: true + hibernate: + ddl-auto: update + database-platform: org.hibernate.dialect.MariaDB103Dialect + +#공공포탈 api service key, public url +nongsaro: + url: <공공포탈> + key: <공공포털 access key> + +cloud: + aws: + credentials: + accessKey: + secretKey: + s3: + bucket: + region: + static: + stack: + auto: false +``` + +# 실행 +* JVM 실행인자 설정 +```sh +# aaws sdk 설정: ec2메타데이터 비활성화 +-Dcom.amazonaws.sdk.disableEc2Metadata=true +``` From 9d2f804d2f9090ee1a359d7a346bb6550fea55bf Mon Sep 17 00:00:00 2001 From: choisungwook Date: Sun, 23 Jan 2022 15:19:22 +0900 Subject: [PATCH 05/38] =?UTF-8?q?submodule=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitmodules | 3 +++ backend/src/main/resources/CIAT_private | 1 + 2 files changed, 4 insertions(+) create mode 100644 .gitmodules create mode 160000 backend/src/main/resources/CIAT_private diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..6dff6688 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "backend/src/main/resources/CIAT_private"] + path = backend/src/main/resources/CIAT_private + url = https://github.com/INFP-Study/CIAT_private diff --git a/backend/src/main/resources/CIAT_private b/backend/src/main/resources/CIAT_private new file mode 160000 index 00000000..f7f7633b --- /dev/null +++ b/backend/src/main/resources/CIAT_private @@ -0,0 +1 @@ +Subproject commit f7f7633bbb16f9406c9a0b7b04b9247af12b1fb4 From 619a5ff2d741797f81fe5f2235947873241a7507 Mon Sep 17 00:00:00 2001 From: choisungwook Date: Sun, 23 Jan 2022 15:24:49 +0900 Subject: [PATCH 06/38] =?UTF-8?q?githubaction=20=EB=B9=8C=EB=93=9C?= =?UTF-8?q?=EB=B0=B0=ED=8F=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/backend-dev-unitest.yaml | 62 +++++++++++ .github/workflows/backend-dev.yaml | 101 +++++++++++++----- .github/workflows/gradle_test.yaml | 98 ++++++++--------- .../cicd/dev/charts/templates/deployment.yaml | 2 +- backend/cicd/dev/charts/values.yaml | 14 ++- 5 files changed, 191 insertions(+), 86 deletions(-) diff --git a/.github/workflows/backend-dev-unitest.yaml b/.github/workflows/backend-dev-unitest.yaml index e69de29b..b3c23c09 100644 --- a/.github/workflows/backend-dev-unitest.yaml +++ b/.github/workflows/backend-dev-unitest.yaml @@ -0,0 +1,62 @@ +name: backend-dev-junittest + +on: + push: + branches: + - "develop" + +jobs: + build: + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./backend + steps: + - uses: actions/checkout@v2 + with: + ssh-key: ${{ secrets.PRIVATEREPO_SSHKEY }} + submodules: 'recursive' + + - name: copy springboot profile + run: | + cp ./src/main/resources/CIAT_private/springboot/application-test.yaml ./src/main/resources/application.yaml + + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + java-version: '11' + distribution: 'adopt' + server-id: github # Value of the distributionManagement/repository/id field of the pom.xml + settings-path: ${{ github.workspace }} # location for the settings.xml file + + - name: gradle build + run: | + gradle clean build --exclude-task test + + # - name: Discord Alert Success + # uses: sarisia/actions-status-discord@v1 + # if: success() + # with: + # webhook: ${{ secrets.DISCORD_WEBHOOK }} + # description: "🎉 테스트 되었습니다!" + + # - name: Discord Alert Failure + # uses: sarisia/actions-status-discord@v1 + # if: failure() + # with: + # webhook: ${{ secrets.DISCORD_WEBHOOK }} + # description: "🔥 테스트를 실패하였습니다." + + - name: Publish Unit Test Results + uses: EnricoMi/publish-unit-test-result-action@v1 + if: ${{ always() }} + with: + files: build/test-results/*/.xml + + - name: Cleanup Gradle Cache + # Remove some files from the Gradle cache, so they aren't cached by GitHub Actions. + # Restoring these files from a GitHub Actions cache might cause problems for future builds. + if: ${{ always() }} + run: | + rm -f ~/.gradle/caches/modules-2/modules-2.lock + rm -f ~/.gradle/caches/modules-2/gc.properties \ No newline at end of file diff --git a/.github/workflows/backend-dev.yaml b/.github/workflows/backend-dev.yaml index c761894f..2b01a088 100644 --- a/.github/workflows/backend-dev.yaml +++ b/.github/workflows/backend-dev.yaml @@ -1,61 +1,105 @@ -name: backend-dev-deploy +name: backend-dev-CICD on: push: branches: - "develop" + paths-ignore: + - "backend/cicd/dev/charts/override_values.yaml" jobs: build: runs-on: ubuntu-latest + defaults: run: working-directory: ./backend + + env: + dockerimage_tag: ${{ github.sha }} + dockerimage_name: choisunguk/siat-dev-backend:${{ github.sha }} + + # 1. git submodule을 이용해서 스프링부트 프로파일 복사 + # 2. 스프링부트 프로젝트 빌드 + # 3. docker build + # 4. docker push steps: - uses: actions/checkout@v2 with: - ssh-key: ${{ secrets.PRIVATEREPO_SSHKEY }} + ssh-key: ${{ secrets.GITHUBACTION_KEY }} submodules: 'recursive' - - - name: print - run: | - ls -l ./src/main/resources/CIAT_private/springboot - name: copy springboot profile run: | - cp ./src/main/resources/CIAT_private/springboot/application-dev.yaml ./src/main/resources/application.yaml + cp ./src/main/resources/CIAT_private/springboot/application-dev.yaml ./src/main/resources/application-dev.yaml - name: Set up JDK 11 uses: actions/setup-java@v2 with: java-version: '11' distribution: 'adopt' - server-id: github # Value of the distributionManagement/repository/id field of the pom.xml - settings-path: ${{ github.workspace }} # location for the settings.xml file - + server-id: github + settings-path: ${{ github.workspace }} + - name: gradle build run: | gradle clean build --exclude-task test - # - name: Discord Alert Success - # uses: sarisia/actions-status-discord@v1 - # if: success() - # with: - # webhook: ${{ secrets.DISCORD_WEBHOOK }} - # description: "🎉 테스트 되었습니다!" + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 - # - name: Discord Alert Failure - # uses: sarisia/actions-status-discord@v1 - # if: failure() - # with: - # webhook: ${{ secrets.DISCORD_WEBHOOK }} - # description: "🔥 테스트를 실패하였습니다." + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: copy dockerfile + run: | + rm -rf ./Dockerfile + cp ./cicd/dev/Dockerfile ./Dockerfile + + - name: Build and push + id: docker_build + run: | + docker build -t ${{ env.dockerimage_name }} . + docker push ${{ env.dockerimage_name }} - # - name: Publish Unit Test Results - # uses: EnricoMi/publish-unit-test-result-action@v1 - # if: ${{ always() }} - # with: - # files: build/test-results/*/.xml + - name: change override_values.yaml + run: | + cat < ./cicd/dev/charts/override_values.yaml + image: + tag: ${{ env.dockerimage_tag }} + EOF + + - name: git push + run: | + git config --global user.email "GitHub Actions Bot@github.com" + git config --global user.name "GitHub Actions Bot" + git add ./cicd/dev/charts/override_values.yaml + git commit -m "change dockertag" + git push origin develop + + + - name: Discord Alert Success + uses: sarisia/actions-status-discord@v1 + if: success() + with: + webhook: ${{ secrets.DISCORD_WEBHOOK }} + description: "🎉 테스트 되었습니다!" + + - name: Discord Alert Failure + uses: sarisia/actions-status-discord@v1 + if: failure() + with: + webhook: ${{ secrets.DISCORD_WEBHOOK }} + description: "🔥 테스트를 실패하였습니다." + + - name: Publish Unit Test Results + uses: EnricoMi/publish-unit-test-result-action@v1 + if: ${{ always() }} + with: + files: build/test-results/*/.xml - name: Cleanup Gradle Cache # Remove some files from the Gradle cache, so they aren't cached by GitHub Actions. @@ -63,4 +107,5 @@ jobs: if: ${{ always() }} run: | rm -f ~/.gradle/caches/modules-2/modules-2.lock - rm -f ~/.gradle/caches/modules-2/gc.properties \ No newline at end of file + rm -f ~/.gradle/caches/modules-2/gc.properties + \ No newline at end of file diff --git a/.github/workflows/gradle_test.yaml b/.github/workflows/gradle_test.yaml index dee9e5f8..5eec9d50 100644 --- a/.github/workflows/gradle_test.yaml +++ b/.github/workflows/gradle_test.yaml @@ -1,56 +1,56 @@ -name: Test +# name: Test -on: - pull_request: - branches: - - "master" +# on: +# pull_request: +# branches: +# - "master" -jobs: - build: - runs-on: ubuntu-latest - defaults: - run: - working-directory: ./backend - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v2 - with: - java-version: '11' - distribution: 'adopt' - server-id: github # Value of the distributionManagement/repository/id field of the pom.xml - settings-path: ${{ github.workspace }} # location for the settings.xml file +# jobs: +# build: +# runs-on: ubuntu-latest +# defaults: +# run: +# working-directory: ./backend +# steps: +# - uses: actions/checkout@v2 +# - name: Set up JDK 11 +# uses: actions/setup-java@v2 +# with: +# java-version: '11' +# distribution: 'adopt' +# server-id: github # Value of the distributionManagement/repository/id field of the pom.xml +# settings-path: ${{ github.workspace }} # location for the settings.xml file - - name: gradle test - run: | - export jasypt_password=${{ secrets.JASYPT_PASSWORD }} - gradle clean test +# - name: gradle test +# run: | +# export jasypt_password=${{ secrets.JASYPT_PASSWORD }} +# gradle clean test - - name: Discord Alert Success - uses: sarisia/actions-status-discord@v1 - if: success() - with: - webhook: ${{ secrets.DISCORD_WEBHOOK }} - description: "🎉 테스트 되었습니다!" +# - name: Discord Alert Success +# uses: sarisia/actions-status-discord@v1 +# if: success() +# with: +# webhook: ${{ secrets.DISCORD_WEBHOOK }} +# description: "🎉 테스트 되었습니다!" - - name: Discord Alert Failure - uses: sarisia/actions-status-discord@v1 - if: failure() - with: - webhook: ${{ secrets.DISCORD_WEBHOOK }} - description: "🔥 테스트를 실패하였습니다." +# - name: Discord Alert Failure +# uses: sarisia/actions-status-discord@v1 +# if: failure() +# with: +# webhook: ${{ secrets.DISCORD_WEBHOOK }} +# description: "🔥 테스트를 실패하였습니다." - - name: Publish Unit Test Results - uses: EnricoMi/publish-unit-test-result-action@v1 - if: ${{ always() }} - with: - files: build/test-results/*/.xml +# - name: Publish Unit Test Results +# uses: EnricoMi/publish-unit-test-result-action@v1 +# if: ${{ always() }} +# with: +# files: build/test-results/*/.xml - # 추가 - - name: Cleanup Gradle Cache - # Remove some files from the Gradle cache, so they aren't cached by GitHub Actions. - # Restoring these files from a GitHub Actions cache might cause problems for future builds. - if: ${{ always() }} - run: | - rm -f ~/.gradle/caches/modules-2/modules-2.lock - rm -f ~/.gradle/caches/modules-2/gc.properties \ No newline at end of file +# # 추가 +# - name: Cleanup Gradle Cache +# # Remove some files from the Gradle cache, so they aren't cached by GitHub Actions. +# # Restoring these files from a GitHub Actions cache might cause problems for future builds. +# if: ${{ always() }} +# run: | +# rm -f ~/.gradle/caches/modules-2/modules-2.lock +# rm -f ~/.gradle/caches/modules-2/gc.properties \ No newline at end of file diff --git a/backend/cicd/dev/charts/templates/deployment.yaml b/backend/cicd/dev/charts/templates/deployment.yaml index 311ecfb2..53f77f37 100644 --- a/backend/cicd/dev/charts/templates/deployment.yaml +++ b/backend/cicd/dev/charts/templates/deployment.yaml @@ -39,7 +39,7 @@ spec: protocol: TCP env: - name: JAVA_OPTS - value: -Djasypt.encryptor.password={{ .Values.application.secret.jasypt }} -Dspring.profiles.active={{ .Values.application.mode }} -Dcom.amazonaws.sdk.disableEc2Metadata=true + value: -Dspring.profiles.active={{ .Values.application.mode }} -Dcom.amazonaws.sdk.disableEc2Metadata=true livenessProbe: httpGet: path: /healthcheck diff --git a/backend/cicd/dev/charts/values.yaml b/backend/cicd/dev/charts/values.yaml index 18f37cfb..56c86d92 100644 --- a/backend/cicd/dev/charts/values.yaml +++ b/backend/cicd/dev/charts/values.yaml @@ -1,9 +1,9 @@ replicaCount: 1 image: - repository: __IMAGENAME__ + repository: choisunguk/siat-dev-backend pullPolicy: IfNotPresent - tag: __TAGNAME__ + tag: __TAG__ imagePullSecrets: [] nameOverride: "" @@ -31,14 +31,14 @@ ingress: cert-manager.io/cluster-issuer: "letencrypt-prod" certmanager.k8s.io/acme-challenge-type: dns01 hosts: - - host: __HOST1__ + - host: ciat-dev.choicloudlab.com paths: - path: /api/v1 pathType: Prefix tls: - - secretName: __TLS__SECRETNAME__ + - secretName: ciat-dev hosts: - - __HOST1__ + - ciat-dev.choicloudlab.com resources: limits: @@ -61,7 +61,5 @@ tolerations: [] affinity: {} -application: - secret: - jasypt: __JASYPT__ +application: mode: __MODE__ From 74affefa08dfaf714baa22bb8961397a5fe4aa67 Mon Sep 17 00:00:00 2001 From: GitHub Actions Bot Date: Sun, 23 Jan 2022 06:57:31 +0000 Subject: [PATCH 07/38] change dockertag --- backend/cicd/dev/charts/override_values.yaml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 backend/cicd/dev/charts/override_values.yaml diff --git a/backend/cicd/dev/charts/override_values.yaml b/backend/cicd/dev/charts/override_values.yaml new file mode 100644 index 00000000..49575ada --- /dev/null +++ b/backend/cicd/dev/charts/override_values.yaml @@ -0,0 +1,2 @@ +image: + tag: 55b02ae6d849b1546c565488f7e4e4f26ff5a47b From d8720897263ba95e527433d87dc0988bb8c0895b Mon Sep 17 00:00:00 2001 From: choisungwook Date: Sun, 23 Jan 2022 15:59:12 +0900 Subject: [PATCH 08/38] =?UTF-8?q?submodule=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitmodules | 3 --- backend/src/main/resources/CIAT_private | 1 - 2 files changed, 4 deletions(-) delete mode 100644 .gitmodules delete mode 160000 backend/src/main/resources/CIAT_private diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 6dff6688..00000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "backend/src/main/resources/CIAT_private"] - path = backend/src/main/resources/CIAT_private - url = https://github.com/INFP-Study/CIAT_private diff --git a/backend/src/main/resources/CIAT_private b/backend/src/main/resources/CIAT_private deleted file mode 160000 index f7f7633b..00000000 --- a/backend/src/main/resources/CIAT_private +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f7f7633bbb16f9406c9a0b7b04b9247af12b1fb4 From d9b222651a8c99d6fe29478129a1871aaab157be Mon Sep 17 00:00:00 2001 From: choisungwook Date: Sun, 23 Jan 2022 16:03:12 +0900 Subject: [PATCH 09/38] =?UTF-8?q?submodule=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitmodules | 3 +++ backend/src/main/resources/CIAT_private | 1 + 2 files changed, 4 insertions(+) create mode 100644 .gitmodules create mode 160000 backend/src/main/resources/CIAT_private diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..4d5152cb --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "backend/src/main/resources/CIAT_private"] + path = backend/src/main/resources/CIAT_private + url = git@github.com:INFP-Study/CIAT_private.git diff --git a/backend/src/main/resources/CIAT_private b/backend/src/main/resources/CIAT_private new file mode 160000 index 00000000..f7f7633b --- /dev/null +++ b/backend/src/main/resources/CIAT_private @@ -0,0 +1 @@ +Subproject commit f7f7633bbb16f9406c9a0b7b04b9247af12b1fb4 From bef241c56d27a619c392c60b6ff4465cb93086fd Mon Sep 17 00:00:00 2001 From: choisungwook Date: Sun, 23 Jan 2022 16:04:45 +0900 Subject: [PATCH 10/38] =?UTF-8?q?workflow=20=EC=8B=A4=ED=96=89=EC=A1=B0?= =?UTF-8?q?=EA=B1=B4=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/backend-dev-unitest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/backend-dev-unitest.yaml b/.github/workflows/backend-dev-unitest.yaml index b3c23c09..43cd5449 100644 --- a/.github/workflows/backend-dev-unitest.yaml +++ b/.github/workflows/backend-dev-unitest.yaml @@ -1,7 +1,7 @@ name: backend-dev-junittest on: - push: + pull_request: branches: - "develop" From 0b30e7597d0e5e616d9a1083f721f41bfddcc4bf Mon Sep 17 00:00:00 2001 From: GitHub Actions Bot Date: Sun, 23 Jan 2022 07:05:29 +0000 Subject: [PATCH 11/38] change dockertag --- backend/cicd/dev/charts/override_values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/cicd/dev/charts/override_values.yaml b/backend/cicd/dev/charts/override_values.yaml index 49575ada..db232459 100644 --- a/backend/cicd/dev/charts/override_values.yaml +++ b/backend/cicd/dev/charts/override_values.yaml @@ -1,2 +1,2 @@ image: - tag: 55b02ae6d849b1546c565488f7e4e4f26ff5a47b + tag: b3706b5027f10ff5e4625b4c04b10a64e44261b5 From 17dca65c2ca6cb7eeb7336ab63aafb3bd383b057 Mon Sep 17 00:00:00 2001 From: choisungwook Date: Sun, 23 Jan 2022 16:05:44 +0900 Subject: [PATCH 12/38] =?UTF-8?q?gradle=20=EB=AA=85=EB=A0=B9=EC=96=B4=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/backend-dev-unitest.yaml | 32 +++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/backend-dev-unitest.yaml b/.github/workflows/backend-dev-unitest.yaml index 43cd5449..ca786858 100644 --- a/.github/workflows/backend-dev-unitest.yaml +++ b/.github/workflows/backend-dev-unitest.yaml @@ -29,23 +29,23 @@ jobs: server-id: github # Value of the distributionManagement/repository/id field of the pom.xml settings-path: ${{ github.workspace }} # location for the settings.xml file - - name: gradle build + - name: test run: | - gradle clean build --exclude-task test - - # - name: Discord Alert Success - # uses: sarisia/actions-status-discord@v1 - # if: success() - # with: - # webhook: ${{ secrets.DISCORD_WEBHOOK }} - # description: "🎉 테스트 되었습니다!" - - # - name: Discord Alert Failure - # uses: sarisia/actions-status-discord@v1 - # if: failure() - # with: - # webhook: ${{ secrets.DISCORD_WEBHOOK }} - # description: "🔥 테스트를 실패하였습니다." + gradle test + + - name: Discord Alert Success + uses: sarisia/actions-status-discord@v1 + if: success() + with: + webhook: ${{ secrets.DISCORD_WEBHOOK }} + description: "🎉 테스트 되었습니다!" + + - name: Discord Alert Failure + uses: sarisia/actions-status-discord@v1 + if: failure() + with: + webhook: ${{ secrets.DISCORD_WEBHOOK }} + description: "🔥 테스트를 실패하였습니다." - name: Publish Unit Test Results uses: EnricoMi/publish-unit-test-result-action@v1 From 0ace8c4cf3463263169dd22af1009638d7af0ed7 Mon Sep 17 00:00:00 2001 From: GitHub Actions Bot Date: Sun, 23 Jan 2022 07:09:35 +0000 Subject: [PATCH 13/38] change dockertag --- backend/cicd/dev/charts/override_values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/cicd/dev/charts/override_values.yaml b/backend/cicd/dev/charts/override_values.yaml index db232459..e6df2d51 100644 --- a/backend/cicd/dev/charts/override_values.yaml +++ b/backend/cicd/dev/charts/override_values.yaml @@ -1,2 +1,2 @@ image: - tag: b3706b5027f10ff5e4625b4c04b10a64e44261b5 + tag: 84b4b0c9c3e2081dfb921df5ffef7e31c55e31ba From 3da105c6e13abadc8ff74558250f61a983a8d1f4 Mon Sep 17 00:00:00 2001 From: choisungwook Date: Sun, 23 Jan 2022 16:11:45 +0900 Subject: [PATCH 14/38] =?UTF-8?q?helm=20values=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/cicd/dev/charts/values.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/cicd/dev/charts/values.yaml b/backend/cicd/dev/charts/values.yaml index 56c86d92..8b6be2ef 100644 --- a/backend/cicd/dev/charts/values.yaml +++ b/backend/cicd/dev/charts/values.yaml @@ -3,7 +3,7 @@ replicaCount: 1 image: repository: choisunguk/siat-dev-backend pullPolicy: IfNotPresent - tag: __TAG__ + tag: "" imagePullSecrets: [] nameOverride: "" @@ -62,4 +62,4 @@ tolerations: [] affinity: {} application: - mode: __MODE__ + mode: dev From 6296b06b0c04368ace647c5a9757550941c976f4 Mon Sep 17 00:00:00 2001 From: choisungwook Date: Sun, 23 Jan 2022 16:13:40 +0900 Subject: [PATCH 15/38] =?UTF-8?q?job=EC=9D=B4=EB=A6=84=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/backend-dev-unitest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/backend-dev-unitest.yaml b/.github/workflows/backend-dev-unitest.yaml index ca786858..65c2558e 100644 --- a/.github/workflows/backend-dev-unitest.yaml +++ b/.github/workflows/backend-dev-unitest.yaml @@ -6,7 +6,7 @@ on: - "develop" jobs: - build: + test: runs-on: ubuntu-latest defaults: run: From d82b0eb6828a060793693fd74a9a90ddae572b8e Mon Sep 17 00:00:00 2001 From: GitHub Actions Bot Date: Sun, 23 Jan 2022 07:26:32 +0000 Subject: [PATCH 16/38] change dockertag --- backend/cicd/dev/charts/override_values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/cicd/dev/charts/override_values.yaml b/backend/cicd/dev/charts/override_values.yaml index e6df2d51..f777c8c0 100644 --- a/backend/cicd/dev/charts/override_values.yaml +++ b/backend/cicd/dev/charts/override_values.yaml @@ -1,2 +1,2 @@ image: - tag: 84b4b0c9c3e2081dfb921df5ffef7e31c55e31ba + tag: 7aba5a6c78d30d779551e567eecec7b550a35006 From bf7ecfeade92696e131ae4a9adf98a69b40b1bc0 Mon Sep 17 00:00:00 2001 From: choisungwook Date: Sun, 23 Jan 2022 16:27:52 +0900 Subject: [PATCH 17/38] =?UTF-8?q?gitmodule=20=EC=B4=88=EA=B8=B0=ED=99=94:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitmodules | 3 --- backend/src/main/resources/CIAT_private | 1 - 2 files changed, 4 deletions(-) delete mode 100644 .gitmodules delete mode 160000 backend/src/main/resources/CIAT_private diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 4d5152cb..00000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "backend/src/main/resources/CIAT_private"] - path = backend/src/main/resources/CIAT_private - url = git@github.com:INFP-Study/CIAT_private.git diff --git a/backend/src/main/resources/CIAT_private b/backend/src/main/resources/CIAT_private deleted file mode 160000 index f7f7633b..00000000 --- a/backend/src/main/resources/CIAT_private +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f7f7633bbb16f9406c9a0b7b04b9247af12b1fb4 From 3fa2de1eb06303035645556598b180b5768c02bd Mon Sep 17 00:00:00 2001 From: choisungwook Date: Sun, 23 Jan 2022 16:32:22 +0900 Subject: [PATCH 18/38] git submodule --- .gitmodules | 3 +++ backend/src/main/resources/CIAT_private | 1 + 2 files changed, 4 insertions(+) create mode 100644 .gitmodules create mode 160000 backend/src/main/resources/CIAT_private diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..29ad5681 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "CIAT_private"] + path = backend/src/main/resources/CIAT_private + url = git@github.com:INFP-Study/CIAT_private.git diff --git a/backend/src/main/resources/CIAT_private b/backend/src/main/resources/CIAT_private new file mode 160000 index 00000000..f7f7633b --- /dev/null +++ b/backend/src/main/resources/CIAT_private @@ -0,0 +1 @@ +Subproject commit f7f7633bbb16f9406c9a0b7b04b9247af12b1fb4 From 32fb621327f23faaaeb1e3fdb4dd48a418d80de1 Mon Sep 17 00:00:00 2001 From: choisungwook Date: Sun, 23 Jan 2022 16:40:05 +0900 Subject: [PATCH 19/38] =?UTF-8?q?liveness=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/cicd/dev/charts/templates/deployment.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/backend/cicd/dev/charts/templates/deployment.yaml b/backend/cicd/dev/charts/templates/deployment.yaml index 53f77f37..4aafed41 100644 --- a/backend/cicd/dev/charts/templates/deployment.yaml +++ b/backend/cicd/dev/charts/templates/deployment.yaml @@ -40,12 +40,12 @@ spec: env: - name: JAVA_OPTS value: -Dspring.profiles.active={{ .Values.application.mode }} -Dcom.amazonaws.sdk.disableEc2Metadata=true - livenessProbe: - httpGet: - path: /healthcheck - port: http - initialDelaySeconds: 60 - periodSeconds: 60 + # livenessProbe: + # httpGet: + # path: /healthcheck + # port: http + # initialDelaySeconds: 60 + # periodSeconds: 60 readinessProbe: httpGet: path: /healthcheck From 622e7dc1e67bf8a20b2f41553a56495c51626c44 Mon Sep 17 00:00:00 2001 From: GitHub Actions Bot Date: Sun, 23 Jan 2022 08:28:30 +0000 Subject: [PATCH 20/38] change dockertag --- backend/cicd/dev/charts/override_values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/cicd/dev/charts/override_values.yaml b/backend/cicd/dev/charts/override_values.yaml index f777c8c0..a65e698c 100644 --- a/backend/cicd/dev/charts/override_values.yaml +++ b/backend/cicd/dev/charts/override_values.yaml @@ -1,2 +1,2 @@ image: - tag: 7aba5a6c78d30d779551e567eecec7b550a35006 + tag: 1ce6d0560a4b063b2f8d42dd9baf67c2a20bd45e From 755d55da9c3fc93186ff4b361b86576ee9ae07c1 Mon Sep 17 00:00:00 2001 From: choisungwook Date: Sun, 23 Jan 2022 17:34:30 +0900 Subject: [PATCH 21/38] =?UTF-8?q?=EB=B0=B1=EC=97=94=EB=93=9C=20prd=20cicd?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/backend-prd.yaml | 110 ++++++++++++++++++ backend/cicd/prd/Dockerfile | 4 + backend/cicd/prd/charts/.helmignore | 23 ++++ backend/cicd/prd/charts/Chart.yaml | 6 + backend/cicd/prd/charts/templates/NOTES.txt | 22 ++++ .../cicd/prd/charts/templates/_helpers.tpl | 62 ++++++++++ .../cicd/prd/charts/templates/deployment.yaml | 68 +++++++++++ backend/cicd/prd/charts/templates/hpa.yaml | 28 +++++ .../cicd/prd/charts/templates/ingress.yaml | 56 +++++++++ .../cicd/prd/charts/templates/service.yaml | 18 +++ .../prd/charts/templates/serviceaccount.yaml | 12 ++ .../templates/tests/test-connection.yaml | 15 +++ backend/cicd/prd/charts/values.yaml | 65 +++++++++++ backend/cicd/prd/override_values.yaml | 0 14 files changed, 489 insertions(+) create mode 100644 .github/workflows/backend-prd.yaml create mode 100644 backend/cicd/prd/Dockerfile create mode 100644 backend/cicd/prd/charts/.helmignore create mode 100644 backend/cicd/prd/charts/Chart.yaml create mode 100644 backend/cicd/prd/charts/templates/NOTES.txt create mode 100644 backend/cicd/prd/charts/templates/_helpers.tpl create mode 100644 backend/cicd/prd/charts/templates/deployment.yaml create mode 100644 backend/cicd/prd/charts/templates/hpa.yaml create mode 100644 backend/cicd/prd/charts/templates/ingress.yaml create mode 100644 backend/cicd/prd/charts/templates/service.yaml create mode 100644 backend/cicd/prd/charts/templates/serviceaccount.yaml create mode 100644 backend/cicd/prd/charts/templates/tests/test-connection.yaml create mode 100644 backend/cicd/prd/charts/values.yaml create mode 100644 backend/cicd/prd/override_values.yaml diff --git a/.github/workflows/backend-prd.yaml b/.github/workflows/backend-prd.yaml new file mode 100644 index 00000000..31ebe3b0 --- /dev/null +++ b/.github/workflows/backend-prd.yaml @@ -0,0 +1,110 @@ +name: backend-prd-CICD + +on: + push: + branches: + - "production" + paths-ignore: + - "backend/cicd/prd/charts/override_values.yaml" + +jobs: + build: + runs-on: ubuntu-latest + + defaults: + run: + working-directory: ./backend + + env: + dockerimage_tag: ${{ github.sha }} + dockerimage_name: choisunguk/ciat-prd-backend:${{ github.sha }} + + # 1. git submodule을 이용해서 스프링부트 프로파일 복사 + # 2. 스프링부트 프로젝트 빌드 + # 3. docker build + # 4. docker push + steps: + - uses: actions/checkout@v2 + with: + ssh-key: ${{ secrets.GITHUBACTION_KEY }} + submodules: 'recursive' + + - name: copy springboot profile + run: | + cp ./src/main/resources/CIAT_private/springboot/application-prd.yaml ./src/main/resources/application-prd.yaml + + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + java-version: '11' + distribution: 'adopt' + server-id: github + settings-path: ${{ github.workspace }} + + - name: gradle build + run: | + gradle clean build --exclude-task test + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: copy dockerfile + run: | + rm -rf ./Dockerfile + cp ./cicd/dev/Dockerfile ./Dockerfile + + - name: Build and push + id: docker_build + run: | + docker build -t ${{ env.dockerimage_name }} . + docker push ${{ env.dockerimage_name }} + + - name: change override_values.yaml + run: | + cat < ./cicd/dev/charts/override_values.yaml + image: + tag: ${{ env.dockerimage_tag }} + EOF + + - name: git push + run: | + git config --global user.email "GitHub Actions Bot@github.com" + git config --global user.name "GitHub Actions Bot" + git add ./cicd/dev/charts/override_values.yaml + git commit -m "change dockertag" + git push origin production + + # - name: Discord Alert Success + # uses: sarisia/actions-status-discord@v1 + # if: success() + # with: + # webhook: ${{ secrets.DISCORD_WEBHOOK }} + # description: "🎉 테스트 되었습니다!" + + # - name: Discord Alert Failure + # uses: sarisia/actions-status-discord@v1 + # if: failure() + # with: + # webhook: ${{ secrets.DISCORD_WEBHOOK }} + # description: "🔥 테스트를 실패하였습니다." + + - name: Publish Unit Test Results + uses: EnricoMi/publish-unit-test-result-action@v1 + if: ${{ always() }} + with: + files: build/test-results/*/.xml + + - name: Cleanup Gradle Cache + # Remove some files from the Gradle cache, so they aren't cached by GitHub Actions. + # Restoring these files from a GitHub Actions cache might cause problems for future builds. + if: ${{ always() }} + run: | + rm -f ~/.gradle/caches/modules-2/modules-2.lock + rm -f ~/.gradle/caches/modules-2/gc.properties + \ No newline at end of file diff --git a/backend/cicd/prd/Dockerfile b/backend/cicd/prd/Dockerfile new file mode 100644 index 00000000..e75e92f8 --- /dev/null +++ b/backend/cicd/prd/Dockerfile @@ -0,0 +1,4 @@ +FROM adoptopenjdk/openjdk11:ubi +ARG JAR_FILE=build/libs/*-SNAPSHOT.jar +COPY ${JAR_FILE} app.jar +ENTRYPOINT ["sh", "-c", "java ${JAVA_OPTS} -jar /app.jar"] \ No newline at end of file diff --git a/backend/cicd/prd/charts/.helmignore b/backend/cicd/prd/charts/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/backend/cicd/prd/charts/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/backend/cicd/prd/charts/Chart.yaml b/backend/cicd/prd/charts/Chart.yaml new file mode 100644 index 00000000..36428106 --- /dev/null +++ b/backend/cicd/prd/charts/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: release +description: ciat prd backend +type: application +version: 0.1.0 +appVersion: "0.1.0" diff --git a/backend/cicd/prd/charts/templates/NOTES.txt b/backend/cicd/prd/charts/templates/NOTES.txt new file mode 100644 index 00000000..97dd3a9b --- /dev/null +++ b/backend/cicd/prd/charts/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "charts.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "charts.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "charts.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "charts.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/backend/cicd/prd/charts/templates/_helpers.tpl b/backend/cicd/prd/charts/templates/_helpers.tpl new file mode 100644 index 00000000..68f9e0e2 --- /dev/null +++ b/backend/cicd/prd/charts/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "charts.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "charts.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "charts.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "charts.labels" -}} +helm.sh/chart: {{ include "charts.chart" . }} +{{ include "charts.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "charts.selectorLabels" -}} +app.kubernetes.io/name: {{ include "charts.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "charts.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "charts.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/backend/cicd/prd/charts/templates/deployment.yaml b/backend/cicd/prd/charts/templates/deployment.yaml new file mode 100644 index 00000000..4aafed41 --- /dev/null +++ b/backend/cicd/prd/charts/templates/deployment.yaml @@ -0,0 +1,68 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "charts.fullname" . }} + labels: + {{- include "charts.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "charts.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "charts.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "charts.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 9400 + protocol: TCP + env: + - name: JAVA_OPTS + value: -Dspring.profiles.active={{ .Values.application.mode }} -Dcom.amazonaws.sdk.disableEc2Metadata=true + # livenessProbe: + # httpGet: + # path: /healthcheck + # port: http + # initialDelaySeconds: 60 + # periodSeconds: 60 + readinessProbe: + httpGet: + path: /healthcheck + port: http + initialDelaySeconds: 60 + periodSeconds: 60 + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/backend/cicd/prd/charts/templates/hpa.yaml b/backend/cicd/prd/charts/templates/hpa.yaml new file mode 100644 index 00000000..7138f1d4 --- /dev/null +++ b/backend/cicd/prd/charts/templates/hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "charts.fullname" . }} + labels: + {{- include "charts.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "charts.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/backend/cicd/prd/charts/templates/ingress.yaml b/backend/cicd/prd/charts/templates/ingress.yaml new file mode 100644 index 00000000..cc6b59f4 --- /dev/null +++ b/backend/cicd/prd/charts/templates/ingress.yaml @@ -0,0 +1,56 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "charts.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "charts.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if .Values.ingress.ingressClassName }} + ingressClassName: {{ .Values.ingress.ingressClassName }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/backend/cicd/prd/charts/templates/service.yaml b/backend/cicd/prd/charts/templates/service.yaml new file mode 100644 index 00000000..451653ca --- /dev/null +++ b/backend/cicd/prd/charts/templates/service.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "charts.fullname" . }} + labels: + {{- include "charts.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: {{ .Values.service.targetPort }} + protocol: TCP + name: http +{{- if .Values.service.nodePort }} + nodePort: {{ .Values.service.nodePort }} +{{- end }} + selector: + {{- include "charts.selectorLabels" . | nindent 4 }} diff --git a/backend/cicd/prd/charts/templates/serviceaccount.yaml b/backend/cicd/prd/charts/templates/serviceaccount.yaml new file mode 100644 index 00000000..9397ca79 --- /dev/null +++ b/backend/cicd/prd/charts/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "charts.serviceAccountName" . }} + labels: + {{- include "charts.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/backend/cicd/prd/charts/templates/tests/test-connection.yaml b/backend/cicd/prd/charts/templates/tests/test-connection.yaml new file mode 100644 index 00000000..f482848d --- /dev/null +++ b/backend/cicd/prd/charts/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "charts.fullname" . }}-test-connection" + labels: + {{- include "charts.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "charts.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/backend/cicd/prd/charts/values.yaml b/backend/cicd/prd/charts/values.yaml new file mode 100644 index 00000000..d0e692e7 --- /dev/null +++ b/backend/cicd/prd/charts/values.yaml @@ -0,0 +1,65 @@ +replicaCount: 1 + +image: + repository: choisunguk/ciat-prd-backend + pullPolicy: IfNotPresent + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + create: false + annotations: {} + name: "" + +podAnnotations: {} +podSecurityContext: {} +securityContext: {} + +service: + type: NodePort + port: 9400 + targetPort: 9400 + nodePort: 30502 + +ingress: + enabled: true + ingressClassName: "nginx" + annotations: + cert-manager.io/cluster-issuer: "letencrypt-prod" + certmanager.k8s.io/acme-challenge-type: dns01 + hosts: + - host: ciat.choicloudlab.com + paths: + - path: /api/v1 + pathType: Prefix + tls: + - secretName: ciat-prd + hosts: + - ciat.choicloudlab.com + +resources: + limits: + cpu: 300m + memory: 512Mi + requests: + cpu: 300m + memory: 512Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +application: + mode: prd diff --git a/backend/cicd/prd/override_values.yaml b/backend/cicd/prd/override_values.yaml new file mode 100644 index 00000000..e69de29b From 0293315e666f5336df246260beaa86152991a4cf Mon Sep 17 00:00:00 2001 From: GitHub Actions Bot Date: Sun, 23 Jan 2022 08:40:23 +0000 Subject: [PATCH 22/38] change dockertag --- backend/cicd/dev/charts/override_values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/cicd/dev/charts/override_values.yaml b/backend/cicd/dev/charts/override_values.yaml index a65e698c..c11a4ddc 100644 --- a/backend/cicd/dev/charts/override_values.yaml +++ b/backend/cicd/dev/charts/override_values.yaml @@ -1,2 +1,2 @@ image: - tag: 1ce6d0560a4b063b2f8d42dd9baf67c2a20bd45e + tag: 4ecdd67bd9014076a05787c142575e5770913a36 From c37c5061e711f5b077ffa01acfda8b861647278b Mon Sep 17 00:00:00 2001 From: choisungwook Date: Sun, 23 Jan 2022 17:46:04 +0900 Subject: [PATCH 23/38] =?UTF-8?q?dummy=ED=8C=8C=EC=9D=BC=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 --- .github/workflows/backend-prd.yaml | 6 +++--- backend/cicd/prd/{ => charts}/override_values.yaml | 0 2 files changed, 3 insertions(+), 3 deletions(-) rename backend/cicd/prd/{ => charts}/override_values.yaml (100%) diff --git a/.github/workflows/backend-prd.yaml b/.github/workflows/backend-prd.yaml index 31ebe3b0..a3d80203 100644 --- a/.github/workflows/backend-prd.yaml +++ b/.github/workflows/backend-prd.yaml @@ -57,7 +57,7 @@ jobs: - name: copy dockerfile run: | rm -rf ./Dockerfile - cp ./cicd/dev/Dockerfile ./Dockerfile + cp ./cicd/prd/Dockerfile ./Dockerfile - name: Build and push id: docker_build @@ -67,7 +67,7 @@ jobs: - name: change override_values.yaml run: | - cat < ./cicd/dev/charts/override_values.yaml + cat < ./cicd/prd/charts/override_values.yaml image: tag: ${{ env.dockerimage_tag }} EOF @@ -76,7 +76,7 @@ jobs: run: | git config --global user.email "GitHub Actions Bot@github.com" git config --global user.name "GitHub Actions Bot" - git add ./cicd/dev/charts/override_values.yaml + git add ./cicd/prd/charts/override_values.yaml git commit -m "change dockertag" git push origin production diff --git a/backend/cicd/prd/override_values.yaml b/backend/cicd/prd/charts/override_values.yaml similarity index 100% rename from backend/cicd/prd/override_values.yaml rename to backend/cicd/prd/charts/override_values.yaml From f9859c5dc30eb007a7943af4fd12c2ddf9cbaeec Mon Sep 17 00:00:00 2001 From: choisungwook Date: Sun, 23 Jan 2022 19:00:56 +0900 Subject: [PATCH 24/38] =?UTF-8?q?backend=20=EA=B0=9C=EB=B0=9C=ED=99=98?= =?UTF-8?q?=EA=B2=BD=20workflow=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/backend-dev.yaml | 62 ++++++++++++++++-------------- backend/cicd/dev/Jenkinsfile | 61 ----------------------------- 2 files changed, 33 insertions(+), 90 deletions(-) delete mode 100644 backend/cicd/dev/Jenkinsfile diff --git a/.github/workflows/backend-dev.yaml b/.github/workflows/backend-dev.yaml index 2b01a088..12f5681e 100644 --- a/.github/workflows/backend-dev.yaml +++ b/.github/workflows/backend-dev.yaml @@ -4,8 +4,10 @@ on: push: branches: - "develop" - paths-ignore: - - "backend/cicd/dev/charts/override_values.yaml" + +env: + dockerimage_tag: ${{ github.sha }} + dockerimage_name: choisunguk/siat-dev-backend:${{ github.sha }} jobs: build: @@ -15,10 +17,6 @@ jobs: run: working-directory: ./backend - env: - dockerimage_tag: ${{ github.sha }} - dockerimage_name: choisunguk/siat-dev-backend:${{ github.sha }} - # 1. git submodule을 이용해서 스프링부트 프로파일 복사 # 2. 스프링부트 프로젝트 빌드 # 3. docker build @@ -64,22 +62,6 @@ jobs: run: | docker build -t ${{ env.dockerimage_name }} . docker push ${{ env.dockerimage_name }} - - - name: change override_values.yaml - run: | - cat < ./cicd/dev/charts/override_values.yaml - image: - tag: ${{ env.dockerimage_tag }} - EOF - - - name: git push - run: | - git config --global user.email "GitHub Actions Bot@github.com" - git config --global user.name "GitHub Actions Bot" - git add ./cicd/dev/charts/override_values.yaml - git commit -m "change dockertag" - git push origin develop - - name: Discord Alert Success uses: sarisia/actions-status-discord@v1 @@ -95,12 +77,6 @@ jobs: webhook: ${{ secrets.DISCORD_WEBHOOK }} description: "🔥 테스트를 실패하였습니다." - - name: Publish Unit Test Results - uses: EnricoMi/publish-unit-test-result-action@v1 - if: ${{ always() }} - with: - files: build/test-results/*/.xml - - name: Cleanup Gradle Cache # Remove some files from the Gradle cache, so they aren't cached by GitHub Actions. # Restoring these files from a GitHub Actions cache might cause problems for future builds. @@ -108,4 +84,32 @@ jobs: run: | rm -f ~/.gradle/caches/modules-2/modules-2.lock rm -f ~/.gradle/caches/modules-2/gc.properties - \ No newline at end of file + + update-argocd-metadata: + runs-on: ubuntu-latest + + defaults: + run: + working-directory: ./dev/backend + + steps: + - uses: actions/checkout@v2 + with: + ref: "charts" + ssh-key: ${{ secrets.GITHUBACTION_KEY }} + submodules: 'recursive' + + - name: change override_values.yaml + run: | + cat < override_values.yaml + image: + tag: ${{ env.dockerimage_tag }} + EOF + + - name: git push + run: | + git config --global user.email "GitHub Actions Bot@github.com" + git config --global user.name "GitHub Actions Bot" + git add ./cicd/dev/charts/override_values.yaml + git commit -m "change dockertag" + git push origin develop diff --git a/backend/cicd/dev/Jenkinsfile b/backend/cicd/dev/Jenkinsfile deleted file mode 100644 index 25a90fad..00000000 --- a/backend/cicd/dev/Jenkinsfile +++ /dev/null @@ -1,61 +0,0 @@ -pipeline { - agent any - tools {gradle "gradle"} - - environment { - APP_NAME = "ciat-backend-dev" - NAMESPACE = "infp" - DOCKER_IMAGE = "ciat-dev-backend" - TAG = "${BUILD_NUMBER}" - DOCKER_IMAGENAME = "${DOCKER_IMAGE}:${TAG}" - JASYPT_KEY = credentials('SIAT_DEV_JASYPT') - MODE = "dev" - TLS_SECRETNAME = "ciat-dev" - INGRESS_HOST1 = "ciat-dev.choicloudlab.com" - } - - stages { - stage('project build'){ - steps{ - dir('backend'){ - withGradle { - sh 'gradle clean build --exclude-task test' - } - } - } - } - stage('docker build&push'){ - steps{ - dir('backend'){ - sh 'rm -rf ./Dockerfile Jenkinsfile charts' - sh 'cp -rf cicd/dev/* ./' - withCredentials([string(credentialsId: 'dockerID', variable: 'dockerID')]) { - script{ - sh 'docker build -t ${dockerID}/${DOCKER_IMAGENAME} .' - // 비용문제로 주석 - // withCredentials([usernamePassword(credentialsId: 'docker', passwordVariable: 'dockerpassword', usernameVariable: 'dockeruser')]) { - // sh 'docker login -u ${dockeruser} -p ${dockerpassword}' - // sh 'docker push ${dockerID}/${DOCKER_IMAGENAME}' - // } - } - } - } - } - } - stage('deploy'){ - steps{ - dir('backend'){ - withCredentials([string(credentialsId: 'dockerID', variable: 'dockerID')]) { - sh 'sed -i "s/__IMAGENAME__/${dockerID}\\/${DOCKER_IMAGE}/g" charts/values.yaml' - sh 'sed -i "s/__TAGNAME__/${TAG}/g" charts/values.yaml' - sh 'sed -i "s/__JASYPT__/${JASYPT_KEY}/g" charts/values.yaml' - sh 'sed -i "s/__MODE__/${MODE}/g" charts/values.yaml' - sh 'sed -i "s/__HOST1__/${INGRESS_HOST1}/g" charts/values.yaml' - sh 'sed -i "s/__TLS__SECRETNAME__/${TLS_SECRETNAME}/g" charts/values.yaml' - sh "helm upgrade --install --namespace ${NAMESPACE} ${APP_NAME} ./charts" - } - } - } - } - } -} From b86c1d75b1035110536fe3482df8ee6cf953e648 Mon Sep 17 00:00:00 2001 From: choisungwook Date: Sun, 23 Jan 2022 19:01:21 +0900 Subject: [PATCH 25/38] fix: branch --- .github/workflows/backend-dev.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/backend-dev.yaml b/.github/workflows/backend-dev.yaml index 12f5681e..1583f99d 100644 --- a/.github/workflows/backend-dev.yaml +++ b/.github/workflows/backend-dev.yaml @@ -112,4 +112,4 @@ jobs: git config --global user.name "GitHub Actions Bot" git add ./cicd/dev/charts/override_values.yaml git commit -m "change dockertag" - git push origin develop + git push origin charts From d7e896c6180b1a59120779fa6599488d08e42be6 Mon Sep 17 00:00:00 2001 From: choisungwook Date: Sun, 23 Jan 2022 19:03:55 +0900 Subject: [PATCH 26/38] fix: git add --- .github/workflows/backend-dev.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/backend-dev.yaml b/.github/workflows/backend-dev.yaml index 1583f99d..6a17f6a0 100644 --- a/.github/workflows/backend-dev.yaml +++ b/.github/workflows/backend-dev.yaml @@ -110,6 +110,6 @@ jobs: run: | git config --global user.email "GitHub Actions Bot@github.com" git config --global user.name "GitHub Actions Bot" - git add ./cicd/dev/charts/override_values.yaml + git add override_values.yaml git commit -m "change dockertag" git push origin charts From 91d05ef7a6dddb5226f61e8d4b8321828d289629 Mon Sep 17 00:00:00 2001 From: choisungwook Date: Sun, 23 Jan 2022 19:05:28 +0900 Subject: [PATCH 27/38] =?UTF-8?q?workflow=20job=20=EC=88=9C=EC=84=9C?= =?UTF-8?q?=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/backend-dev.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/backend-dev.yaml b/.github/workflows/backend-dev.yaml index 6a17f6a0..9d2d8f5f 100644 --- a/.github/workflows/backend-dev.yaml +++ b/.github/workflows/backend-dev.yaml @@ -86,6 +86,7 @@ jobs: rm -f ~/.gradle/caches/modules-2/gc.properties update-argocd-metadata: + needs: build runs-on: ubuntu-latest defaults: From d05872c73678a4c0464791136776a31c1c2765a2 Mon Sep 17 00:00:00 2001 From: choisungwook Date: Sun, 23 Jan 2022 19:17:44 +0900 Subject: [PATCH 28/38] =?UTF-8?q?backend=20prd=20workflow=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/backend-dev.yaml | 1 + .github/workflows/backend-prd.yaml | 79 ++++++++++++++++-------------- 2 files changed, 44 insertions(+), 36 deletions(-) diff --git a/.github/workflows/backend-dev.yaml b/.github/workflows/backend-dev.yaml index 9d2d8f5f..1cea98ca 100644 --- a/.github/workflows/backend-dev.yaml +++ b/.github/workflows/backend-dev.yaml @@ -113,4 +113,5 @@ jobs: git config --global user.name "GitHub Actions Bot" git add override_values.yaml git commit -m "change dockertag" + git pull origin charts git push origin charts diff --git a/.github/workflows/backend-prd.yaml b/.github/workflows/backend-prd.yaml index a3d80203..bc4f911e 100644 --- a/.github/workflows/backend-prd.yaml +++ b/.github/workflows/backend-prd.yaml @@ -3,9 +3,7 @@ name: backend-prd-CICD on: push: branches: - - "production" - paths-ignore: - - "backend/cicd/prd/charts/override_values.yaml" + - "prd" jobs: build: @@ -65,40 +63,19 @@ jobs: docker build -t ${{ env.dockerimage_name }} . docker push ${{ env.dockerimage_name }} - - name: change override_values.yaml - run: | - cat < ./cicd/prd/charts/override_values.yaml - image: - tag: ${{ env.dockerimage_tag }} - EOF - - - name: git push - run: | - git config --global user.email "GitHub Actions Bot@github.com" - git config --global user.name "GitHub Actions Bot" - git add ./cicd/prd/charts/override_values.yaml - git commit -m "change dockertag" - git push origin production - - # - name: Discord Alert Success - # uses: sarisia/actions-status-discord@v1 - # if: success() - # with: - # webhook: ${{ secrets.DISCORD_WEBHOOK }} - # description: "🎉 테스트 되었습니다!" - - # - name: Discord Alert Failure - # uses: sarisia/actions-status-discord@v1 - # if: failure() - # with: - # webhook: ${{ secrets.DISCORD_WEBHOOK }} - # description: "🔥 테스트를 실패하였습니다." + - name: Discord Alert Success + uses: sarisia/actions-status-discord@v1 + if: success() + with: + webhook: ${{ secrets.DISCORD_WEBHOOK }} + description: "🎉 테스트 되었습니다!" - - name: Publish Unit Test Results - uses: EnricoMi/publish-unit-test-result-action@v1 - if: ${{ always() }} + - name: Discord Alert Failure + uses: sarisia/actions-status-discord@v1 + if: failure() with: - files: build/test-results/*/.xml + webhook: ${{ secrets.DISCORD_WEBHOOK }} + description: "🔥 테스트를 실패하였습니다." - name: Cleanup Gradle Cache # Remove some files from the Gradle cache, so they aren't cached by GitHub Actions. @@ -107,4 +84,34 @@ jobs: run: | rm -f ~/.gradle/caches/modules-2/modules-2.lock rm -f ~/.gradle/caches/modules-2/gc.properties - \ No newline at end of file + + update-argocd-metadata: + needs: build + runs-on: ubuntu-latest + + defaults: + run: + working-directory: ./prd/backend + + steps: + - uses: actions/checkout@v2 + with: + ref: "charts" + ssh-key: ${{ secrets.GITHUBACTION_KEY }} + submodules: 'recursive' + + - name: change override_values.yaml + run: | + cat < override_values.yaml + image: + tag: ${{ env.dockerimage_tag }} + EOF + + - name: git push + run: | + git config --global user.email "GitHub Actions Bot@github.com" + git config --global user.name "GitHub Actions Bot" + git add override_values.yaml + git commit -m "change dockertag" + git pull origin charts + git push origin charts From 6256e15a7d65e6b49fb51c4c0938fc8860f13a0a Mon Sep 17 00:00:00 2001 From: choisungwook Date: Sun, 23 Jan 2022 19:18:25 +0900 Subject: [PATCH 29/38] =?UTF-8?q?charts=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/cicd/dev/charts/.helmignore | 23 ------- backend/cicd/dev/charts/Chart.yaml | 6 -- backend/cicd/dev/charts/templates/NOTES.txt | 22 ------ .../cicd/dev/charts/templates/_helpers.tpl | 62 ----------------- .../cicd/dev/charts/templates/deployment.yaml | 68 ------------------- backend/cicd/dev/charts/templates/hpa.yaml | 28 -------- .../cicd/dev/charts/templates/ingress.yaml | 56 --------------- .../cicd/dev/charts/templates/service.yaml | 18 ----- .../dev/charts/templates/serviceaccount.yaml | 12 ---- .../templates/tests/test-connection.yaml | 15 ---- backend/cicd/dev/charts/values.yaml | 65 ------------------ backend/cicd/prd/charts/.helmignore | 23 ------- backend/cicd/prd/charts/Chart.yaml | 6 -- backend/cicd/prd/charts/override_values.yaml | 0 backend/cicd/prd/charts/templates/NOTES.txt | 22 ------ .../cicd/prd/charts/templates/_helpers.tpl | 62 ----------------- .../cicd/prd/charts/templates/deployment.yaml | 68 ------------------- backend/cicd/prd/charts/templates/hpa.yaml | 28 -------- .../cicd/prd/charts/templates/ingress.yaml | 56 --------------- .../cicd/prd/charts/templates/service.yaml | 18 ----- .../prd/charts/templates/serviceaccount.yaml | 12 ---- .../templates/tests/test-connection.yaml | 15 ---- backend/cicd/prd/charts/values.yaml | 65 ------------------ 23 files changed, 750 deletions(-) delete mode 100644 backend/cicd/dev/charts/.helmignore delete mode 100644 backend/cicd/dev/charts/Chart.yaml delete mode 100644 backend/cicd/dev/charts/templates/NOTES.txt delete mode 100644 backend/cicd/dev/charts/templates/_helpers.tpl delete mode 100644 backend/cicd/dev/charts/templates/deployment.yaml delete mode 100644 backend/cicd/dev/charts/templates/hpa.yaml delete mode 100644 backend/cicd/dev/charts/templates/ingress.yaml delete mode 100644 backend/cicd/dev/charts/templates/service.yaml delete mode 100644 backend/cicd/dev/charts/templates/serviceaccount.yaml delete mode 100644 backend/cicd/dev/charts/templates/tests/test-connection.yaml delete mode 100644 backend/cicd/dev/charts/values.yaml delete mode 100644 backend/cicd/prd/charts/.helmignore delete mode 100644 backend/cicd/prd/charts/Chart.yaml delete mode 100644 backend/cicd/prd/charts/override_values.yaml delete mode 100644 backend/cicd/prd/charts/templates/NOTES.txt delete mode 100644 backend/cicd/prd/charts/templates/_helpers.tpl delete mode 100644 backend/cicd/prd/charts/templates/deployment.yaml delete mode 100644 backend/cicd/prd/charts/templates/hpa.yaml delete mode 100644 backend/cicd/prd/charts/templates/ingress.yaml delete mode 100644 backend/cicd/prd/charts/templates/service.yaml delete mode 100644 backend/cicd/prd/charts/templates/serviceaccount.yaml delete mode 100644 backend/cicd/prd/charts/templates/tests/test-connection.yaml delete mode 100644 backend/cicd/prd/charts/values.yaml diff --git a/backend/cicd/dev/charts/.helmignore b/backend/cicd/dev/charts/.helmignore deleted file mode 100644 index 0e8a0eb3..00000000 --- a/backend/cicd/dev/charts/.helmignore +++ /dev/null @@ -1,23 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*.orig -*~ -# Various IDEs -.project -.idea/ -*.tmproj -.vscode/ diff --git a/backend/cicd/dev/charts/Chart.yaml b/backend/cicd/dev/charts/Chart.yaml deleted file mode 100644 index 76c5db78..00000000 --- a/backend/cicd/dev/charts/Chart.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: v2 -name: alpha -description: SIAT dev -type: application -version: 0.1.0 -appVersion: "0.1.0" diff --git a/backend/cicd/dev/charts/templates/NOTES.txt b/backend/cicd/dev/charts/templates/NOTES.txt deleted file mode 100644 index 97dd3a9b..00000000 --- a/backend/cicd/dev/charts/templates/NOTES.txt +++ /dev/null @@ -1,22 +0,0 @@ -1. Get the application URL by running these commands: -{{- if .Values.ingress.enabled }} -{{- range $host := .Values.ingress.hosts }} - {{- range .paths }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} - {{- end }} -{{- end }} -{{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "charts.fullname" . }}) - export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "charts.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "charts.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "charts.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") - export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") - echo "Visit http://127.0.0.1:8080 to use your application" - kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT -{{- end }} diff --git a/backend/cicd/dev/charts/templates/_helpers.tpl b/backend/cicd/dev/charts/templates/_helpers.tpl deleted file mode 100644 index 68f9e0e2..00000000 --- a/backend/cicd/dev/charts/templates/_helpers.tpl +++ /dev/null @@ -1,62 +0,0 @@ -{{/* -Expand the name of the chart. -*/}} -{{- define "charts.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} -{{- end }} - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -If release name contains chart name it will be used as a full name. -*/}} -{{- define "charts.fullname" -}} -{{- if .Values.fullnameOverride }} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} -{{- else }} -{{- $name := default .Chart.Name .Values.nameOverride }} -{{- if contains $name .Release.Name }} -{{- .Release.Name | trunc 63 | trimSuffix "-" }} -{{- else }} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} -{{- end }} -{{- end }} -{{- end }} - -{{/* -Create chart name and version as used by the chart label. -*/}} -{{- define "charts.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} -{{- end }} - -{{/* -Common labels -*/}} -{{- define "charts.labels" -}} -helm.sh/chart: {{ include "charts.chart" . }} -{{ include "charts.selectorLabels" . }} -{{- if .Chart.AppVersion }} -app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} -{{- end }} -app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- end }} - -{{/* -Selector labels -*/}} -{{- define "charts.selectorLabels" -}} -app.kubernetes.io/name: {{ include "charts.name" . }} -app.kubernetes.io/instance: {{ .Release.Name }} -{{- end }} - -{{/* -Create the name of the service account to use -*/}} -{{- define "charts.serviceAccountName" -}} -{{- if .Values.serviceAccount.create }} -{{- default (include "charts.fullname" .) .Values.serviceAccount.name }} -{{- else }} -{{- default "default" .Values.serviceAccount.name }} -{{- end }} -{{- end }} diff --git a/backend/cicd/dev/charts/templates/deployment.yaml b/backend/cicd/dev/charts/templates/deployment.yaml deleted file mode 100644 index 4aafed41..00000000 --- a/backend/cicd/dev/charts/templates/deployment.yaml +++ /dev/null @@ -1,68 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ include "charts.fullname" . }} - labels: - {{- include "charts.labels" . | nindent 4 }} -spec: - {{- if not .Values.autoscaling.enabled }} - replicas: {{ .Values.replicaCount }} - {{- end }} - selector: - matchLabels: - {{- include "charts.selectorLabels" . | nindent 6 }} - template: - metadata: - {{- with .Values.podAnnotations }} - annotations: - {{- toYaml . | nindent 8 }} - {{- end }} - labels: - {{- include "charts.selectorLabels" . | nindent 8 }} - spec: - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - serviceAccountName: {{ include "charts.serviceAccountName" . }} - securityContext: - {{- toYaml .Values.podSecurityContext | nindent 8 }} - containers: - - name: {{ .Chart.Name }} - securityContext: - {{- toYaml .Values.securityContext | nindent 12 }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} - ports: - - name: http - containerPort: 9400 - protocol: TCP - env: - - name: JAVA_OPTS - value: -Dspring.profiles.active={{ .Values.application.mode }} -Dcom.amazonaws.sdk.disableEc2Metadata=true - # livenessProbe: - # httpGet: - # path: /healthcheck - # port: http - # initialDelaySeconds: 60 - # periodSeconds: 60 - readinessProbe: - httpGet: - path: /healthcheck - port: http - initialDelaySeconds: 60 - periodSeconds: 60 - resources: - {{- toYaml .Values.resources | nindent 12 }} - {{- with .Values.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.affinity }} - affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} diff --git a/backend/cicd/dev/charts/templates/hpa.yaml b/backend/cicd/dev/charts/templates/hpa.yaml deleted file mode 100644 index 7138f1d4..00000000 --- a/backend/cicd/dev/charts/templates/hpa.yaml +++ /dev/null @@ -1,28 +0,0 @@ -{{- if .Values.autoscaling.enabled }} -apiVersion: autoscaling/v2beta1 -kind: HorizontalPodAutoscaler -metadata: - name: {{ include "charts.fullname" . }} - labels: - {{- include "charts.labels" . | nindent 4 }} -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: {{ include "charts.fullname" . }} - minReplicas: {{ .Values.autoscaling.minReplicas }} - maxReplicas: {{ .Values.autoscaling.maxReplicas }} - metrics: - {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} - - type: Resource - resource: - name: cpu - targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} - {{- end }} - {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} - - type: Resource - resource: - name: memory - targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} - {{- end }} -{{- end }} diff --git a/backend/cicd/dev/charts/templates/ingress.yaml b/backend/cicd/dev/charts/templates/ingress.yaml deleted file mode 100644 index cc6b59f4..00000000 --- a/backend/cicd/dev/charts/templates/ingress.yaml +++ /dev/null @@ -1,56 +0,0 @@ -{{- if .Values.ingress.enabled -}} -{{- $fullName := include "charts.fullname" . -}} -{{- $svcPort := .Values.service.port -}} -{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} -apiVersion: networking.k8s.io/v1 -{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} -apiVersion: networking.k8s.io/v1beta1 -{{- else -}} -apiVersion: extensions/v1beta1 -{{- end }} -kind: Ingress -metadata: - name: {{ $fullName }} - labels: - {{- include "charts.labels" . | nindent 4 }} - {{- with .Values.ingress.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -spec: - {{- if .Values.ingress.ingressClassName }} - ingressClassName: {{ .Values.ingress.ingressClassName }} - {{- end }} - {{- if .Values.ingress.tls }} - tls: - {{- range .Values.ingress.tls }} - - hosts: - {{- range .hosts }} - - {{ . | quote }} - {{- end }} - secretName: {{ .secretName }} - {{- end }} - {{- end }} - rules: - {{- range .Values.ingress.hosts }} - - host: {{ .host | quote }} - http: - paths: - {{- range .paths }} - - path: {{ .path }} - {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} - pathType: {{ .pathType }} - {{- end }} - backend: - {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} - service: - name: {{ $fullName }} - port: - number: {{ $svcPort }} - {{- else }} - serviceName: {{ $fullName }} - servicePort: {{ $svcPort }} - {{- end }} - {{- end }} - {{- end }} -{{- end }} diff --git a/backend/cicd/dev/charts/templates/service.yaml b/backend/cicd/dev/charts/templates/service.yaml deleted file mode 100644 index 451653ca..00000000 --- a/backend/cicd/dev/charts/templates/service.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ include "charts.fullname" . }} - labels: - {{- include "charts.labels" . | nindent 4 }} -spec: - type: {{ .Values.service.type }} - ports: - - port: {{ .Values.service.port }} - targetPort: {{ .Values.service.targetPort }} - protocol: TCP - name: http -{{- if .Values.service.nodePort }} - nodePort: {{ .Values.service.nodePort }} -{{- end }} - selector: - {{- include "charts.selectorLabels" . | nindent 4 }} diff --git a/backend/cicd/dev/charts/templates/serviceaccount.yaml b/backend/cicd/dev/charts/templates/serviceaccount.yaml deleted file mode 100644 index 9397ca79..00000000 --- a/backend/cicd/dev/charts/templates/serviceaccount.yaml +++ /dev/null @@ -1,12 +0,0 @@ -{{- if .Values.serviceAccount.create -}} -apiVersion: v1 -kind: ServiceAccount -metadata: - name: {{ include "charts.serviceAccountName" . }} - labels: - {{- include "charts.labels" . | nindent 4 }} - {{- with .Values.serviceAccount.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -{{- end }} diff --git a/backend/cicd/dev/charts/templates/tests/test-connection.yaml b/backend/cicd/dev/charts/templates/tests/test-connection.yaml deleted file mode 100644 index f482848d..00000000 --- a/backend/cicd/dev/charts/templates/tests/test-connection.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - name: "{{ include "charts.fullname" . }}-test-connection" - labels: - {{- include "charts.labels" . | nindent 4 }} - annotations: - "helm.sh/hook": test -spec: - containers: - - name: wget - image: busybox - command: ['wget'] - args: ['{{ include "charts.fullname" . }}:{{ .Values.service.port }}'] - restartPolicy: Never diff --git a/backend/cicd/dev/charts/values.yaml b/backend/cicd/dev/charts/values.yaml deleted file mode 100644 index 8b6be2ef..00000000 --- a/backend/cicd/dev/charts/values.yaml +++ /dev/null @@ -1,65 +0,0 @@ -replicaCount: 1 - -image: - repository: choisunguk/siat-dev-backend - pullPolicy: IfNotPresent - tag: "" - -imagePullSecrets: [] -nameOverride: "" -fullnameOverride: "" - -serviceAccount: - create: false - annotations: {} - name: "" - -podAnnotations: {} -podSecurityContext: {} -securityContext: {} - -service: - type: NodePort - port: 9400 - targetPort: 9400 - nodePort: 30501 - -ingress: - enabled: true - ingressClassName: "nginx" - annotations: - cert-manager.io/cluster-issuer: "letencrypt-prod" - certmanager.k8s.io/acme-challenge-type: dns01 - hosts: - - host: ciat-dev.choicloudlab.com - paths: - - path: /api/v1 - pathType: Prefix - tls: - - secretName: ciat-dev - hosts: - - ciat-dev.choicloudlab.com - -resources: - limits: - cpu: 300m - memory: 512Mi - requests: - cpu: 300m - memory: 512Mi - -autoscaling: - enabled: false - minReplicas: 1 - maxReplicas: 100 - targetCPUUtilizationPercentage: 80 - # targetMemoryUtilizationPercentage: 80 - -nodeSelector: {} - -tolerations: [] - -affinity: {} - -application: - mode: dev diff --git a/backend/cicd/prd/charts/.helmignore b/backend/cicd/prd/charts/.helmignore deleted file mode 100644 index 0e8a0eb3..00000000 --- a/backend/cicd/prd/charts/.helmignore +++ /dev/null @@ -1,23 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*.orig -*~ -# Various IDEs -.project -.idea/ -*.tmproj -.vscode/ diff --git a/backend/cicd/prd/charts/Chart.yaml b/backend/cicd/prd/charts/Chart.yaml deleted file mode 100644 index 36428106..00000000 --- a/backend/cicd/prd/charts/Chart.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: v2 -name: release -description: ciat prd backend -type: application -version: 0.1.0 -appVersion: "0.1.0" diff --git a/backend/cicd/prd/charts/override_values.yaml b/backend/cicd/prd/charts/override_values.yaml deleted file mode 100644 index e69de29b..00000000 diff --git a/backend/cicd/prd/charts/templates/NOTES.txt b/backend/cicd/prd/charts/templates/NOTES.txt deleted file mode 100644 index 97dd3a9b..00000000 --- a/backend/cicd/prd/charts/templates/NOTES.txt +++ /dev/null @@ -1,22 +0,0 @@ -1. Get the application URL by running these commands: -{{- if .Values.ingress.enabled }} -{{- range $host := .Values.ingress.hosts }} - {{- range .paths }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} - {{- end }} -{{- end }} -{{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "charts.fullname" . }}) - export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "charts.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "charts.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "charts.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") - export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") - echo "Visit http://127.0.0.1:8080 to use your application" - kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT -{{- end }} diff --git a/backend/cicd/prd/charts/templates/_helpers.tpl b/backend/cicd/prd/charts/templates/_helpers.tpl deleted file mode 100644 index 68f9e0e2..00000000 --- a/backend/cicd/prd/charts/templates/_helpers.tpl +++ /dev/null @@ -1,62 +0,0 @@ -{{/* -Expand the name of the chart. -*/}} -{{- define "charts.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} -{{- end }} - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -If release name contains chart name it will be used as a full name. -*/}} -{{- define "charts.fullname" -}} -{{- if .Values.fullnameOverride }} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} -{{- else }} -{{- $name := default .Chart.Name .Values.nameOverride }} -{{- if contains $name .Release.Name }} -{{- .Release.Name | trunc 63 | trimSuffix "-" }} -{{- else }} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} -{{- end }} -{{- end }} -{{- end }} - -{{/* -Create chart name and version as used by the chart label. -*/}} -{{- define "charts.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} -{{- end }} - -{{/* -Common labels -*/}} -{{- define "charts.labels" -}} -helm.sh/chart: {{ include "charts.chart" . }} -{{ include "charts.selectorLabels" . }} -{{- if .Chart.AppVersion }} -app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} -{{- end }} -app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- end }} - -{{/* -Selector labels -*/}} -{{- define "charts.selectorLabels" -}} -app.kubernetes.io/name: {{ include "charts.name" . }} -app.kubernetes.io/instance: {{ .Release.Name }} -{{- end }} - -{{/* -Create the name of the service account to use -*/}} -{{- define "charts.serviceAccountName" -}} -{{- if .Values.serviceAccount.create }} -{{- default (include "charts.fullname" .) .Values.serviceAccount.name }} -{{- else }} -{{- default "default" .Values.serviceAccount.name }} -{{- end }} -{{- end }} diff --git a/backend/cicd/prd/charts/templates/deployment.yaml b/backend/cicd/prd/charts/templates/deployment.yaml deleted file mode 100644 index 4aafed41..00000000 --- a/backend/cicd/prd/charts/templates/deployment.yaml +++ /dev/null @@ -1,68 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ include "charts.fullname" . }} - labels: - {{- include "charts.labels" . | nindent 4 }} -spec: - {{- if not .Values.autoscaling.enabled }} - replicas: {{ .Values.replicaCount }} - {{- end }} - selector: - matchLabels: - {{- include "charts.selectorLabels" . | nindent 6 }} - template: - metadata: - {{- with .Values.podAnnotations }} - annotations: - {{- toYaml . | nindent 8 }} - {{- end }} - labels: - {{- include "charts.selectorLabels" . | nindent 8 }} - spec: - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - serviceAccountName: {{ include "charts.serviceAccountName" . }} - securityContext: - {{- toYaml .Values.podSecurityContext | nindent 8 }} - containers: - - name: {{ .Chart.Name }} - securityContext: - {{- toYaml .Values.securityContext | nindent 12 }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} - ports: - - name: http - containerPort: 9400 - protocol: TCP - env: - - name: JAVA_OPTS - value: -Dspring.profiles.active={{ .Values.application.mode }} -Dcom.amazonaws.sdk.disableEc2Metadata=true - # livenessProbe: - # httpGet: - # path: /healthcheck - # port: http - # initialDelaySeconds: 60 - # periodSeconds: 60 - readinessProbe: - httpGet: - path: /healthcheck - port: http - initialDelaySeconds: 60 - periodSeconds: 60 - resources: - {{- toYaml .Values.resources | nindent 12 }} - {{- with .Values.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.affinity }} - affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} diff --git a/backend/cicd/prd/charts/templates/hpa.yaml b/backend/cicd/prd/charts/templates/hpa.yaml deleted file mode 100644 index 7138f1d4..00000000 --- a/backend/cicd/prd/charts/templates/hpa.yaml +++ /dev/null @@ -1,28 +0,0 @@ -{{- if .Values.autoscaling.enabled }} -apiVersion: autoscaling/v2beta1 -kind: HorizontalPodAutoscaler -metadata: - name: {{ include "charts.fullname" . }} - labels: - {{- include "charts.labels" . | nindent 4 }} -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: {{ include "charts.fullname" . }} - minReplicas: {{ .Values.autoscaling.minReplicas }} - maxReplicas: {{ .Values.autoscaling.maxReplicas }} - metrics: - {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} - - type: Resource - resource: - name: cpu - targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} - {{- end }} - {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} - - type: Resource - resource: - name: memory - targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} - {{- end }} -{{- end }} diff --git a/backend/cicd/prd/charts/templates/ingress.yaml b/backend/cicd/prd/charts/templates/ingress.yaml deleted file mode 100644 index cc6b59f4..00000000 --- a/backend/cicd/prd/charts/templates/ingress.yaml +++ /dev/null @@ -1,56 +0,0 @@ -{{- if .Values.ingress.enabled -}} -{{- $fullName := include "charts.fullname" . -}} -{{- $svcPort := .Values.service.port -}} -{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} -apiVersion: networking.k8s.io/v1 -{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} -apiVersion: networking.k8s.io/v1beta1 -{{- else -}} -apiVersion: extensions/v1beta1 -{{- end }} -kind: Ingress -metadata: - name: {{ $fullName }} - labels: - {{- include "charts.labels" . | nindent 4 }} - {{- with .Values.ingress.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -spec: - {{- if .Values.ingress.ingressClassName }} - ingressClassName: {{ .Values.ingress.ingressClassName }} - {{- end }} - {{- if .Values.ingress.tls }} - tls: - {{- range .Values.ingress.tls }} - - hosts: - {{- range .hosts }} - - {{ . | quote }} - {{- end }} - secretName: {{ .secretName }} - {{- end }} - {{- end }} - rules: - {{- range .Values.ingress.hosts }} - - host: {{ .host | quote }} - http: - paths: - {{- range .paths }} - - path: {{ .path }} - {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} - pathType: {{ .pathType }} - {{- end }} - backend: - {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} - service: - name: {{ $fullName }} - port: - number: {{ $svcPort }} - {{- else }} - serviceName: {{ $fullName }} - servicePort: {{ $svcPort }} - {{- end }} - {{- end }} - {{- end }} -{{- end }} diff --git a/backend/cicd/prd/charts/templates/service.yaml b/backend/cicd/prd/charts/templates/service.yaml deleted file mode 100644 index 451653ca..00000000 --- a/backend/cicd/prd/charts/templates/service.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ include "charts.fullname" . }} - labels: - {{- include "charts.labels" . | nindent 4 }} -spec: - type: {{ .Values.service.type }} - ports: - - port: {{ .Values.service.port }} - targetPort: {{ .Values.service.targetPort }} - protocol: TCP - name: http -{{- if .Values.service.nodePort }} - nodePort: {{ .Values.service.nodePort }} -{{- end }} - selector: - {{- include "charts.selectorLabels" . | nindent 4 }} diff --git a/backend/cicd/prd/charts/templates/serviceaccount.yaml b/backend/cicd/prd/charts/templates/serviceaccount.yaml deleted file mode 100644 index 9397ca79..00000000 --- a/backend/cicd/prd/charts/templates/serviceaccount.yaml +++ /dev/null @@ -1,12 +0,0 @@ -{{- if .Values.serviceAccount.create -}} -apiVersion: v1 -kind: ServiceAccount -metadata: - name: {{ include "charts.serviceAccountName" . }} - labels: - {{- include "charts.labels" . | nindent 4 }} - {{- with .Values.serviceAccount.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -{{- end }} diff --git a/backend/cicd/prd/charts/templates/tests/test-connection.yaml b/backend/cicd/prd/charts/templates/tests/test-connection.yaml deleted file mode 100644 index f482848d..00000000 --- a/backend/cicd/prd/charts/templates/tests/test-connection.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - name: "{{ include "charts.fullname" . }}-test-connection" - labels: - {{- include "charts.labels" . | nindent 4 }} - annotations: - "helm.sh/hook": test -spec: - containers: - - name: wget - image: busybox - command: ['wget'] - args: ['{{ include "charts.fullname" . }}:{{ .Values.service.port }}'] - restartPolicy: Never diff --git a/backend/cicd/prd/charts/values.yaml b/backend/cicd/prd/charts/values.yaml deleted file mode 100644 index d0e692e7..00000000 --- a/backend/cicd/prd/charts/values.yaml +++ /dev/null @@ -1,65 +0,0 @@ -replicaCount: 1 - -image: - repository: choisunguk/ciat-prd-backend - pullPolicy: IfNotPresent - tag: "" - -imagePullSecrets: [] -nameOverride: "" -fullnameOverride: "" - -serviceAccount: - create: false - annotations: {} - name: "" - -podAnnotations: {} -podSecurityContext: {} -securityContext: {} - -service: - type: NodePort - port: 9400 - targetPort: 9400 - nodePort: 30502 - -ingress: - enabled: true - ingressClassName: "nginx" - annotations: - cert-manager.io/cluster-issuer: "letencrypt-prod" - certmanager.k8s.io/acme-challenge-type: dns01 - hosts: - - host: ciat.choicloudlab.com - paths: - - path: /api/v1 - pathType: Prefix - tls: - - secretName: ciat-prd - hosts: - - ciat.choicloudlab.com - -resources: - limits: - cpu: 300m - memory: 512Mi - requests: - cpu: 300m - memory: 512Mi - -autoscaling: - enabled: false - minReplicas: 1 - maxReplicas: 100 - targetCPUUtilizationPercentage: 80 - # targetMemoryUtilizationPercentage: 80 - -nodeSelector: {} - -tolerations: [] - -affinity: {} - -application: - mode: prd From ca7fe6eacd3a9b4a2bf297f5984fccdec2e03368 Mon Sep 17 00:00:00 2001 From: choisungwook Date: Sun, 23 Jan 2022 19:29:24 +0900 Subject: [PATCH 30/38] =?UTF-8?q?prd=20=ED=99=98=EA=B2=BD=EB=B3=80?= =?UTF-8?q?=EC=88=98=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/backend-prd.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/backend-prd.yaml b/.github/workflows/backend-prd.yaml index bc4f911e..c84081a7 100644 --- a/.github/workflows/backend-prd.yaml +++ b/.github/workflows/backend-prd.yaml @@ -5,6 +5,10 @@ on: branches: - "prd" +env: + dockerimage_tag: ${{ github.sha }} + dockerimage_name: choisunguk/ciat-prd-backend:${{ github.sha }} + jobs: build: runs-on: ubuntu-latest @@ -13,10 +17,6 @@ jobs: run: working-directory: ./backend - env: - dockerimage_tag: ${{ github.sha }} - dockerimage_name: choisunguk/ciat-prd-backend:${{ github.sha }} - # 1. git submodule을 이용해서 스프링부트 프로파일 복사 # 2. 스프링부트 프로젝트 빌드 # 3. docker build From ca99fdd41ee98ed416e13e28b992ea11f1143d5f Mon Sep 17 00:00:00 2001 From: choisungwook Date: Sun, 23 Jan 2022 19:34:28 +0900 Subject: [PATCH 31/38] =?UTF-8?q?workflow=20=EC=98=88=EC=99=B8=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 --- .github/workflows/backend-dev.yaml | 4 ++++ .github/workflows/backend-prd.yaml | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/.github/workflows/backend-dev.yaml b/.github/workflows/backend-dev.yaml index 1cea98ca..933bf576 100644 --- a/.github/workflows/backend-dev.yaml +++ b/.github/workflows/backend-dev.yaml @@ -4,6 +4,10 @@ on: push: branches: - "develop" + paths-ignore: + - ".github/workflows/backend-dev-unitest.yaml" + - ".github/workflows/backend-prd.yaml" + - ".github/workflows/frontend-**" env: dockerimage_tag: ${{ github.sha }} diff --git a/.github/workflows/backend-prd.yaml b/.github/workflows/backend-prd.yaml index c84081a7..1f1e6687 100644 --- a/.github/workflows/backend-prd.yaml +++ b/.github/workflows/backend-prd.yaml @@ -4,6 +4,10 @@ on: push: branches: - "prd" + paths-ignore: + - ".github/workflows/backend-dev-unitest.yaml" + - ".github/workflows/backend-dev" + - ".github/workflows/frontend-**" env: dockerimage_tag: ${{ github.sha }} From d785012ce0eb457d63ec9a55483655b94e3b5eed Mon Sep 17 00:00:00 2001 From: choisungwook Date: Sun, 23 Jan 2022 21:07:28 +0900 Subject: [PATCH 32/38] =?UTF-8?q?prd=20=EB=B9=84=ED=99=9C=EC=84=B1?= =?UTF-8?q?=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/backend-prd.yaml | 202 ++++++++++++++--------------- 1 file changed, 101 insertions(+), 101 deletions(-) diff --git a/.github/workflows/backend-prd.yaml b/.github/workflows/backend-prd.yaml index 1f1e6687..5877bb5f 100644 --- a/.github/workflows/backend-prd.yaml +++ b/.github/workflows/backend-prd.yaml @@ -1,121 +1,121 @@ -name: backend-prd-CICD +# name: backend-prd-CICD -on: - push: - branches: - - "prd" - paths-ignore: - - ".github/workflows/backend-dev-unitest.yaml" - - ".github/workflows/backend-dev" - - ".github/workflows/frontend-**" +# on: +# push: +# branches: +# - "prd" +# paths-ignore: +# - ".github/workflows/backend-dev-unitest.yaml" +# - ".github/workflows/backend-dev" +# - ".github/workflows/frontend-**" -env: - dockerimage_tag: ${{ github.sha }} - dockerimage_name: choisunguk/ciat-prd-backend:${{ github.sha }} +# env: +# dockerimage_tag: ${{ github.sha }} +# dockerimage_name: choisunguk/ciat-prd-backend:${{ github.sha }} -jobs: - build: - runs-on: ubuntu-latest +# jobs: +# build: +# runs-on: ubuntu-latest - defaults: - run: - working-directory: ./backend +# defaults: +# run: +# working-directory: ./backend - # 1. git submodule을 이용해서 스프링부트 프로파일 복사 - # 2. 스프링부트 프로젝트 빌드 - # 3. docker build - # 4. docker push - steps: - - uses: actions/checkout@v2 - with: - ssh-key: ${{ secrets.GITHUBACTION_KEY }} - submodules: 'recursive' +# # 1. git submodule을 이용해서 스프링부트 프로파일 복사 +# # 2. 스프링부트 프로젝트 빌드 +# # 3. docker build +# # 4. docker push +# steps: +# - uses: actions/checkout@v2 +# with: +# ssh-key: ${{ secrets.GITHUBACTION_KEY }} +# submodules: 'recursive' - - name: copy springboot profile - run: | - cp ./src/main/resources/CIAT_private/springboot/application-prd.yaml ./src/main/resources/application-prd.yaml +# - name: copy springboot profile +# run: | +# cp ./src/main/resources/CIAT_private/springboot/application-prd.yaml ./src/main/resources/application-prd.yaml - - name: Set up JDK 11 - uses: actions/setup-java@v2 - with: - java-version: '11' - distribution: 'adopt' - server-id: github - settings-path: ${{ github.workspace }} +# - name: Set up JDK 11 +# uses: actions/setup-java@v2 +# with: +# java-version: '11' +# distribution: 'adopt' +# server-id: github +# settings-path: ${{ github.workspace }} - - name: gradle build - run: | - gradle clean build --exclude-task test +# - name: gradle build +# run: | +# gradle clean build --exclude-task test - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 +# - name: Set up Docker Buildx +# uses: docker/setup-buildx-action@v1 - - name: Login to DockerHub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} +# - name: Login to DockerHub +# uses: docker/login-action@v1 +# with: +# username: ${{ secrets.DOCKERHUB_USERNAME }} +# password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: copy dockerfile - run: | - rm -rf ./Dockerfile - cp ./cicd/prd/Dockerfile ./Dockerfile +# - name: copy dockerfile +# run: | +# rm -rf ./Dockerfile +# cp ./cicd/prd/Dockerfile ./Dockerfile - - name: Build and push - id: docker_build - run: | - docker build -t ${{ env.dockerimage_name }} . - docker push ${{ env.dockerimage_name }} +# - name: Build and push +# id: docker_build +# run: | +# docker build -t ${{ env.dockerimage_name }} . +# docker push ${{ env.dockerimage_name }} - - name: Discord Alert Success - uses: sarisia/actions-status-discord@v1 - if: success() - with: - webhook: ${{ secrets.DISCORD_WEBHOOK }} - description: "🎉 테스트 되었습니다!" +# - name: Discord Alert Success +# uses: sarisia/actions-status-discord@v1 +# if: success() +# with: +# webhook: ${{ secrets.DISCORD_WEBHOOK }} +# description: "🎉 테스트 되었습니다!" - - name: Discord Alert Failure - uses: sarisia/actions-status-discord@v1 - if: failure() - with: - webhook: ${{ secrets.DISCORD_WEBHOOK }} - description: "🔥 테스트를 실패하였습니다." +# - name: Discord Alert Failure +# uses: sarisia/actions-status-discord@v1 +# if: failure() +# with: +# webhook: ${{ secrets.DISCORD_WEBHOOK }} +# description: "🔥 테스트를 실패하였습니다." - - name: Cleanup Gradle Cache - # Remove some files from the Gradle cache, so they aren't cached by GitHub Actions. - # Restoring these files from a GitHub Actions cache might cause problems for future builds. - if: ${{ always() }} - run: | - rm -f ~/.gradle/caches/modules-2/modules-2.lock - rm -f ~/.gradle/caches/modules-2/gc.properties +# - name: Cleanup Gradle Cache +# # Remove some files from the Gradle cache, so they aren't cached by GitHub Actions. +# # Restoring these files from a GitHub Actions cache might cause problems for future builds. +# if: ${{ always() }} +# run: | +# rm -f ~/.gradle/caches/modules-2/modules-2.lock +# rm -f ~/.gradle/caches/modules-2/gc.properties - update-argocd-metadata: - needs: build - runs-on: ubuntu-latest +# update-argocd-metadata: +# needs: build +# runs-on: ubuntu-latest - defaults: - run: - working-directory: ./prd/backend +# defaults: +# run: +# working-directory: ./prd/backend - steps: - - uses: actions/checkout@v2 - with: - ref: "charts" - ssh-key: ${{ secrets.GITHUBACTION_KEY }} - submodules: 'recursive' +# steps: +# - uses: actions/checkout@v2 +# with: +# ref: "charts" +# ssh-key: ${{ secrets.GITHUBACTION_KEY }} +# submodules: 'recursive' - - name: change override_values.yaml - run: | - cat < override_values.yaml - image: - tag: ${{ env.dockerimage_tag }} - EOF +# - name: change override_values.yaml +# run: | +# cat < override_values.yaml +# image: +# tag: ${{ env.dockerimage_tag }} +# EOF - - name: git push - run: | - git config --global user.email "GitHub Actions Bot@github.com" - git config --global user.name "GitHub Actions Bot" - git add override_values.yaml - git commit -m "change dockertag" - git pull origin charts - git push origin charts +# - name: git push +# run: | +# git config --global user.email "GitHub Actions Bot@github.com" +# git config --global user.name "GitHub Actions Bot" +# git add override_values.yaml +# git commit -m "change dockertag" +# git pull origin charts +# git push origin charts From b1eb502888a446ed8b698e78d2fae20241bf31f7 Mon Sep 17 00:00:00 2001 From: choisungwook Date: Sun, 23 Jan 2022 21:34:53 +0900 Subject: [PATCH 33/38] =?UTF-8?q?workflow=20=EC=A3=BC=EC=84=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/backend-dev.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/backend-dev.yaml b/.github/workflows/backend-dev.yaml index 933bf576..25dce8f2 100644 --- a/.github/workflows/backend-dev.yaml +++ b/.github/workflows/backend-dev.yaml @@ -4,6 +4,7 @@ on: push: branches: - "develop" + # ignore path paths-ignore: - ".github/workflows/backend-dev-unitest.yaml" - ".github/workflows/backend-prd.yaml" From 2d8722e2c6654408e45628ab3d160ccc7b971a51 Mon Sep 17 00:00:00 2001 From: TaeheeYoon Date: Sun, 23 Jan 2022 23:03:51 +0900 Subject: [PATCH 34/38] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 132db618..3d390dd7 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,8 @@ ### 게스트 로그인🔑 ``` -id : -pw : +id : admin@ciat.com +pw : ciat1234! ``` From ab15d53af6be4152b74fd94824a22772f4e47afc Mon Sep 17 00:00:00 2001 From: choisungwook Date: Mon, 24 Jan 2022 00:25:14 +0900 Subject: [PATCH 35/38] =?UTF-8?q?=EC=9A=B4=EC=98=81=20workflow=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/backend-dev.yaml | 6 +++--- .github/workflows/backend-prd.yaml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/backend-dev.yaml b/.github/workflows/backend-dev.yaml index 25dce8f2..bfe27e17 100644 --- a/.github/workflows/backend-dev.yaml +++ b/.github/workflows/backend-dev.yaml @@ -105,9 +105,9 @@ jobs: ssh-key: ${{ secrets.GITHUBACTION_KEY }} submodules: 'recursive' - - name: change override_values.yaml + - name: change values-dev.yaml run: | - cat < override_values.yaml + cat < values-dev.yaml image: tag: ${{ env.dockerimage_tag }} EOF @@ -116,7 +116,7 @@ jobs: run: | git config --global user.email "GitHub Actions Bot@github.com" git config --global user.name "GitHub Actions Bot" - git add override_values.yaml + git add values-dev.yaml git commit -m "change dockertag" git pull origin charts git push origin charts diff --git a/.github/workflows/backend-prd.yaml b/.github/workflows/backend-prd.yaml index 5877bb5f..e76cef82 100644 --- a/.github/workflows/backend-prd.yaml +++ b/.github/workflows/backend-prd.yaml @@ -104,9 +104,9 @@ # ssh-key: ${{ secrets.GITHUBACTION_KEY }} # submodules: 'recursive' -# - name: change override_values.yaml +# - name: change values-prd.yaml # run: | -# cat < override_values.yaml +# cat < values-prd.yaml # image: # tag: ${{ env.dockerimage_tag }} # EOF @@ -115,7 +115,7 @@ # run: | # git config --global user.email "GitHub Actions Bot@github.com" # git config --global user.name "GitHub Actions Bot" -# git add override_values.yaml +# git add values-prd.yaml # git commit -m "change dockertag" # git pull origin charts # git push origin charts From 73565bacd8db4ab7d16004d6e0e116af311f7b78 Mon Sep 17 00:00:00 2001 From: choisungwook Date: Mon, 24 Jan 2022 22:14:54 +0900 Subject: [PATCH 36/38] =?UTF-8?q?=EB=AC=B8=EC=84=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 15 ++++++++++++++- backend/.gitignore | 6 ------ backend/Readme.md | 5 ++++- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 9e5b78a2..2871e117 100644 --- a/.gitignore +++ b/.gitignore @@ -44,4 +44,17 @@ frontend/dist/* frontend/build frontend/build/* frontend/*.log -frontend/package-lock.json \ No newline at end of file +frontend/package-lock.json + +# backend +# springboot profiles +application.yml +application-dev.yml +application-prd.yml +application-test.yml +# springboot profiles +application.yaml +application-dev.yaml +application-prd.yaml +application-test.yaml + diff --git a/backend/.gitignore b/backend/.gitignore index 9b3d3c24..c2065bc2 100644 --- a/backend/.gitignore +++ b/backend/.gitignore @@ -35,9 +35,3 @@ out/ ### VS Code ### .vscode/ - -# springboot profiles -application.yml -application-dev.yml -application-prd.yml -application-test.yml diff --git a/backend/Readme.md b/backend/Readme.md index 847198f6..1f357ff6 100644 --- a/backend/Readme.md +++ b/backend/Readme.md @@ -2,8 +2,11 @@ * 이 프로젝트에서 연동된 데이터베이스정보 등 등록이 필요합니다. * CIAT repo에 등록된 멤버는 git submodule에 접근정보를 얻을 수 있습니다. ```sh -git submodule update --recursive --remote --merge --force +git submodule update --init --recursive ``` + ## 스프링부트 프로파일 템플릿 * 이 템플릿은 외부사용자를 위한 설명입니다. ```yaml From ddb67bc039333009a0d0886e26aacaedfa96d3fd Mon Sep 17 00:00:00 2001 From: Im-HyeJeong Date: Mon, 24 Jan 2022 22:39:41 +0900 Subject: [PATCH 37/38] =?UTF-8?q?[FEATURE]=20E4-S10=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=EC=9E=90=EC=97=90=EA=B2=8C=204=EC=9E=90=EB=A6=AC=EC=9D=98=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=EB=B2=88=ED=98=B8=20=EB=A9=94=EC=9D=BC?= =?UTF-8?q?=EB=A1=9C=20=EC=A0=84=EB=8B=AC=20#285?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/build.gradle | 1 + .../infp/ciat/config/cors/webconfigDev.java | 4 +- .../infp/ciat/config/cors/webconfigProd.java | 3 +- .../user/controller/AccountController.java | 43 +++++++++++++++++++ .../dto/request/ResetPasswordRequestDTO.java | 17 ++++++++ .../dto/response/ResetPasswordResponse.java | 20 +++++++++ 6 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 backend/src/main/java/com/infp/ciat/user/controller/dto/request/ResetPasswordRequestDTO.java create mode 100644 backend/src/main/java/com/infp/ciat/user/controller/dto/response/ResetPasswordResponse.java diff --git a/backend/build.gradle b/backend/build.gradle index 23f1b5ee..c581b9b2 100644 --- a/backend/build.gradle +++ b/backend/build.gradle @@ -39,6 +39,7 @@ dependencies { testImplementation 'org.springframework.security:spring-security-test' implementation 'com.sun.xml.bind:jaxb1-impl:2.2.5.1' annotationProcessor "org.springframework.boot:spring-boot-configuration-processor" + implementation 'org.springframework.boot:spring-boot-starter-mail' } test { diff --git a/backend/src/main/java/com/infp/ciat/config/cors/webconfigDev.java b/backend/src/main/java/com/infp/ciat/config/cors/webconfigDev.java index 66f7e0d1..3ebf0c92 100644 --- a/backend/src/main/java/com/infp/ciat/config/cors/webconfigDev.java +++ b/backend/src/main/java/com/infp/ciat/config/cors/webconfigDev.java @@ -17,7 +17,9 @@ public void addCorsMappings(CorsRegistry registry) { "https://vuelogin.choicloudlab.com", "http://localhost:8070", "https://ciat-dev.choicloudlab.com", - "https://ciat.choicloudlab.com" + "https://ciat.choicloudlab.com", + "https://smtp.naver.com" + ) .allowedMethods("*"); } diff --git a/backend/src/main/java/com/infp/ciat/config/cors/webconfigProd.java b/backend/src/main/java/com/infp/ciat/config/cors/webconfigProd.java index aa6e8a59..345f14d8 100644 --- a/backend/src/main/java/com/infp/ciat/config/cors/webconfigProd.java +++ b/backend/src/main/java/com/infp/ciat/config/cors/webconfigProd.java @@ -17,7 +17,8 @@ public void addCorsMappings(CorsRegistry registry) { "http://localhost:8070", "https://ciat-frontend.choicloudlab.com", "https://ciat-dev.choicloudlab.com", - "https://ciat.choicloudlab.com" + "https://ciat.choicloudlab.com", + "https://smtp.naver.com" ) .allowedMethods("*"); } diff --git a/backend/src/main/java/com/infp/ciat/user/controller/AccountController.java b/backend/src/main/java/com/infp/ciat/user/controller/AccountController.java index 6d3a5eba..6f9a243f 100644 --- a/backend/src/main/java/com/infp/ciat/user/controller/AccountController.java +++ b/backend/src/main/java/com/infp/ciat/user/controller/AccountController.java @@ -1,18 +1,26 @@ package com.infp.ciat.user.controller; import com.infp.ciat.config.auth.PrincipalDetails; +import com.infp.ciat.user.controller.dto.request.ResetPasswordRequestDTO; import com.infp.ciat.user.controller.dto.request.SignupRequestDTO; import com.infp.ciat.user.controller.dto.response.LoginSuccessResponse; +import com.infp.ciat.user.controller.dto.response.ResetPasswordResponse; import com.infp.ciat.user.controller.dto.response.SignUpResponse; import com.infp.ciat.user.service.AccountService; import lombok.RequiredArgsConstructor; +import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import org.springframework.mail.javamail.JavaMailSender; +import org.springframework.mail.javamail.MimeMessageHelper; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.*; +import javax.mail.internet.MimeMessage; import javax.validation.Valid; +import java.util.Random; @RestController @RequiredArgsConstructor @@ -21,6 +29,11 @@ public class AccountController { private final AccountService accountService; + private final JavaMailSender javaMailSender; + + @Value("${spring.mail.username}") + private String fromMail; + @PostMapping("/signup") public ResponseEntity signUp(@Valid @RequestBody SignupRequestDTO requestDTO) { @@ -39,4 +52,34 @@ public ResponseEntity signUp(@Valid @RequestBody SignupRequestDT public ResponseEntity login_success(@AuthenticationPrincipal PrincipalDetails user) { return new ResponseEntity<>(new LoginSuccessResponse(user.getUsername()), HttpStatus.OK); } + + @SneakyThrows + @PostMapping("/resetPassword") + public ResponseEntity resetPassword(@RequestBody ResetPasswordRequestDTO requestDTO) { + + String toMail = requestDTO.getEmail(); + + MimeMessage mimeMessage = javaMailSender.createMimeMessage(); + MimeMessageHelper mimeMessageHelper = new MimeMessageHelper(mimeMessage, true, "UTF-8"); + mimeMessageHelper.setFrom(fromMail); + mimeMessageHelper.setTo(toMail); + mimeMessageHelper.setSubject("[ciat] 임시 비밀번호 안내"); + + Random random = new Random(); + String originCode = ""; + for (int i = 0; i < 4; i++) { + originCode += random.nextInt(10); + } + + StringBuilder body = new StringBuilder(); + + body.append("3시간 안에 코드를 입력해주세요."); + body.append("코드: " + originCode); + + mimeMessageHelper.setText(body.toString(), true); + javaMailSender.send(mimeMessage); + + return new ResponseEntity<>(new ResetPasswordResponse(toMail, originCode), HttpStatus.OK); + } + } diff --git a/backend/src/main/java/com/infp/ciat/user/controller/dto/request/ResetPasswordRequestDTO.java b/backend/src/main/java/com/infp/ciat/user/controller/dto/request/ResetPasswordRequestDTO.java new file mode 100644 index 00000000..edbcaa8c --- /dev/null +++ b/backend/src/main/java/com/infp/ciat/user/controller/dto/request/ResetPasswordRequestDTO.java @@ -0,0 +1,17 @@ +package com.infp.ciat.user.controller.dto.request; + +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@Getter +public class ResetPasswordRequestDTO { + + private String email; + + @Builder + public ResetPasswordRequestDTO(String email) { + this.email = email; + } +} diff --git a/backend/src/main/java/com/infp/ciat/user/controller/dto/response/ResetPasswordResponse.java b/backend/src/main/java/com/infp/ciat/user/controller/dto/response/ResetPasswordResponse.java new file mode 100644 index 00000000..a8608419 --- /dev/null +++ b/backend/src/main/java/com/infp/ciat/user/controller/dto/response/ResetPasswordResponse.java @@ -0,0 +1,20 @@ +package com.infp.ciat.user.controller.dto.response; + +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@Getter +public class ResetPasswordResponse { + + private String email; + + private String originCode; + + @Builder + public ResetPasswordResponse(String email, String originCode) { + this.email = email; + this.originCode = originCode; + } +} From bfc465e642ccde8c9ab8693f1df4b9cb25b8874b Mon Sep 17 00:00:00 2001 From: Im-HyeJeong Date: Mon, 24 Jan 2022 22:48:28 +0900 Subject: [PATCH 38/38] =?UTF-8?q?[FEATURE]=20E4-S10=20submodule=20commit?= =?UTF-8?q?=20id=20=EB=B3=80=EA=B2=BD=20#285?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/main/resources/CIAT_private | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/main/resources/CIAT_private b/backend/src/main/resources/CIAT_private index f7f7633b..71a3bcaa 160000 --- a/backend/src/main/resources/CIAT_private +++ b/backend/src/main/resources/CIAT_private @@ -1 +1 @@ -Subproject commit f7f7633bbb16f9406c9a0b7b04b9247af12b1fb4 +Subproject commit 71a3bcaab2cdf722326ea8e8eb10273a0f8e6ad5