Skip to content

Commit

Permalink
Docker remove
Browse files Browse the repository at this point in the history
  • Loading branch information
sleeg00 committed May 21, 2024
1 parent 236f0d0 commit 2baccd0
Showing 1 changed file with 93 additions and 93 deletions.
186 changes: 93 additions & 93 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -1,94 +1,94 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
## This workflow uses actions that are not certified by GitHub.
## They are provided by a third-party and are governed by
## separate terms of service, privacy policy, and support
## documentation.
## This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
## For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
##
#name: Java CI with Gradle
#####
#on: # 이벤트 트리거
# push: #push 이벤트 발생시
# branches: #어떤 브랜치에서
# - develop
# pull_request: #pull_request 발생시
# branches: #어떤 브랜치에서
# - develop
#
#permissions: #작업에 필요한 권환₩#
# contents: read
#
#jobs: #작업을 정의
# build-docker-image:
# runs-on: ubuntu-latest # Ubunt 환경에서 작업을 실행
#
# steps: #작업 단계 정의
# - uses: actions/checkout@v3 #현재 레퍼지토리를 체크아웃
# - name: Set up JDK 11 #JDK 11 설치
# uses: actions/setup-java@v3 #JDK 11을 설치하는 액션을 사용
# with:
# java-version: '11'
# distribution: 'temurin'
#
# - name: Copy Firebase
# env:
# FIREBASE: ${{ secrets.FIREBASE }}
# FIREBASE_DIR: src/main/resources/key
# FIREBASE_DIR_FILE_NAME: just-firebase-key.json
# run: |
# mkdir -p $FIREBASE_DIR
# echo $FIREBASE | base64 --decode > $FIREBASE_DIR/$FIREBASE_DIR_FILE_NAME
#
# - name: Copy Secret
# env:
# OCCUPY_SECRET: ${{ secrets.OCCUPY_SECRET }}
# OCCUPY_SECRET_DIR: src/main/resources
# OCCUPY_SECRET_DIR_FILE_NAME: application.yml
# run: echo $OCCUPY_SECRET | base64 --decode > $OCCUPY_SECRET_DIR/$OCCUPY_SECRET_DIR_FILE_NAME
#
# - name: Build with Gradle #Gradle이용하여 빌드
# uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
# with:
# gradle-version: 7.2 #그래들 버전 7.2 사용
# arguments: clean build -x test
# # 2. Docker Registry 실행
# - name: docker registry run
# run: docker run --name private-repo -d -p 5000:5000 registry
#
# # 3. Docker 이미지 빌드
# - name: docker image build
# run: docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/just .
#
# # 4. DockerHub 로그인
# - name: docker login
# uses: docker/login-action@v2
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_PASSWORD }}
# - name: docker tag
# run: docker tag &{{ secrets.DOCKERHUB_USERNAME }}/just localhost:5000/${{ secrets.DOCKERHUB_USERNAME }}/just
# # 5. Docker Hub 이미지 푸시
# - name: docker Hub push
# run: docker push localhost:5000/${{ secrets.DOCKERHUB_USERNAME }}/just
# #
# run-docker-image-on-ec2:
# # build-docker-image (위)과정이 완료되어야 실행됩니다.
# needs: build-docker-image
# runs-on: self-hosted
#
# steps:
# - name: docker rmi
# run: docker rmi 13.209.213.191:5000/${{ secrets.DOCKERHUB_USERNAME }}/just:latest
# # 1. 최신 이미지를 풀받습니다
# - name: docker pull
# run: sudo docker pull 13.209.213.191:5000/${{ secrets.DOCKERHUB_USERNAME }}/just:latest
#
# # 2. 기존의 컨테이너를 중지시킵니다
# - name: docker stop container
# run: sudo docker stop $(sudo docker ps -q) 2>/dev/null || true
#
# # 3. 최신 이미지를 컨테이너화하여 실행시킵니다
# - name: docker run new container
# run: sudo docker run 13.209.213.191:5000/${{ secrets.DOCKERHUB_USERNAME }}/just:latest
#
#
name: Java CI with Gradle
####
on: # 이벤트 트리거
push: #push 이벤트 발생시
branches: #어떤 브랜치에서
- develop
pull_request: #pull_request 발생시
branches: #어떤 브랜치에서
- develop

permissions: #작업에 필요한 권환₩#
contents: read

jobs: #작업을 정의
build-docker-image:
runs-on: ubuntu-latest # Ubunt 환경에서 작업을 실행

steps: #작업 단계 정의
- uses: actions/checkout@v3 #현재 레퍼지토리를 체크아웃
- name: Set up JDK 11 #JDK 11 설치
uses: actions/setup-java@v3 #JDK 11을 설치하는 액션을 사용
with:
java-version: '11'
distribution: 'temurin'

- name: Copy Firebase
env:
FIREBASE: ${{ secrets.FIREBASE }}
FIREBASE_DIR: src/main/resources/key
FIREBASE_DIR_FILE_NAME: just-firebase-key.json
run: |
mkdir -p $FIREBASE_DIR
echo $FIREBASE | base64 --decode > $FIREBASE_DIR/$FIREBASE_DIR_FILE_NAME
- name: Copy Secret
env:
OCCUPY_SECRET: ${{ secrets.OCCUPY_SECRET }}
OCCUPY_SECRET_DIR: src/main/resources
OCCUPY_SECRET_DIR_FILE_NAME: application.yml
run: echo $OCCUPY_SECRET | base64 --decode > $OCCUPY_SECRET_DIR/$OCCUPY_SECRET_DIR_FILE_NAME

- name: Build with Gradle #Gradle이용하여 빌드
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
gradle-version: 7.2 #그래들 버전 7.2 사용
arguments: clean build -x test
# 2. Docker Registry 실행
- name: docker registry run
run: docker run --name private-repo -d -p 5000:5000 registry

# 3. Docker 이미지 빌드
- name: docker image build
run: docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/just .

# 4. DockerHub 로그인
- name: docker login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: docker tag
run: docker tag &{{ secrets.DOCKERHUB_USERNAME }}/just localhost:5000/${{ secrets.DOCKERHUB_USERNAME }}/just
# 5. Docker Hub 이미지 푸시
- name: docker Hub push
run: docker push localhost:5000/${{ secrets.DOCKERHUB_USERNAME }}/just
#
run-docker-image-on-ec2:
# build-docker-image (위)과정이 완료되어야 실행됩니다.
needs: build-docker-image
runs-on: self-hosted

steps:
- name: docker rmi
run: docker rmi 13.209.213.191:5000/${{ secrets.DOCKERHUB_USERNAME }}/just:latest
# 1. 최신 이미지를 풀받습니다
- name: docker pull
run: sudo docker pull 13.209.213.191:5000/${{ secrets.DOCKERHUB_USERNAME }}/just:latest

# 2. 기존의 컨테이너를 중지시킵니다
- name: docker stop container
run: sudo docker stop $(sudo docker ps -q) 2>/dev/null || true

# 3. 최신 이미지를 컨테이너화하여 실행시킵니다
- name: docker run new container
run: sudo docker run 13.209.213.191:5000/${{ secrets.DOCKERHUB_USERNAME }}/just:latest


0 comments on commit 2baccd0

Please sign in to comment.