Skip to content

Commit

Permalink
[YS-35] chore: CD 스크립트 및 도커 파일 추가 (#8)
Browse files Browse the repository at this point in the history
* chore: add cd script

* chore: add docker-compose file
  • Loading branch information
Ji-soo708 authored Dec 28, 2024
1 parent 814b8c2 commit 9ebd7eb
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/cd-backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Java CD with Gradle and Docker

on:
push:
branches:
- dev

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: 'temurin'

- name: make application-dev.yml
run: |
cd ./src/main/resources
touch ./application-dev.yml
echo "${{ secrets.DEV_YML }}" >> ./application-dev.yml
shell: bash

- name: Grant execute permisson for gradlew
run: chmod +x gradlew

- name: Build with Gradle (without Test)
run: ./gradlew clean build -x test --stacktrace

- name: Docker Hub build & push
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -t ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }} .
docker images
docker push ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }}
- name: Deploy to Prod WAS Server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.WAS_HOST }}
username: ${{ secrets.WAS_USERNAME }}
key: ${{ secrets.WAS_KEY }}
port: ${{ secrets.WAS_SSH_PORT }}
script: |
cd /home/ubuntu/dobby-backend/
sudo docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
sudo docker rm -f $(sudo docker ps -qa)
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }}
sudo docker-compose up -d
sudo docker image prune -f
4 changes: 4 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ java {
}
}

tasks.jar {
enabled = false
}

configurations {
compileOnly {
extendsFrom(configurations.annotationProcessor.get())
Expand Down
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: '3'
services:
app:
container_name: dobby
user: "1000:1000"
image: jisoo708/dobby
expose:
- "8080"
ports: # host - container 포트 매핑
- "8080:8080"
volumes: # host 로그 디렉토리 - container 로그 디렉토리 볼륨 마운트
- ./logs:/logs

0 comments on commit 9ebd7eb

Please sign in to comment.