Skip to content

Commit

Permalink
[BSVR-186] s3 연결 및 운영환경 수동배포 테스트 (#105)
Browse files Browse the repository at this point in the history
* feat: s3 설정값 수정

* feat: application-ncp 환경변수 네이밍 수정

* feat: manual-prod-deploy.yaml 운영환경 수동 배포 스크립트 수정
  • Loading branch information
pminsung12 authored Aug 3, 2024
1 parent 01787da commit 54db739
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 27 deletions.
51 changes: 31 additions & 20 deletions .github/workflows/manual-prod-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
inputs:
tag:
description: 'Tag to deploy (v1.0.0)'
description: 'Tag to deploy (v0.33.8)'
required: true

jobs:
Expand All @@ -16,22 +16,33 @@ jobs:
with:
ref: ${{ github.event.inputs.tag }}

- name: Deploy to Prod NCP Server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.PROD_NCP_SERVER_HOST }}
username: ${{ secrets.PROD_NCP_SERVER_USERNAME }}
password: ${{ secrets.PROD_NCP_SERVER_PASSWORD }}
port: ${{ secrets.PROD_NCP_SERVER_PORT }}
script: |
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/spot-server:${{ github.event.inputs.tag }}
docker stop spot-server-prod || true
docker rm spot-server-prod || true
docker run -d --name spot-server-prod \
-p 8080:8080 \
-e SPRING_DATASOURCE_URL=${{ secrets.PROD_DB_URL }} \
-e SPRING_DATASOURCE_USERNAME=${{ secrets.PROD_DB_USERNAME }} \
-e SPRING_DATASOURCE_PASSWORD=${{ secrets.PROD_DB_PASSWORD }} \
-e TZ=Asia/Seoul \
${{ secrets.DOCKERHUB_USERNAME }}/spot-server:${{ github.event.inputs.tag }}
docker system prune -af
- name: Deploy to PROD - AWS EC2
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.PROD_AWS_SERVER_HOST }}
username: ${{ secrets.PROD_AWS_SERVER_USERNAME }}
password: ${{ secrets.PROD_AWS_SERVER_PASSWORD }}
port: ${{ secrets.PROD_AWS_SERVER_PORT }}
script: |
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/spot-server:prod-${{ github.sha }}
docker stop spot-server-prod || true
docker rm spot-server-prod || true
docker run -d --name spot-server-prod \
-p 8080:8080 \
-e SPRING_PROFILES_ACTIVE=prod \
-e SPRING_DATASOURCE_URL=${{ secrets.PROD_DB_URL }} \
-e SPRING_DATASOURCE_USERNAME=${{ secrets.PROD_DB_USERNAME }} \
-e SPRING_DATASOURCE_PASSWORD=${{ secrets.PROD_DB_PASSWORD }} \
-e SPRING_JWT_SECRET=${{ secrets.JWT_SECRET }} \
-e OAUTH_CLIENTID=${{ secrets.KAKAO_CLIENT_ID }} \
-e OAUTH_KAUTHTOKENURLHOST=${{ secrets.KAUTH_TOKEN_URL_HOST }} \
-e OAUTH_KAUTHUSERURLHOST=${{ secrets.KAUTH_USER_URL_HOST }} \
-e SPRING_JPA_HIBERNATE_DDL_AUTO=validate \
-e NCP_OBJECT_STORAGE_ACCESS_KEY=${{ secrets.AWS_S3_ACCESS_KEY }} \
-e NCP_OBJECT_STORAGE_SECRET_KEY=${{ secrets.AWS_S3_SECRET_KEY }} \
-e TZ=Asia/Seoul \
-e SENTRY_DSN=${{ secrets.SENTRY_DSN }} \
-e SENTRY_ENABLE_TRACING=true \
-e SENTRY_ENVIRONMENT=prod \
${{ secrets.DOCKERHUB_USERNAME }}/spot-server:prod-${{ github.sha }}
docker system prune -af
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;

Expand All @@ -19,14 +19,13 @@
public class ObjectStorageConfig {

private final ObjectStorageProperties objectStorageProperties;
private static final String ENDPOINT = "https://kr.object.ncloudstorage.com";
private static final String REGION = "kr-standard";
public static final String BUCKET_NAME = "spot-image-bucket";
private final Regions clientRegion = Regions.AP_NORTHEAST_2;
public static final String BUCKET_NAME = "spot-image-bucket-v2";

@Bean
public AmazonS3 getAmazonS3() {
return AmazonS3ClientBuilder.standard()
.withEndpointConfiguration(new EndpointConfiguration(ENDPOINT, REGION))
.withRegion(clientRegion)
.withCredentials(
new AWSStaticCredentialsProvider(
new BasicAWSCredentials(
Expand Down
5 changes: 3 additions & 2 deletions infrastructure/ncp/src/main/resources/application-ncp.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
ncp:
object-storage:
accessKey: ${NCP_OBJECT_STORAGE_ACCESS_KEY}
secretKey: ${NCP_OBJECT_STORAGE_SECRET_KEY}
# accessKey: ${NCP_OBJECT_STORAGE_ACCESS_KEY}
accessKey: ${AWS_OBJECT_STORAGE_ACCESS_KEY}
secretKey: ${AWS_OBJECT_STORAGE_SECRET_KEY}

0 comments on commit 54db739

Please sign in to comment.