-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[BE/feat] AI 서버 분리로 인한 MariaDB 서버 구축 및 EC2 사양 변경
- Loading branch information
Showing
10 changed files
with
296 additions
and
8 deletions.
There are no files selected for viewing
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,109 @@ | ||
name: testAndDeploy | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- release | ||
- main | ||
types: | ||
- closed | ||
|
||
defaults: | ||
run: | ||
working-directory: ./BE/exceed | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-22.04 | ||
permissions: | ||
contents: read | ||
pull-requests: write | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
|
||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
|
||
- name: Cache Gradle | ||
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: Build with Gradle Wrapper | ||
run: ./gradlew build | ||
|
||
- name: Jacoco Report to PR | ||
id: jacoco | ||
uses: madrapps/[email protected] | ||
with: | ||
paths: ${{ github.workspace }}/**/build/reports/jacoco/test/jacocoTestReport.xml | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Send docker-compose.yml | ||
uses: appleboy/scp-action@master | ||
with: | ||
host: ${{ secrets.SSH_HOST }} | ||
username: ${{ secrets.SSH_USERNAME }} | ||
key: ${{ secrets.SSH_KEY }} | ||
source: ./BE/exceed/docker-compose-prod.yml | ||
target: /home/ubuntu/backend-deploy | ||
|
||
- name: Send resources-develop-environment | ||
uses: appleboy/scp-action@master | ||
with: | ||
host: ${{ secrets.SSH_HOST }} | ||
username: ${{ secrets.SSH_USERNAME }} | ||
key: ${{ secrets.SSH_KEY }} | ||
source: ./BE/exceed/resources/gaebaljip-prod-environment | ||
target: /home/ubuntu/backend-deploy | ||
|
||
- name: Create .env.prod file | ||
run: | | ||
echo "${{ secrets.ENV_PROD_VARS }}" > .env.prod | ||
- name: Send env file | ||
uses: appleboy/scp-action@master | ||
with: | ||
host: ${{ secrets.SSH_HOST }} | ||
username: ${{ secrets.SSH_USERNAME }} | ||
key: ${{ secrets.SSH_KEY }} | ||
source: ./BE/exceed/.env.prod | ||
target: /home/ubuntu/backend-deploy | ||
|
||
- name: Docker Image Build | ||
run: docker build -f Dockerfile-prod -t ${{ secrets.DOCKER_HUB_USER_NAME }}/gaebaljip-prod:latest . | ||
|
||
- name: Docker Hub Login | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKER_HUB_USER_NAME }} | ||
password: ${{ secrets.DOCKER_HUB_TOKEN }} | ||
|
||
- name: docker Hub Push | ||
run: docker push ${{ secrets.DOCKER_HUB_USER_NAME }}/gaebaljip-prod:latest | ||
|
||
- name: SSH Deploy | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.SSH_HOST }} | ||
username: ${{ secrets.SSH_USERNAME }} | ||
key: ${{ secrets.SSH_KEY }} | ||
script: | | ||
cd backend-deploy/BE/exceed | ||
sudo docker-compose down | ||
sudo docker pull ${{ secrets.DOCKER_HUB_USER_NAME }}/gaebaljip-prod:latest | ||
sudo docker-compose up --build -d | ||
sudo docker image prune -a -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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,8 +45,7 @@ src/main/resources/static/docs/api-doc.html | |
|
||
### env | ||
.env | ||
env-dev | ||
|
||
.env.prod | ||
|
||
### jmh | ||
|
||
|
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,18 @@ | ||
FROM openjdk:17-oracle | ||
|
||
ENV TZ=Asia/Seoul | ||
|
||
# 앱을 위한 작업 디렉토리 설정 | ||
WORKDIR /app | ||
|
||
# JAR 파일 복사 | ||
ARG JAR_FILE="./build/libs/*.jar" | ||
COPY ${JAR_FILE} eatceed.jar | ||
|
||
# CSV 파일 복사 | ||
COPY ./food_data.csv ./food_data.csv | ||
|
||
EXPOSE 8080 | ||
|
||
# CMD 명령어에서 CSV 파일의 위치를 절대 경로로 지정 | ||
CMD ["java", "-jar", "-Dspring.profiles.active=prod", "eatceed.jar", "./food_data.csv"] |
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,76 @@ | ||
version: '3' | ||
services: | ||
eatceed-redis: | ||
image: redis:alpine | ||
container_name: gaebaljip-redis | ||
command: redis-server --port 6379 | ||
expose: | ||
- "6379" | ||
networks: | ||
- gaebaljip-network | ||
|
||
eatceed-backend: | ||
image: hwangdaesun/gaebaljip-prod:latest | ||
container_name: gaebaljip-spring | ||
ports: | ||
- 8080:8080 | ||
depends_on: | ||
- eatceed-redis | ||
environment: | ||
- RDS_DATABASE_ENDPOINT=${RDS_DATABASE_ENDPOINT} | ||
- RDS_PORT=${RDS_PORT} | ||
- RDS_DB_NAME=${RDS_DB_NAME} | ||
- RDS_DATABASE_USERNAME=${RDS_DATABASE_USERNAME} | ||
- RDS_DATABASE_PASSWORD=${RDS_DATABASE_PASSWORD} | ||
- S3_BUCKET_NAME=${S3_BUCKET_NAME} | ||
- CLOUD_AWS_ACCESS_KEY=${CLOUD_AWS_ACCESS_KEY} | ||
- CLOUD_AWS_SECRET_KEY=${CLOUD_AWS_SECRET_KEY} | ||
- JWT_SECRET=${JWT_SECRET} | ||
- SES_MAIL_ADDRESS=${SES_MAIL_ADDRESS} | ||
- ENCRYPTION_SPEC=${ENCRYPTION_SPEC} | ||
- ENCRYPTION_SECRET=${ENCRYPTION_SECRET} | ||
- ENCRYPTION_ALGORITHM=${ENCRYPTION_ALGORITHM} | ||
- SPRING_REDIS_HOST=gaebaljip-redis | ||
- SPRING_REDIS_PORT=6379 | ||
networks: | ||
- gaebaljip-network | ||
restart: "always" | ||
|
||
grafana: | ||
image: grafana/grafana:latest | ||
container_name: grafana | ||
restart: "always" | ||
ports: | ||
- "3000:3000" | ||
volumes: | ||
- grafana-data:/var/lib/grafana | ||
- ./resources/gaebaljip-prod-environment/grafana/provisioning/:/etc/grafana/provisioning/ | ||
environment: | ||
- GF_SERVER_ROOT_URL=localhost:3000 | ||
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD} | ||
depends_on: | ||
- prometheus | ||
networks: | ||
- gaebaljip-network | ||
|
||
prometheus: | ||
image: prom/prometheus:latest | ||
container_name: prometheus | ||
restart: "always" | ||
ports: | ||
- "9090:9090" | ||
volumes: | ||
- ./resources/gaebaljip-prod-environment/prometheus/config:/etc/prometheus/ | ||
- prometheus-data:/prometheus | ||
command: | ||
- '--config.file=/etc/prometheus/prometheus.yml' | ||
- '--storage.tsdb.path=/prometheus' | ||
networks: | ||
- gaebaljip-network | ||
|
||
volumes: | ||
grafana-data: | ||
prometheus-data: | ||
|
||
networks: | ||
gaebaljip-network: |
19 changes: 19 additions & 0 deletions
19
BE/exceed/resources/gaebaljip-prod-environment/prometheus/config/prometheus.yml
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,19 @@ | ||
global: | ||
scrape_interval: 15s | ||
evaluation_interval: 15s | ||
alerting: | ||
alertmanagers: | ||
- static_configs: | ||
- targets: | ||
# - alertmanager:9093 | ||
rule_files: | ||
scrape_configs: | ||
- job_name: "prometheus" | ||
static_configs: | ||
- targets: ["localhost:9090"] | ||
#추가 | ||
- job_name: "spring-actuator" | ||
metrics_path: '/actuator/prometheus' | ||
scrape_interval: 1s | ||
static_configs: | ||
- targets: ['3.37.117.77:8080'] |
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