Skip to content
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

feat: docker+git action을 사용한 CI/CD (#33) (#68) #69

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"]
Loading