Update Dockerfile #3
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
name: CD | |
on: | |
push: | |
branches: [ "develop" ] | |
jobs: | |
CI: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: create secret config file | |
run: | | |
cd src/main/resources | |
echo "${{ secrets.APPLICATION }}" > ./application.yml | |
- name: Set up Docker Buildx | |
uses: docker/[email protected] | |
- name: Login to Docker Hub | |
uses: docker/[email protected] | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.REPONAME }} | |
CD: | |
needs: [CI] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Docker Image Pull and Container Run | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SERVER_HOST }} | |
username: ${{ secrets.USERNAME }} | |
key: ${{ secrets.SERVER_KEY }} | |
script: | | |
docker stop my-was | |
docker rm my-was | |
docker image rm ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.REPONAME }} | |
docker run -d -p 8080:8080 \ | |
-v /root/my-proj/resources:/app/resources \ | |
--name my-was ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.REPONAME }} | |