Skip to content

Commit

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


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

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 -p ./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@v2
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
push: true
platforms: linux/amd64
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
1 change: 1 addition & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions community/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM openjdk:17-slim

ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} app.jar

ENTRYPOINT ["java","-jar","-Duser.timezone=Asia/Seoul","/app.jar"]
4 changes: 4 additions & 0 deletions community/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ java {
sourceCompatibility = '17'
}

tasks.named('jar') {
enabled = true
}

configurations {
compileOnly {
extendsFrom annotationProcessor
Expand Down
2 changes: 1 addition & 1 deletion community/scripts/start.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

PROJECT_ROOT="/home/ubuntu/community"
JAR_FILE="$PROJECT_ROOT/blog-webapp.jar"
JAR_FILE="$PROJECT_ROOT/community-webapp.jar"

APP_LOG="$PROJECT_ROOT/application.log"
ERROR_LOG="$PROJECT_ROOT/error.log"
Expand Down

0 comments on commit 1224535

Please sign in to comment.