-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #128 from Gachon-Table/develop
v1.0.5
- Loading branch information
Showing
15 changed files
with
329 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: prod-CI | ||
|
||
on: | ||
pull_request: | ||
branches: [ "main" ] | ||
push: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
prod-ci: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# Checkout - 가상 머신에 체크아웃 | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
# JDK setting - JDK 17 설정 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'corretto' | ||
|
||
# gradle caching - 빌드 시간 향상 | ||
- name: Gradle Caching | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.gradle/caches | ||
~/.gradle/wrapper | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | ||
restore-keys: | | ||
${{ runner.os }}-gradle- | ||
# gradle build - 테스트 없이 gradle 빌드 | ||
- name: Build with Gradle | ||
run: | | ||
chmod +x gradlew | ||
./gradlew build -x test | ||
shell: bash | ||
|
||
# Set up Docker Buildx - Docker Buildx 설치 | ||
- name: Set up Docker Buildx | ||
uses: docker/[email protected] | ||
|
||
# Log in to Docker Hub - Docker Hub 로그인 | ||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.PROD_DOCKER_USERNAME }} | ||
password: ${{ secrets.PROD_DOCKER_ACCESS_TOKEN }} | ||
|
||
# Build and push Docker image - Docker image 빌드 및 푸시 | ||
- name: Build and push Docker image | ||
run: | | ||
docker build --platform linux/amd64 -t ${{ secrets.PROD_DOCKER_USERNAME }}/lupg . | ||
docker push ${{ secrets.PROD_DOCKER_USERNAME }}/lupg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM openjdk:17-jdk | ||
|
||
RUN ln -snf /usr/share/zoneinfo/Asia/Seoul /etc/localtime | ||
|
||
COPY build/libs/*.jar gachontable.jar | ||
|
||
ENTRYPOINT ["sh", "-c", "java ${JAVA_OPTS} -Dspring.profiles.active=dev -javaagent:/pinpoint-agent/pinpoint-bootstrap-2.5.3.jar -Dpinpoint.agentId=LUPG -Dpinpoint.applicationName=LUPG-Dev -jar /gachontable.jar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...ain/java/site/gachontable/gachontablebe/global/config/aurora/CustomRoutingDataSource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package site.gachontable.gachontablebe.global.config.aurora; | ||
|
||
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; | ||
import org.springframework.transaction.support.TransactionSynchronizationManager; | ||
|
||
public class CustomRoutingDataSource extends AbstractRoutingDataSource { | ||
|
||
@Override | ||
protected Object determineCurrentLookupKey() { | ||
return TransactionSynchronizationManager.isCurrentTransactionReadOnly() ? "slave" : "master"; | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
src/main/java/site/gachontable/gachontablebe/global/config/aurora/TransactionConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package site.gachontable.gachontablebe.global.config.aurora; | ||
|
||
import com.zaxxer.hikari.HikariDataSource; | ||
import java.util.HashMap; | ||
import javax.sql.DataSource; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.boot.jdbc.DataSourceBuilder; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.DependsOn; | ||
import org.springframework.context.annotation.Primary; | ||
import org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy; | ||
|
||
@Configuration | ||
public class TransactionConfig { | ||
|
||
private static final String MASTER_DATASOURCE = "masterDataSource"; | ||
private static final String SLAVE_DATASOURCE = "slaveDataSource"; | ||
|
||
@Bean(name = MASTER_DATASOURCE) | ||
@ConfigurationProperties(prefix = "spring.datasource.master.hikari") | ||
public HikariDataSource masterDataSource() { | ||
return DataSourceBuilder.create() | ||
.type(HikariDataSource.class) | ||
.build(); | ||
} | ||
|
||
@Bean(name = SLAVE_DATASOURCE) | ||
@ConfigurationProperties("spring.datasource.slave.hikari") | ||
public HikariDataSource slaveDataSource() { | ||
HikariDataSource dataSource = DataSourceBuilder.create() | ||
.type(HikariDataSource.class) | ||
.build(); | ||
dataSource.setReadOnly(true); | ||
return dataSource; | ||
} | ||
|
||
@Bean | ||
public CustomRoutingDataSource routingDataSource() { | ||
CustomRoutingDataSource routingDataSource = new CustomRoutingDataSource(); | ||
HashMap<Object, Object> dataSources = new HashMap<>(); | ||
dataSources.put("master", masterDataSource()); | ||
dataSources.put("slave", slaveDataSource()); | ||
routingDataSource.setTargetDataSources(dataSources); | ||
routingDataSource.setDefaultTargetDataSource(masterDataSource()); | ||
return routingDataSource; | ||
} | ||
|
||
@Bean | ||
@Primary | ||
@DependsOn("routingDataSource") | ||
public DataSource dataSource(CustomRoutingDataSource routingDataSource) { | ||
return new LazyConnectionDataSourceProxy(routingDataSource); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.