-
Notifications
You must be signed in to change notification settings - Fork 3
[setting] MOA-84 백엔드 서버 오라클 클라우드로 이전 #546
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
Changes from all commits
01721c9
9f554db
5640bdf
d241ebf
0356498
b26a38d
0b0cf3a
911637e
e638d29
182e89f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,11 +1,11 @@ | ||||||||||||||||||||||||
| # .github/workflows/server_cd_develop.yml | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| name: Release Server CD | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||
| push: | ||||||||||||||||||||||||
| branches: | ||||||||||||||||||||||||
| - 'main' | ||||||||||||||||||||||||
| - 'setting/#542-oracle_cloud' | ||||||||||||||||||||||||
| paths: | ||||||||||||||||||||||||
| - 'backend/**' | ||||||||||||||||||||||||
| - '.github/workflows/**' | ||||||||||||||||||||||||
|
|
@@ -31,10 +31,12 @@ jobs: | |||||||||||||||||||||||
| uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| - name: Cache Gradle dependencies | ||||||||||||||||||||||||
| uses: actions/cache@v4 # Gradle 의존성 캐시 설정 | ||||||||||||||||||||||||
| uses: actions/cache@v4 | ||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||
| path: ~/.gradle/caches # Gradle 캐시 경로 | ||||||||||||||||||||||||
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} # Gradle 파일 해시값 기반 키 | ||||||||||||||||||||||||
| path: | | ||||||||||||||||||||||||
| ~/.gradle/caches | ||||||||||||||||||||||||
| ~/.gradle/wrapper | ||||||||||||||||||||||||
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | ||||||||||||||||||||||||
| restore-keys: | | ||||||||||||||||||||||||
| ${{ runner.os }}-gradle- | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
@@ -51,37 +53,26 @@ jobs: | |||||||||||||||||||||||
| cd backend | ||||||||||||||||||||||||
| ./gradlew clean build -x test | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| - id: 'auth' | ||||||||||||||||||||||||
| uses: 'google-github-actions/auth@v2' | ||||||||||||||||||||||||
| # Docker 인증 | ||||||||||||||||||||||||
| - name: Log in to Docker Hub | ||||||||||||||||||||||||
| uses: docker/login-action@v2 | ||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||
| credentials_json: ${{ secrets.GCE_SA_KEY }} | ||||||||||||||||||||||||
| username: ${{ secrets.SERVER_DOCKER_USERNAME }} | ||||||||||||||||||||||||
| password: ${{ secrets.SERVER_DOCKER_PASSWORD }} | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
Comment on lines
+57
to
62
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
develop 워크플로와 동일한 actionlint 오류가 발생합니다. 버전을 v3로 올려주세요. - - name: Log in to Docker Hub
- uses: docker/login-action@v2
+ - name: Log in to Docker Hub
+ uses: docker/login-action@v3📝 Committable suggestion
Suggested change
🧰 Tools🪛 actionlint (1.7.7)57-57: the runner of "docker/login-action@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue (action) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||
| # GCloud SDK 캐시 설정 | ||||||||||||||||||||||||
| - name: Cache Google Cloud SDK | ||||||||||||||||||||||||
| uses: actions/cache@v4 | ||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||
| path: ~/.cache | ||||||||||||||||||||||||
| key: gcloud-sdk-${{ runner.os }} | ||||||||||||||||||||||||
| restore-keys: | | ||||||||||||||||||||||||
| gcloud-sdk- | ||||||||||||||||||||||||
| - name: Set up Docker Buildx | ||||||||||||||||||||||||
| uses: docker/setup-buildx-action@v3 | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| # Google Cloud CLI 설정 | ||||||||||||||||||||||||
| - name: Set up Google Cloud SDK | ||||||||||||||||||||||||
| uses: google-github-actions/setup-gcloud@v2 | ||||||||||||||||||||||||
| - name: Build and Push ARM64 Docker Image | ||||||||||||||||||||||||
| uses: docker/build-push-action@v5 | ||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||
| project_id: ${{ secrets.GCE_PROJECT }} | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| # Docker 인증 | ||||||||||||||||||||||||
| - name: Authenticate Docker to Google Cloud Container Registry (GCR) | ||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||
| gcloud auth configure-docker asia-northeast3-docker.pkg.dev | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| # Docker 이미지 빌드 및 GCR 업로드 | ||||||||||||||||||||||||
| - name: Build and Push Docker Image | ||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||
| cd backend | ||||||||||||||||||||||||
| docker build -t ${{ secrets.DOCKER_IMAGE_RELEASE }}:${{ github.sha }} -t ${{ secrets.DOCKER_IMAGE_DEV }}:latest . | ||||||||||||||||||||||||
| docker push -a ${{ secrets.DOCKER_IMAGE_RELEASE }} | ||||||||||||||||||||||||
| context: ./backend | ||||||||||||||||||||||||
| file: ./backend/Dockerfile | ||||||||||||||||||||||||
| platforms: linux/arm64,linux/amd64 | ||||||||||||||||||||||||
| push: true | ||||||||||||||||||||||||
| tags: | | ||||||||||||||||||||||||
| ${{ secrets.DOCKER_IMAGE_RELEASE }}:latest | ||||||||||||||||||||||||
| ${{ secrets.DOCKER_IMAGE_RELEASE }}:${{ github.sha }} | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| deploy: | ||||||||||||||||||||||||
| name: Deploy | ||||||||||||||||||||||||
|
|
@@ -93,33 +84,21 @@ jobs: | |||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| # gcloud-setup workflow 호출 | ||||||||||||||||||||||||
| - id: 'auth' | ||||||||||||||||||||||||
| uses: 'google-github-actions/auth@v2' | ||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||
| credentials_json: ${{ secrets.GCE_SA_KEY }} | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| # Google Cloud CLI 설정 | ||||||||||||||||||||||||
| - name: Set up Google Cloud SDK | ||||||||||||||||||||||||
| uses: google-github-actions/setup-gcloud@v2 | ||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||
| project_id: ${{ secrets.GCE_PROJECT }} | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| # oracle ssh 접속 후 배포 | ||||||||||||||||||||||||
| - name: Update Container on VM | ||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||
| gcloud compute ssh ${{ secrets.GCE_INSTANCE_RELEASE }} --zone=${{ secrets.GCP_REGION }} --command=" | ||||||||||||||||||||||||
| gcloud auth configure-docker asia-northeast3-docker.pkg.dev | ||||||||||||||||||||||||
| gcloud auth activate-service-account --key-file=/home/${{ secrets.GCE_INSTANCE_USER }}/gce_sa_key.json | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| sudo usermod -aG docker $USER | ||||||||||||||||||||||||
| newgrp docker | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| docker pull ${{ secrets.DOCKER_IMAGE_RELEASE }}:latest | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| export USERNAME=${{ secrets.GCE_INSTANCE_USER }} # docker compose 파일에서 사용할 변수명 설정 | ||||||||||||||||||||||||
| export DOCKER_APP_IMAGE=${{ secrets.DOCKER_IMAGE_RELEASE }}:latest | ||||||||||||||||||||||||
| sudo chmod +x /home/${{ secrets.GCE_INSTANCE_USER }}/deploy.sh # 실행 권한 부여 | ||||||||||||||||||||||||
| sudo -E /home/${{ secrets.GCE_INSTANCE_USER }}/deploy.sh # su권한으로 환경 변수 유지 및 실행 | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| docker image prune -af | ||||||||||||||||||||||||
| docker ps -a" | ||||||||||||||||||||||||
| uses: appleboy/ssh-action@master | ||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||
| host: ${{ secrets.ORACLE_INSTANCE_RELEASE_IP }} | ||||||||||||||||||||||||
| username: ${{ secrets.ORACLE_INSTANCE_USER }} | ||||||||||||||||||||||||
| key: ${{ secrets.ORACLE_INSTANCE_RELEASE_PRIVATE_KEY }} | ||||||||||||||||||||||||
| port: ${{ secrets.ORACLE_INSTANCE_RELEASE_PORT }} | ||||||||||||||||||||||||
| script: | | ||||||||||||||||||||||||
|
Comment on lines
+89
to
+95
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion
🤖 Prompt for AI Agents |
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| docker pull ${{ secrets.DOCKER_IMAGE_RELEASE }}:latest | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| export USERNAME=${{ secrets.ORACLE_INSTANCE_USER }} | ||||||||||||||||||||||||
| export DOCKER_APP_IMAGE=${{ secrets.DOCKER_IMAGE_RELEASE }}:latest | ||||||||||||||||||||||||
| sudo chmod +x /home/${{ secrets.ORACLE_INSTANCE_USER }}/deploy.sh | ||||||||||||||||||||||||
| sudo -E /home/${{ secrets.ORACLE_INSTANCE_USER }}/deploy.sh | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| docker image prune -af | ||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,41 +1,41 @@ | ||
| package moadong.media.util; | ||
|
|
||
| import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport; | ||
| import com.google.api.client.json.jackson2.JacksonFactory; | ||
| import com.google.api.services.drive.Drive; | ||
| import com.google.api.services.drive.DriveScopes; | ||
| import com.google.auth.http.HttpCredentialsAdapter; | ||
| import com.google.auth.oauth2.GoogleCredentials; | ||
| import java.io.InputStream; | ||
| import java.util.Collections; | ||
| import org.springframework.beans.factory.annotation.Value; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
| import org.springframework.util.ResourceUtils; | ||
|
|
||
| @Configuration | ||
| public class GoogleDriveConfig { | ||
|
|
||
| @Value("${spring.cloud.gcp.credentials.location}") | ||
| private String credentialsLocation; | ||
|
|
||
| @Value("${google.application.name}") | ||
| private String applicationName; | ||
|
|
||
| @Bean | ||
| public Drive googleDriveService() throws Exception { | ||
| InputStream in = ResourceUtils.getURL(credentialsLocation).openStream(); | ||
| GoogleCredentials credentials = GoogleCredentials.fromStream(in) | ||
| .createScoped(Collections.singleton(DriveScopes.DRIVE)); | ||
|
|
||
| return new Drive.Builder( | ||
| GoogleNetHttpTransport.newTrustedTransport(), | ||
| JacksonFactory.getDefaultInstance(), | ||
| new HttpCredentialsAdapter(credentials)) | ||
| .setApplicationName(applicationName) | ||
| .build(); | ||
|
|
||
| } | ||
|
|
||
|
|
||
| } | ||
| //package moadong.media.util; | ||
| // | ||
| //import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport; | ||
| //import com.google.api.client.json.jackson2.JacksonFactory; | ||
| //import com.google.api.services.drive.Drive; | ||
| //import com.google.api.services.drive.DriveScopes; | ||
| //import com.google.auth.http.HttpCredentialsAdapter; | ||
| //import com.google.auth.oauth2.GoogleCredentials; | ||
| //import java.io.InputStream; | ||
| //import java.util.Collections; | ||
| //import org.springframework.beans.factory.annotation.Value; | ||
| //import org.springframework.context.annotation.Bean; | ||
| //import org.springframework.context.annotation.Configuration; | ||
| //import org.springframework.util.ResourceUtils; | ||
| // | ||
| //@Configuration | ||
| //public class GoogleDriveConfig { | ||
| // | ||
| // @Value("${spring.cloud.gcp.credentials.location}") | ||
| // private String credentialsLocation; | ||
| // | ||
| // @Value("${google.application.name}") | ||
| // private String applicationName; | ||
| // | ||
| // @Bean | ||
| // public Drive googleDriveService() throws Exception { | ||
| // InputStream in = ResourceUtils.getURL(credentialsLocation).openStream(); | ||
| // GoogleCredentials credentials = GoogleCredentials.fromStream(in) | ||
| // .createScoped(Collections.singleton(DriveScopes.DRIVE)); | ||
| // | ||
| // return new Drive.Builder( | ||
| // GoogleNetHttpTransport.newTrustedTransport(), | ||
| // JacksonFactory.getDefaultInstance(), | ||
| // new HttpCredentialsAdapter(credentials)) | ||
| // .setApplicationName(applicationName) | ||
| // .build(); | ||
| // | ||
| // } | ||
| // | ||
| // | ||
| //} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docker/login-action버전을 최신(v3)으로 올려야 합니다.actionlint 경고: “the runner of
docker/login-action@v2action is too old”.GH Actions 런타임과 호환성을 위해 v3로 업데이트하십시오.
📝 Committable suggestion
🧰 Tools
🪛 actionlint (1.7.7)
57-57: the runner of "docker/login-action@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
🤖 Prompt for AI Agents