Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[refactor] dev 환경이 사라짐에 따른 코드, 설정, ci/cd 수정 #501

Merged
merged 10 commits into from
Apr 5, 2024
Merged
104 changes: 0 additions & 104 deletions .github/workflows/cd-dev.yml

This file was deleted.

53 changes: 7 additions & 46 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,68 +14,29 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

# - run: touch ./domain-mysql/src/main/resources/application.yml
- run: echo "${{ secrets.APPLICATION }}" > ./domain-mysql/src/main/resources/application.yml
- uses: actions/upload-artifact@v2
with:
name: application.yml
path: ./domain-mysql/src/main/resources/application.yml

- run: echo "${{ secrets.MEMBER_APPLICATION }}" > ./member-api/src/main/resources/application.yml
- uses: actions/upload-artifact@v2
- name: Checkout
uses: actions/checkout@v3
with:
name: application.yml
path: ./member-api/src/main/resources/application.yml
ref: ${{ github.event.pull_request.head.sha }}

- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'temurin'

# - name: Set up member-api application.yml
# uses: microsoft/variable-substitution@v1
# with:
# files: ./member-api/src/main/resources/application.yml
# env:
# spring.datasource.url: ${{ secrets.LOCAL_DB_URL }}
# spring.datasource.username: ${{ secrets.LOCAL_DB_HOST }}
# spring.datasource.password: ${{ secrets.LOCAL_DB_PASSWORD }}
# spring.redis.host: ${{ secrets.REDIS_HOST }}
# spring.redis.port: ${{ secrets.REDIS_PORT }}
# spring.data.mongodb.uri: ${{ secrets.MONGO_URI }}
# spring.security.jwt.secret: ${{ secrets.JWT_SECRET_KEY }}
# cloud.aws.s3.bucket: ${{ secrets.S3_BUCKET_NAME }}
# cloud.aws.region.static: ${{ secrets.S3_REGION }}
# cloud.aws.credentials.accessKey: ${{ secrets.AWS_ACCESS_KEY }}
# cloud.aws.credentials.secretKey: ${{ secrets.AWS_ACCESS_SECRET }}
# kafka.url: ${{ secrets.KAFKA_URL }}
# custom.domain.image.baseUrl: ${{ secrets.BASE_URL }}
# chatgpt.rest-api-key: ${{ secrets.CHAT_GPT_API_KEY }}

# - name: Set up domain-mysql application.yml
# uses: microsoft/variable-substitution@v1
# with:
# files: ./domain-mysql/src/main/resources/application.yml
# env:
# spring.datasource.url: ${{ secrets.LOCAL_DB_URL }}
# spring.datasource.username: ${{ secrets.LOCAL_DB_HOST }}
# spring.datasource.password: ${{ secrets.LOCAL_DB_PASSWORD }}

- name: Set up domain-mongodb application.yml
- name: Set up member-api application-common.yml
uses: microsoft/variable-substitution@v1
with:
files: ./domain-mongodb/src/main/resources/application.yml
files: ./member-api/src/main/resources/application-common.yml
env:
spring.data.mongodb.uri: ${{ secrets.MONGO_URI }}
jasypt.password: ${{ secrets.JASYPT_PASSWORD }}

- name: Build member-api with Gradle
run : |
cd member-api
chmod +x ./gradlew
./gradlew clean build
./gradlew build
Comment on lines -78 to +39
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

혹시 왜 바꾸신지 궁금하신 분들을 위한 주석
요약하면, ./gradlew clean build는 이전 빌드의 영향을 받지 않는 깨끗한 상태에서 프로젝트를 빌드하고자 할 때 사용하며, ./gradlew build는 빠른 빌드 시간을 위해 이전 빌드의 결과물을 재사용하고자 할 때 사용

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이전 빌드 결과물이 없어서요


- name: Login to DockerHub
uses: docker/login-action@v1
Expand Down
47 changes: 28 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,40 @@ jobs:
java-version: '21'
distribution: 'temurin'

- name: Set up DataHub with Docker
run: |
echo "${{ secrets.CI_DOCKER_COMPOSE }}" > docker-compose.yml
docker-compose up -d
docker ps

- name: Test domain-mysql with Gradle
run: |
cd domain-mysql
chmod +x ./gradlew
./gradlew test

- name: Set up domain-mongodb test application.yml
uses: microsoft/variable-substitution@v1
with:
files: ./domain-mongodb/src/test/resources/application.yml
env:
spring.data.mongodb.uri: ${{ secrets.MONGO_TEST_URI }}
jasypt.password: ${{ secrets.JASYPT_PASSWORD }}

- name: Test domain-mongodb with Gradle
run: |
cd domain-mongodb
chmod +x ./gradlew
./gradlew test

