Skip to content

Commit

Permalink
feat: docker+git action을 사용한 CI/CD (#33) (#68)
Browse files Browse the repository at this point in the history
docker+git action을 사용한 CI/CD (#33)
  • Loading branch information
ryulkim authored Feb 11, 2024
1 parent 6de723b commit 13ce8ea
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 0 deletions.
77 changes: 77 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# 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:
branches: [ "feature/33" ]

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
steps:

- name: checkout
uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

## create application.yml
- name: make application.yml
run: |
## create application.yml
mkdir src/main/resources
cd ./src/main/resources
# application.properties 파일 생성
touch ./application.yml
# GitHub-Actions 에서 설정한 값을 application.yml 파일에 쓰기
echo "${{ secrets.APPLICATION }}" >> ./application.yml
shell: bash

## Grant execute permission for gradlew
- name: Grant execute permission for gradlew
run: chmod +x gradlew

## gradle build
- name: Build with Gradle
run: ./gradlew bootJar


## 웹 이미지 빌드 및 도커허브에 push
- name: web docker build and push
run: |
docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_PASSWORD }}
## docker tag ${{ secrets.DOCKERHUB_USERNAME }} ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_REPO_WEB }}
docker build -t ryulkim/umc-notation-web .
docker push ryulkim/umc-notation-web
## docker compose up
- name: executing remote ssh commands using password
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ubuntu
key: ${{ secrets.KEY }}
script: |
## docker-compose.yml 파일 생성
touch ./docker-compose.yml
echo "${{secrets.COMPOSE}}" > ./docker-compose.yml
## sudo docker rm -f $(sudo docker ps -qa)
sudo docker pull ryulkim/umc-notation-web
sudo docker pull ryulkim/umc-notation-nginx
sudo docker-compose up -d
sudo docker image prune -f
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Dockerfile

# jdk17 Image Start
FROM openjdk:17

# 인자 설정 - JAR_File
ARG JAR_FILE=build/libs/*.jar

# jar 파일 복제
COPY ${JAR_FILE} app.jar

# 인자 설정 부분과 jar 파일 복제 부분 합쳐서 진행해도 무방
#COPY build/libs/*.jar app.jar

# 실행 명령어
ENTRYPOINT ["java", "-jar", "app.jar"]

0 comments on commit 13ce8ea

Please sign in to comment.