forked from kookmin-sw/cap-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Deploy docker-compose for develop branch to test server
- Loading branch information
Showing
3 changed files
with
115 additions
and
3 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,88 @@ | ||
name: Build And Deploy for develop branch to test server | ||
|
||
on: | ||
push: | ||
branches: [ "develop" ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: "adopt" | ||
|
||
- name: Make folder resources | ||
run: | | ||
cd ./server/src/main | ||
mkdir resources | ||
cd resources | ||
- name: Make application.properties | ||
run: | | ||
cd ./server/src/main/resources | ||
touch ./application.properties | ||
echo "${{ secrets.PROPERTIES }}" > ./application.properties | ||
- name: Build with Gradle | ||
run: | | ||
cd server | ||
chmod +x ./gradlew | ||
./gradlew clean build -x test | ||
- name: Docker build & push to docker repo | ||
run: | | ||
cd server | ||
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | ||
docker build -f Dockerfile -t ${{ secrets.DOCKER_REPO }}:latest . | ||
docker push ${{ secrets.DOCKER_REPO }}:latest | ||
pull-and-deploy: | ||
needs: build-and-push | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Remove & Change Docker-compose | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.TEST_EC2_PUBLIC_IP }} | ||
username: ubuntu | ||
key: ${{ secrets.TEST_SSH_PRIVATE_KEY }} | ||
envs: GITHUB_SHA | ||
script: | | ||
if [ -f docker-compose.yml ]; then | ||
sudo rm docker-compose.yml | ||
fi | ||
echo "${{ secrets.DOCKER_COMPOSE }}" > docker-compose.yml | ||
- name: Pull Server Docker image | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.TEST_EC2_PUBLIC_IP }} | ||
username: ubuntu | ||
key: ${{ secrets.TEST_SSH_PRIVATE_KEY }} | ||
envs: GITHUB_SHA | ||
script: | | ||
sudo docker rm -f $(docker ps -qa) | ||
sudo docker pull ${{ secrets.DOCKER_REPO }}:latest | ||
sudo docker image prune -f | ||
- name: Install Docker-compose & Execute | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.TEST_EC2_PUBLIC_IP }} | ||
username: ubuntu | ||
key: ${{ secrets.TEST_SSH_PRIVATE_KEY }} | ||
envs: GITHUB_SHA | ||
script: | | ||
sudo apt-get update | ||
sudo apt-get install -y docker-compose | ||
sudo docker-compose up | ||
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 |
---|---|---|
|
@@ -24,4 +24,4 @@ services: | |
- kafka | ||
image: suhwani/capstone:latest | ||
ports: | ||
- "8080:8080" | ||
- "80:8080" |