-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[YS-35] chore: CD 스크립트 및 도커 파일 추가 (#8)
* chore: add cd script * chore: add docker-compose file
- Loading branch information
Showing
3 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |