diff --git a/.github/workflows/backend-ci-cd-dev.yml b/.github/workflows/backend-ci-cd-dev.yml
index fdf967544..58b86db55 100644
--- a/.github/workflows/backend-ci-cd-dev.yml
+++ b/.github/workflows/backend-ci-cd-dev.yml
@@ -25,6 +25,16 @@ jobs:
java-version: '17'
distribution: 'temurin'
+ - name: Cache Gradle packages
+ uses: actions/cache@v3
+ with:
+ path: |
+ ~/.gradle/caches
+ ~/.gradle/wrapper
+ key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
+ restore-keys: |
+ gradle-${{ runner.os }}-
+
- name: Grant execute permission for gradlew
run: chmod +x gradlew
@@ -58,16 +68,9 @@ jobs:
sudo docker login --username ${{ secrets.DOCKERHUB_DEPLOY_USERNAME }} --password ${{ secrets.DOCKERHUB_DEPLOY_TOKEN }}
sudo docker pull staccato/staccato:dev
- - name: Stop and remove existing container
- run: |
- sudo docker stop staccato-backend-app || true
- sudo docker rm staccato-backend-app || true
+ - name: Docker Compose up
+ run: sudo docker-compose -f /home/ubuntu/staccato/docker-compose.yml up -d
- - name: Docker run
- run: |
- sudo docker run --env-file /home/ubuntu/staccato/.env \
- -v /home/ubuntu/staccato/logs:/logs \
- -p 8080:8080 \
- -d --name staccato-backend-app staccato/staccato:dev
- sudo docker image prune -af
+ - name: Docker image Prune
+ run: sudo docker image prune -af
diff --git a/.github/workflows/backend-ci-cd-prod.yml b/.github/workflows/backend-ci-cd-prod.yml
index b283cfbff..f5b76e656 100644
--- a/.github/workflows/backend-ci-cd-prod.yml
+++ b/.github/workflows/backend-ci-cd-prod.yml
@@ -25,6 +25,16 @@ jobs:
java-version: '17'
distribution: 'temurin'
+ - name: Cache Gradle packages
+ uses: actions/cache@v3
+ with:
+ path: |
+ ~/.gradle/caches
+ ~/.gradle/wrapper
+ key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
+ restore-keys: |
+ gradle-${{ runner.os }}-
+
- name: Grant execute permission for gradlew
run: chmod +x gradlew
diff --git a/.github/workflows/backend-ci.yml b/.github/workflows/backend-ci.yml
index 44e07d7b6..83919e39f 100644
--- a/.github/workflows/backend-ci.yml
+++ b/.github/workflows/backend-ci.yml
@@ -25,6 +25,16 @@ jobs:
java-version: '17'
distribution: 'temurin'
+ - name: Cache Gradle packages
+ uses: actions/cache@v3
+ with:
+ path: |
+ ~/.gradle/caches
+ ~/.gradle/wrapper
+ key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
+ restore-keys: |
+ gradle-${{ runner.os }}-
+
- name: Grant execute permission for gradlew
run: chmod +x gradlew
diff --git a/backend/src/main/java/com/staccato/image/infrastructure/S3ObjectClient.java b/backend/src/main/java/com/staccato/image/infrastructure/S3ObjectClient.java
index ded00e41b..80016fd36 100644
--- a/backend/src/main/java/com/staccato/image/infrastructure/S3ObjectClient.java
+++ b/backend/src/main/java/com/staccato/image/infrastructure/S3ObjectClient.java
@@ -2,8 +2,8 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
-
-import software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider;
+import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
+import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
import software.amazon.awssdk.core.sync.RequestBody;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.s3.S3Client;
@@ -20,11 +20,14 @@ public class S3ObjectClient {
public S3ObjectClient(
@Value("${cloud.aws.s3.bucket}") String bucketName,
@Value("${cloud.aws.s3.endpoint}") String endPoint,
- @Value("${cloud.aws.cloudfront.endpoint}") String cloudFrontEndPoint
+ @Value("${cloud.aws.cloudfront.endpoint}") String cloudFrontEndPoint,
+ @Value("${cloud.aws.access-key}") String accessKey,
+ @Value("${cloud.aws.secret-access-key}") String secretAccessKey
) {
- this.s3Client = software.amazon.awssdk.services.s3.S3Client.builder()
+ AwsBasicCredentials awsCredentials = AwsBasicCredentials.create(accessKey, secretAccessKey);
+ this.s3Client = S3Client.builder()
+ .credentialsProvider(StaticCredentialsProvider.create(awsCredentials))
.region(Region.AP_NORTHEAST_2)
- .credentialsProvider(InstanceProfileCredentialsProvider.create())
.build();
this.bucketName = bucketName;
this.endPoint = endPoint;
diff --git a/backend/src/main/java/com/staccato/image/service/ImageService.java b/backend/src/main/java/com/staccato/image/service/ImageService.java
index 2a7209a75..a64d5286d 100644
--- a/backend/src/main/java/com/staccato/image/service/ImageService.java
+++ b/backend/src/main/java/com/staccato/image/service/ImageService.java
@@ -16,14 +16,13 @@
@Service
@RequiredArgsConstructor
public class ImageService {
- private static final String TEAM_FOLDER_NAME = "staccato/";
private final S3ObjectClient s3ObjectClient;
@Value("${image.folder.name}")
private String imageFolderName;
public ImageUrlResponse uploadImage(MultipartFile image) {
String imageExtension = getImageExtension(image);
- String key = TEAM_FOLDER_NAME + imageFolderName + UUID.randomUUID() + imageExtension;
+ String key = imageFolderName + UUID.randomUUID() + imageExtension;
String contentType = ImageExtension.getContentType(imageExtension);
byte[] imageBytes = getImageBytes(image);
diff --git a/backend/src/main/resources/application-dev.yml b/backend/src/main/resources/application-dev.yml
index 02d1a0aff..2e1b3563b 100644
--- a/backend/src/main/resources/application-dev.yml
+++ b/backend/src/main/resources/application-dev.yml
@@ -43,18 +43,20 @@ security:
token: ${ADMIN_TOKEN}
cloud:
aws:
+ access-key: ${AWS_ACCESS_KEY}
+ secret-access-key: ${AWS_SECRET_ACCESS_KEY}
s3:
- bucket: techcourse-project-2024
- endpoint: https://techcourse-project-2024.s3.ap-northeast-2.amazonaws.com
+ bucket: ${AWS_S3_BUCKET}
+ endpoint: ${AWS_S3_ENDPOINT}
cloudfront:
- endpoint: https://d25aribbn0gp8k.cloudfront.net
+ endpoint: ${AWS_CLOUDFRONT_ENDPOINT}
region:
- static: ap-northeast-2
+ static: ${AWS_REGION_STATIC}
stack:
auto: false
image:
folder:
- name: image/
+ name: dev/
management:
server:
diff --git a/backend/src/main/resources/application-local.yml b/backend/src/main/resources/application-local.yml
index 7659cd292..1017d734e 100644
--- a/backend/src/main/resources/application-local.yml
+++ b/backend/src/main/resources/application-local.yml
@@ -39,18 +39,20 @@ security:
token: ${ADMIN_TOKEN}
cloud:
aws:
+ access-key: accessKey
+ secret-access-key: secretAccessKey
s3:
- bucket: techcourse-project-2024
- endpoint: https://techcourse-project-2024.s3.ap-northeast-2.amazonaws.com
+ bucket: bucket
+ endpoint: endpoint
cloudfront:
- endpoint: https://d25aribbn0gp8k.cloudfront.net
+ endpoint: endpoint
region:
- static: ap-northeast-2
+ static: static
stack:
auto: false
image:
folder:
- name: image/
+ name: local/
management:
server:
diff --git a/backend/src/main/resources/application-prod.yml b/backend/src/main/resources/application-prod.yml
index c9d30ce97..bf05843d5 100644
--- a/backend/src/main/resources/application-prod.yml
+++ b/backend/src/main/resources/application-prod.yml
@@ -65,6 +65,8 @@ security:
token: ${ADMIN_TOKEN}
cloud:
aws:
+ access-key: ${AWS_ACCESS_KEY}
+ secret-access-key: ${AWS_SECRET_ACCESS_KEY}
s3:
bucket: ${AWS_S3_BUCKET}
endpoint: ${AWS_S3_ENDPOINT}
@@ -76,7 +78,7 @@ cloud:
auto: false
image:
folder:
- name: image-prod/
+ name: prod/
management:
server:
diff --git a/backend/src/main/resources/error-appender.xml b/backend/src/main/resources/error-appender.xml
index ff8f75fac..01044b0e8 100644
--- a/backend/src/main/resources/error-appender.xml
+++ b/backend/src/main/resources/error-appender.xml
@@ -11,7 +11,7 @@
[%d{yyyy-MM-dd HH:mm:ss}:%-3relative] [%thread] [request_id=%X{request_id:-startup}] %-5level [%C.%M.-%L] - %msg%n
- ./backup/error/error-%d{yyyy-MM-dd}.%i.log
+ ./logs/error/error-%d{yyyy-MM-dd}.%i.log
10MB
15
3GB
diff --git a/backend/src/main/resources/info-appender.xml b/backend/src/main/resources/info-appender.xml
index da27ad381..7fe9243bf 100644
--- a/backend/src/main/resources/info-appender.xml
+++ b/backend/src/main/resources/info-appender.xml
@@ -11,7 +11,7 @@
[%d{yyyy-MM-dd HH:mm:ss}:%-3relative] [%thread] [request_id=%X{request_id:-startup}] %-5level - %msg%n
- ./backup/info/info-%d{yyyy-MM-dd}.%i.log
+ ./logs/info/info-%d{yyyy-MM-dd}.%i.log
10MB
15
3GB
diff --git a/backend/src/main/resources/logback-spring.xml b/backend/src/main/resources/logback-spring.xml
index 15bebbc77..c67155e94 100644
--- a/backend/src/main/resources/logback-spring.xml
+++ b/backend/src/main/resources/logback-spring.xml
@@ -18,18 +18,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/backend/src/main/resources/warn-appender.xml b/backend/src/main/resources/warn-appender.xml
index 7abeb8b76..b8556bf32 100644
--- a/backend/src/main/resources/warn-appender.xml
+++ b/backend/src/main/resources/warn-appender.xml
@@ -11,7 +11,7 @@
[%d{yyyy-MM-dd HH:mm:ss}:%-3relative] [%thread] [request_id=%X{request_id:-startup}] %-5level [%C.%M.-%L] - %msg%n
- ./backup/warn/warn-%d{yyyy-MM-dd}.%i.log
+ ./logs/warn/warn-%d{yyyy-MM-dd}.%i.log
10MB
15
3GB
diff --git a/backend/src/test/java/com/staccato/image/infrastructure/FakeS3ObjectClient.java b/backend/src/test/java/com/staccato/image/infrastructure/FakeS3ObjectClient.java
index eaf25dd35..f570069a6 100644
--- a/backend/src/test/java/com/staccato/image/infrastructure/FakeS3ObjectClient.java
+++ b/backend/src/test/java/com/staccato/image/infrastructure/FakeS3ObjectClient.java
@@ -2,7 +2,7 @@
public class FakeS3ObjectClient extends S3ObjectClient {
public FakeS3ObjectClient() {
- super("fakeBuket", "fakeEndPoint", "fakeCloudFrontEndPoint");
+ super("fakeBuket", "fakeEndPoint", "fakeCloudFrontEndPoint", "fakeAccessKey", "fakeSecretAccessKey");
}
@Override