Skip to content

Commit

Permalink
[정유진] 11주차 과제 제출 (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
xyzwv authored Sep 24, 2024
2 parents 20b230f + 86e788e commit 7407314
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 24 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@

name: CD/CI with Docker

on:
push:
branches: ["member/yujinjeo", "main"]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

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

- name: Make application.yml
run: |
mkdir ./community/src/main/resources
cd ./community/src/main/resources
touch ./application.yml
echo "${{ secrets.APPLICATION }}" > ./application.yml
- 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: Build with Gradle
run: |
cd ./community
chmod +x ./gradlew
./gradlew build -x test
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Docker build & push
uses: docker/build-push-action@v2
with:
context: ./community
file: ./community/Dockerfile
platforms: linux/amd64
push: true
tags: ${{ secrets.DOCKER_REPO }}:latest

- name: Deploy to Server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
envs: GITHUB_SHA
script: |
sudo docker rm -f $(sudo docker ps -qa)
sudo docker pull ${{ secrets.DOCKER_REPO }}:latest
sudo docker run -d -p 8080:8080 ${{ secrets.DOCKER_REPO }}:latest
sudo docker image prune -f
4 changes: 4 additions & 0 deletions community/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM openjdk:17-jdk
ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-Dspring.profiles.active=docker", "-jar", "app.jar"]
24 changes: 0 additions & 24 deletions community/src/main/resources/application.yml

This file was deleted.

0 comments on commit 7407314

Please sign in to comment.