- name: Set up member-api test application.yml
- name: Set up member-api application-common.yml
uses: microsoft/variable-substitution@v1
with:
files: ./member-api/src/test/resources/application.yml
files: ./member-api/src/main/resources/application-common.yml
env:
spring.datasource.url: ${{ secrets.TEST_DB_URL }}
spring.datasource.username: ${{ secrets.TEST_DB_HOST }}
spring.datasource.password: ${{ secrets.TEST_DB_PASSWORD }}
spring.security.jwt.secret: ${{ secrets.JWT_SECRET_KEY }}
spring.data.mongodb.uri: ${{ secrets.MONGO_TEST_URI }}
custom.domain.image.baseUrl: ${{ secrets.BASE_URL }}
cloud.aws.s3.bucket: ${{ secrets.S3_BUCKET_NAME }}
cloud.aws.region.static: ${{ secrets.S3_REGION }}
cloud.aws.credentials.accessKey: ${{ secrets.AWS_ACCESS_KEY }}
cloud.aws.credentials.secretKey: ${{ secrets.AWS_ACCESS_SECRET }}

- name: Run chmod to make gradlew executable
run: chmod +x ./gradlew

- name: Test with Gradle
run: ./gradlew test
jasypt.password: ${{ secrets.JASYPT_PASSWORD }}

- name: Build member-api with Gradle
run: |
cd member-api
chmod +x ./gradlew
./gradlew build
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ member-api/logs/**

member-api/member-api/logs/**

member-api/src/main/resources/application-local.yml

core/src/test/java/com/kernelsqaure/core/config/JasyptConfigTest.java

### STS ###
.apt_generated
.classpath
Expand Down
6 changes: 6 additions & 0 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ dependencies {
//Monitoring
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'io.micrometer:micrometer-registry-prometheus'

//jasypt
implementation 'com.github.ulisesbocchio:jasypt-spring-boot-starter:3.0.5'

//Test
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

tasks.named('test') {
Expand Down
23 changes: 0 additions & 23 deletions core/src/main/java/com/kernelsquare/core/compose/Kafka.yml

This file was deleted.

13 changes: 0 additions & 13 deletions core/src/main/java/com/kernelsquare/core/compose/MongoDB.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.kernelsquare.core.config;

import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties;
import org.jasypt.encryption.StringEncryptor;
import org.jasypt.encryption.pbe.PooledPBEStringEncryptor;
import org.jasypt.encryption.pbe.config.SimpleStringPBEConfig;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableEncryptableProperties
public class JasyptConfig {
@Value("${jasypt.password}")
private String password;

@Bean("jasyptEncryptorAES")
public StringEncryptor stringEncryptor() {
PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
SimpleStringPBEConfig config = new SimpleStringPBEConfig();
config.setPassword(password);
config.setAlgorithm("PBEWITHHMACSHA512ANDAES_256"); // 알고리즘
config.setKeyObtentionIterations("1000"); // 반복할 해싱 횟수
config.setPoolSize("1"); // 인스턴스 pool
config.setProviderName("SunJCE"); // 기본 암호화 제공자
config.setSaltGeneratorClassName("org.jasypt.salt.RandomSaltGenerator"); // 기본 salt 생성 클래스
config.setIvGeneratorClassName("org.jasypt.iv.RandomIvGenerator"); // 랜덤 초기화 벡터
config.setStringOutputType("base64"); //인코딩 방식
encryptor.setConfig(config);
return encryptor;
}
}
1 change: 0 additions & 1 deletion core/src/main/resources/application.properties

This file was deleted.

3 changes: 3 additions & 0 deletions domain-mongodb/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ dependencies {
//mongodb
implementation 'org.springframework.boot:spring-boot-starter-data-mongodb'

//jasypt
implementation 'com.github.ulisesbocchio:jasypt-spring-boot-starter:3.0.5'

//Test
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
Expand Down
4 changes: 0 additions & 4 deletions domain-mongodb/src/main/resources/application.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.kernelsquare.domainmongodb.common.config;

import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties;
import org.jasypt.encryption.StringEncryptor;
import org.jasypt.encryption.pbe.PooledPBEStringEncryptor;
import org.jasypt.encryption.pbe.config.SimpleStringPBEConfig;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.context.annotation.Bean;

@TestConfiguration
@EnableEncryptableProperties
public class TestJasyptConfig {
@Value("${jasypt.password}")
private String password;

@Bean("jasyptEncryptorAES")
public StringEncryptor stringEncryptor() {
PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
SimpleStringPBEConfig config = new SimpleStringPBEConfig();
config.setPassword(password);
config.setAlgorithm("PBEWITHHMACSHA512ANDAES_256"); // 알고리즘
config.setKeyObtentionIterations("1000"); // 반복할 해싱 횟수
config.setPoolSize("1"); // 인스턴스 pool
config.setProviderName("SunJCE"); // 기본 암호화 제공자
config.setSaltGeneratorClassName("org.jasypt.salt.RandomSaltGenerator"); // 기본 salt 생성 클래스
config.setIvGeneratorClassName("org.jasypt.iv.RandomIvGenerator"); // 랜덤 초기화 벡터
config.setStringOutputType("base64"); //인코딩 방식
encryptor.setConfig(config);
return encryptor;
}
}
Loading
Loading