Skip to content

fix: 추천 콘텐츠 DB 저장 로직 추가 #21

fix: 추천 콘텐츠 DB 저장 로직 추가

fix: 추천 콘텐츠 DB 저장 로직 추가 #21

Workflow file for this run

name: Dockerizing to Amazon EC2 for Dev
on:
push:
branches: [ "develop" ]
jobs:
deploy_job:
runs-on: ubuntu-latest
steps:
# 레포지토리 체크아웃
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
token: ${{ secrets.ACTION_TOKEN }}
- name: Update submodule
run: |
git submodule update --remote --recursive
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
# 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-
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew clean build
- name: Install wget
run: sudo apt-get update && sudo apt-get install -y wget
# wget으로 dd-java-agent.jar 다운로드
- name: Download Datadog Java Agent
run: wget -O dd-java-agent.jar 'https://dtdg.co/latest-java-tracer'
# Docker 이미지를 빌드할 준비
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# DockerHub에 로그인
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Develop에 Docker 이미지를 build, push
- name: Build and push Docker image to develop
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/antifragile-dev:latest
build-args: |
SPRING_PROFILES_ACTIVE=develop
# docker-compose 파일을 EC2로 복사
- name: Copy docker-compose file to EC2
uses: appleboy/scp-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_SSH_KEY }}
source: 'docker-compose.dev.yml'
target: '/home/ubuntu'
# EC2 인스턴스에 SSH로 접속하여 Docker 컨테이너를 업데이트하고 실행
- name: Deploy to EC2 (develop)
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_SSH_KEY }}
script: |
cd /home/ubuntu
DOCKER_USERNAME=${{ secrets.DOCKER_USERNAME }} docker-compose -f docker-compose.dev.yml pull
DOCKER_USERNAME=${{ secrets.DOCKER_USERNAME }} docker-compose -f docker-compose.dev.yml down
DOCKER_USERNAME=${{ secrets.DOCKER_USERNAME }} docker-compose -f docker-compose.dev.yml up -d