This repository has been archived by the owner on Jul 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: https ์ ์ฉ
- Loading branch information
Eun-chan Cho
authored
Aug 2, 2023
1 parent
7c3f3ec
commit 636fb6b
Showing
8 changed files
with
140 additions
and
13 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,70 @@ | ||
name: CICD for Backend Production | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'backend/**' | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
## jdk setting | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' # https://github.com/actions/setup-java | ||
cache: gradle | ||
|
||
## gradle caching | ||
- 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 build | ||
- name: Test with Gradle | ||
run: | | ||
cd ./backend | ||
./gradlew test | ||
- name: Build with Gradle | ||
run: | | ||
cd ./backend | ||
./gradlew build -x test | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: ./backend | ||
file: ./backend/Dockerfile | ||
push: true | ||
tags: ${{ secrets.DOCKER_USERNAME }}/dong-gle-backend:latest | ||
platforms: linux/arm64 | ||
|
||
deploy: | ||
needs: build | ||
uses: ./.github/workflows/deploy-prod.yml | ||
secrets: inherit |
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,30 @@ | ||
name: Run Docker Compose Production | ||
|
||
on: | ||
workflow_call: | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
deploy: | ||
runs-on: [self-hosted,prod] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: create .env | ||
run: | | ||
touch .env | ||
echo "DOCKER_USERNAME=${{ secrets.DOCKER_USERNAME }}" >> .env | ||
echo "DB_URL=${{ secrets.DB_URL }}" >> .env | ||
echo "DB_USERNAME=${{ secrets.DB_USERNAME_PROD }}" >> .env | ||
echo "DB_PASSWORD=${{ secrets.DB_PASSWORD_PROD }}" >> .env | ||
echo "SPRING_PROFILES_ACTIVE=${{ secrets.SPRING_PROFILES_ACTIVE }}" >> .env | ||
echo "PROFILE"=${{ secrets.PROD_PROFILE }} >> .env | ||
## deploy to production | ||
- name: Deploy to prod | ||
run: | | ||
sudo docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | ||
sudo docker compose down -v | ||
sudo docker compose pull | ||
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
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
File renamed without changes.
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,33 @@ | ||
server { | ||
listen 80; | ||
client_max_body_size 0; | ||
server_name donggle.blog; | ||
server_tokens off; | ||
location / { | ||
return 301 https://$host$request_uri; | ||
} | ||
} | ||
server{ | ||
listen 443 ssl; | ||
client_max_body_size 0; | ||
server_name donggle.blog; | ||
|
||
ssl_certificate /etc/nginx/certs/certificate.crt; | ||
ssl_certificate_key /etc/nginx/certs/private.key; | ||
|
||
location /api { | ||
rewrite ^/api/(.*) /$1 break; | ||
proxy_pass http://backend:8080; | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
} | ||
location / { | ||
proxy_pass http://frontend:3000; | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
} | ||
} |
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