Skip to content

fix: add image url in get cart #15

fix: add image url in get cart

fix: add image url in get cart #15

Workflow file for this run

name: Java CI with Gradle
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build-docker-image:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
# 깃허브 레포지토리의 코드를 체크아웃
- uses: actions/checkout@v4
# JDK 17 설치
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
# application-prod.yml 파일 생성 및 내용 추가
- name: Make application-prod.yml
run: |
cd ./src/main/resources
touch application-prod.yml
echo "${{ secrets.PROPERTIES_PROD }}" > application-prod.yml
shell: bash
# application-oauth.yml 파일 생성 및 내용 추가
- name: Make application-auth.yml
run: |
cd ./src/main/resources
touch application-auth.yml
echo "${{ secrets.PROPERTIES_OAUTH }}" > application-auth.yml
shell: bash
# Gradle 설정
- name: Setup Gradle
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
# gradlew 파일에 실행 권한 부여
- name: Grant execute permission for gradlew
run: chmod +x gradlew
# Spring Boot 어플리케이션을 Gradle로 빌드
- name: Build with Gradle Wrapper
run: ./gradlew build
# Docker 이미지 빌드
- name: docker image build
run: docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/eco .
# DockerHub 로그인 (이미지 푸시를 위해)
- name: docker login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PW }}
# DockerHub로 이미지 푸시
- name: Docker Hub push
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/eco
# 위 과정에서 푸시한 이미지를 EC2에서 받아서 실행
run-docker-image-on-ec2:
needs: build-docker-image
runs-on: self-hosted
steps:
# DockerHub에서 이미지 pull
- name: docker pull
run : sudo docker pull ${{ secrets.DOCKERHUB_USERNAME }}/eco
# 기존에 실행 중인 컨테이너 중지
- name: docker stop container
run: |
if [ $(sudo docker ps -a -q -f name=eco) ]; then
sudo docker stop eco
fi
# 오래된 Docker 이미지 삭제
- name: delete old docker image
run: sudo docker system prune -f
# 새 컨테이너 실행
- name: docker run new container
run: sudo docker run --rm -it -d -p 8092:8092 --name eco ${{ secrets.DOCKERHUB_USERNAME }}/eco