-
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.
- Loading branch information
1 parent
a73fa03
commit 31b0e3d
Showing
3 changed files
with
100 additions
and
18 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,61 @@ | ||
name: CD | ||
|
||
on: | ||
push: | ||
branches: [ "cd" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
|
||
- name: Gradle Caching | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.gradle/caches | ||
~/.gradle/wrapper | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | ||
restore-keys: | | ||
${{ runner.os }}-gradle- | ||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
|
||
- name: Create application.yml | ||
run: | | ||
cd ./src/main/resources | ||
touch ./application.yml | ||
echo "${{ secrets.APPLICATION }}" > ./application.yml | ||
shell: bash | ||
|
||
- name: Access permission to gradle build | ||
run: chmod +x gradlew | ||
|
||
- name: Run gradle build | ||
run: ./gradlew build | ||
shell: bash | ||
|
||
- name: Build docker image build and push | ||
run: | | ||
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | ||
docker build -t ${{ secrets.DOCKER_REPOSITORY }}/${{ secrets.DOCKER_IMAGE }} . | ||
docker push ${{ secrets.DOCKER_REPOSITORY }}/${{ secrets.DOCKER_IMAGE }} | ||
- name: Pull from docker hub and deploy | ||
uses: appleboy/ssh-action@master | ||
with: | ||
username: ${{ REMOTE_USERNAME }} | ||
host: ${{ secrets.REMOTE_HOST }} | ||
key: ${{ secrets.REMOTE_KEY }} | ||
script: | | ||
cd /Backend | ||
sudo docker compose down | ||
sudo docker compose up -d |
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 |
---|---|---|
@@ -1,14 +1,46 @@ | ||
services: | ||
backend: | ||
image: ${DOCKER_BACKEND_IMAGE} | ||
environment: | ||
SPRING_DATASOURCE_URL: ${SPRING_DATASOURCE_URL} | ||
SPRING_DATASOURCE_USERNAME: ${SPRING_DATASOURCE_USERNAME} | ||
SPRING_DATASOURCE_PASSWORD: ${SPRING_DATASOURCE_PASSWORD} | ||
SPRING_DATA_REDIS_HOST: ${SPRING_DATA_REDIS_HOST} | ||
SPRING_DATA_REDIS_PORT: ${SPRING_DATA_REDIS_PORT} | ||
SPRING_DATA_REDIS_CLIENT_NAME: ${SPRING_DATA_REDIS_CLIENT_NAME} | ||
SPRING_DATA_REDIS_PASSWORD: ${SPRING_DATA_REDIS_PASSWORD} | ||
ports: | ||
- '8080:8080' | ||
depends_on: | ||
- mysql | ||
- redis | ||
networks: | ||
- db | ||
|
||
mysql: | ||
image: 'mysql:latest' | ||
environment: | ||
- 'MYSQL_DATABASE=mydatabase' | ||
- 'MYSQL_PASSWORD=secret' | ||
- 'MYSQL_ROOT_PASSWORD=verysecret' | ||
- 'MYSQL_USER=myuser' | ||
MYSQL_DATABASE: ${} | ||
MYSQL_ROOT_PASSWORD: salk1104- | ||
volumes: | ||
- mysql_data:/var/lib/mysql | ||
ports: | ||
- '3306' | ||
- '3306:3306' | ||
networks: | ||
- db | ||
|
||
redis: | ||
image: 'redis:latest' | ||
ports: | ||
- '6379' | ||
- '6379:6379' | ||
volumes: | ||
- redis_data:/usr/local/etc/redis | ||
networks: | ||
- db | ||
|
||
networks: | ||
db: | ||
|
||
volumes: | ||
mysql_data: | ||
redis_data: |
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