Skip to content

Commit

Permalink
Fix: dockerFile, github action 코드 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
mjttong committed Aug 27, 2024
1 parent 711c37b commit 2e802aa
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
echo "docker pull $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> scripts/deploy.sh
echo "docker stop csbroker-api || true" >> scripts/deploy.sh
echo "docker rm csbroker-api || true" >> scripts/deploy.sh
echo "docker run -p 8080:8080 -e SPRING_PROFILES_ACTIVE=dev -d --restart always --name csbroker-api $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> scripts/deploy.sh
echo "docker run -p 8080:8080 -e SPRING_CONFIG_LOCATION=/config/application.yml -v /local/path/to/config:/config -e SPRING_PROFILES_ACTIVE=dev -d --restart always --name csbroker-api $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> scripts/deploy.sh
- name: Upload to S3
env:
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM openjdk:17-jdk
ARG JAR_FILE=./build/libs/*-SNAPSHOT.jar
COPY ${JAR_FILE} app.jar
COPY ./src/main/resources/application.yml /config/application.yml
ENTRYPOINT ["java", "-jar", "/app.jar"]
31 changes: 26 additions & 5 deletions src/main/java/acc/hotsix/file_share/global/config/S3Config.java
Original file line number Diff line number Diff line change
@@ -1,29 +1,50 @@
package acc.hotsix.file_share.global.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider;
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
import software.amazon.awssdk.auth.credentials.AwsCredentials;
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.services.s3.presigner.S3Presigner;

@Configuration
public class S3Config {

@Value("${cloud.aws.credentials.access-key}")
private String accessKey;

@Value("${cloud.aws.credentials.secret-key}")
private String secretKey;

@Value("${cloud.aws.region.static}")
private String region;

// access, secret key 이용해 aws 자격증명 제공
@Bean
public AwsCredentialsProvider awsCredentialsProvider() {
AwsCredentials awsCredentials = AwsBasicCredentials.create(accessKey, secretKey);
return StaticCredentialsProvider.create(awsCredentials);
}

// s3서비스를 이용하기 위한 S3Client 객체 생성
@Bean
public S3Client s3Client() {
return S3Client.builder()
.region(Region.AP_NORTHEAST_2)
.credentialsProvider(DefaultCredentialsProvider.create())
.region(Region.of(region))
.credentialsProvider(awsCredentialsProvider())
.build();
}

// presignedURL 을 적용하기 위한 S3Presigner 객체 생성
@Bean
public S3Presigner s3Presigner() {
return S3Presigner.builder()
.region(Region.AP_NORTHEAST_2)
.credentialsProvider(DefaultCredentialsProvider.create())
.region(Region.of(region))
.credentialsProvider(awsCredentialsProvider())
.build();
}
}

0 comments on commit 2e802aa

Please sign in to comment.