Skip to content

Commit

Permalink
Merge pull request #14 from TEAM-SAMSION/PET-98
Browse files Browse the repository at this point in the history
PET-98 chore : 모니터링에 로그 수집 통합
  • Loading branch information
tlarbals824 authored Sep 12, 2023
2 parents 9dd2684 + e28c9c1 commit f40fbce
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 135 deletions.
73 changes: 1 addition & 72 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,82 +12,11 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Setup JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'corretto'

- name: make application.yml
run: |
cd ./src/main/resources
touch ./application.yml
echo "${{ secrets.APPLICATION }}" > ./application.yml
shell: bash

- name: make prometheus.yml
run: |
cd ./monitoring
touch ./prometheus.yml
echo "${{ secrets.PROMETHEUS }}" > ./prometheus.yml
- name: Set .env for configuration
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ubuntu
key: ${{ secrets.KEY }}
script: |
rm -rf ./.env
touch ./.env
echo "MONGO_USERNAME=${{ secrets.MONGO_USERNAME }}" >> ./.env
echo "MONGO_PASSWORD=${{ secrets.MONGO_PASSWORD }}" >> ./.env
echo "DOCKER_USERNAME=${{ secrets.DOCKER_USERNAME }}" >> ./.env
echo "DOCKER_REPOSITORY=${{ secrets.DOCKER_REPOSITORY }}" >> ./.env
- name: Build With Gradle
run: ./gradlew build

- name: Docker build
run: docker build -f ./deploy/Dockerfile -t ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }} .

- name: Docker Hub Login
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Docker push
run: docker push ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }}

- name: deploy-docker-compose push
uses: appleboy/scp-action@master
with:
host: ${{ secrets.HOST }}
username: ubuntu
key: ${{ secrets.KEY }}
source: "./deploy/docker-compose.yml"
target: "/home/ubuntu"
strip_components: 2

- name: monitoring-docker-compose push
uses: appleboy/scp-action@master
with:
host: ${{ secrets.HOST }}
username: ubuntu
key: ${{ secrets.KEY }}
source: "./monitoring"
target: "/home/ubuntu"

- name: Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ubuntu
key: ${{ secrets.KEY }}
script: |
docker pull ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }}
docker stop ${{ secrets.DOCKER_REPOSITORY }}
docker rm -f ${{ secrets.DOCKER_REPOSITORY }}
docker-compose up -d
docker image prune -f
target: "/home/ubuntu"
50 changes: 25 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
name: CI

on:
pull_request:
branches:
- dev

jobs:
build:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v2

- name: Setup JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'corretto'

- name: Grant Execute Permission For Gradlew
run: chmod +x gradlew

- name: Build With Gradle
run: ./gradlew build
#name: CI
#
#on:
# pull_request:
# branches:
# - dev
#
#jobs:
# build:
# runs-on: ubuntu-22.04
#
# steps:
# - uses: actions/checkout@v2
#
# - name: Setup JDK 17
# uses: actions/setup-java@v3
# with:
# java-version: '17'
# distribution: 'corretto'
#
# - name: Grant Execute Permission For Gradlew
# run: chmod +x gradlew
#
# - name: Build With Gradle
# run: ./gradlew build
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,4 @@ out/

### application ###

/src/main/resources/application.yml
/monitoring/prometheus.yml
/src/main/resources/application.yml
4 changes: 0 additions & 4 deletions deploy/Dockerfile

This file was deleted.

32 changes: 0 additions & 32 deletions deploy/docker-compose.yml

This file was deleted.

13 changes: 13 additions & 0 deletions monitoring/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ services:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
networks:
- monitoring_network
restart: always

grafana:
image: grafana/grafana
Expand All @@ -21,6 +22,18 @@ services:
networks:
- monitoring_network

loki:
image: grafana/loki:master
container_name: docker-loki
ports:
- "3100:3100"
command:
- "-config.file=/etc/loki/local-config.yaml"
depends_on:
- grafana
networks:
- monitoring_network

networks:
monitoring_network:
name: server_network
Expand Down
9 changes: 9 additions & 0 deletions monitoring/prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
global:
scrape_interval: 10s

scrape_configs:
- job_name: "petmory"
static_configs:
- targets: ['52.78.52.47:8079']
metrics_path: /actuator/prometheus
scrape_interval: 1s

0 comments on commit f40fbce

Please sign in to comment.