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

[YS-35] chore: 누락된 Dockerfile 추가 #9

Merged
merged 4 commits into from
Dec 28, 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
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
5 changes: 5 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM adoptopenjdk/openjdk17:alpine-jre
ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} dobby.jar
ENV SPRING_PROFILES_ACTIVE=dev
ENTRYPOINT ["java","-jar", "-Dspring.profiles.active=dev", "/dobby.jar"]
Loading