-
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.
Merge pull request #351 from Team-Smeme/develop
deploy: 실서버v4 배포 (임시)
- Loading branch information
Showing
72 changed files
with
1,170 additions
and
238 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
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,71 +1,75 @@ | ||
name: deploy-dev | ||
name: CD-dev | ||
|
||
on: | ||
release: | ||
types: [ published ] | ||
types: [ "published" ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-20.04 | ||
deploy-ci: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
- name: Checkout Latest Repo | ||
uses: actions/checkout@v3 | ||
# 최신 저장소에서 체크아웃 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: 17 | ||
distribution: 'temurin' | ||
cache: gradle | ||
distribution: 'corretto' | ||
java-version: '17' | ||
# 자바 버전을 JDK 17로 설정 | ||
|
||
- name: Create application-secret.yml | ||
run: | | ||
pwd | ||
cd ./smeem-bootstrap/src/main/resources | ||
touch ./application-secret.yml | ||
echo "${{ secrets.APPLICATION_SECRET_YML }}" >> ./application-secret.yml | ||
cat ./application-secret.yml | ||
- name: Configure AWS credentials | ||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }} | ||
aws-region: ${{ secrets.AWS_REGION }} | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_DEV }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY_DEV }} | ||
aws-region: ap-northeast-2 | ||
# AWS 자격 증명 설정 | ||
|
||
- name: Set FCM_JSON_PATH | ||
run: echo "FCM_JSON_PATH=smeem-output-notification/src/main/resources/firebase-config/smeem_fcm_dev.json" >> $GITHUB_ENV | ||
- name: Set FCM JSON File Path | ||
run: | | ||
echo "FCM_JSON_PATH=smeem-output-notification/src/main/resources/firebase-config/smeem_fcm_dev.json" >> $GITHUB_ENV | ||
# FCM JSON 파일 위치 경로 설정 | ||
|
||
- name: Create FireBase JSON file From AWS | ||
- name: Create FCM JSON File from AWS | ||
run: aws s3 cp --region ap-northeast-2 ${{ secrets.AWS_S3_FCM_JSON_URI_DEV }} ${{ env.FCM_JSON_PATH }} | ||
# FCM JSON 파일 복사 | ||
|
||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
shell: bash | ||
# gradlew 파일에 실행 권한 부여 | ||
|
||
- name: Build with Gradle | ||
run: | | ||
chmod +x ./gradlew | ||
./gradlew build -x test | ||
run: ./gradlew clean build -x test | ||
shell: bash | ||
# 그래들로 빌드 | ||
|
||
- name: Set docker | ||
- name: Set Docker | ||
uses: docker/[email protected] | ||
# 도커 설정 | ||
|
||
- name: Login docker | ||
- name: Login Docker | ||
uses: docker/[email protected] | ||
with: | ||
username: ${{ secrets.DOCKERHUB_LOGIN_USERNAME_DEV }} | ||
password: ${{ secrets.DOCKERHUB_LOGIN_ACCESSTOKEN_DEV }} | ||
# 도커에 로그인 | ||
|
||
- name: Build docker image | ||
- name: Docker Build | ||
run: | | ||
docker build --platform linux/amd64 -t smeemdev/smeem-dev:latest -f Dockerfile-dev . | ||
docker push smeemdev/smeem-dev:latest | ||
deploy-cd: | ||
needs: build | ||
runs-on: ubuntu-20.04 | ||
needs: deploy-ci | ||
runs-on: ubuntu-latest | ||
# deploy-ci 이후 작업 실행 | ||
|
||
steps: | ||
- name: SSH로 서버 접속 | ||
- name: Connect to EC2 and Deploy | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.RELEASE_SERVER_IP_DEV }} | ||
|
@@ -78,19 +82,14 @@ jobs: | |
wget https://raw.githubusercontent.com/Team-Smeme/Smeme-server-renewal/develop/script/deploy.sh -O deploy.sh | ||
chmod +x deploy.sh | ||
# .env 파일 추가 | ||
if ! grep -q "REGISTRY_URL=" .env; then | ||
echo "REGISTRY_URL=${{ secrets.REGISTRY_URL_DEV }}" >> .env | ||
fi | ||
if ! grep -q "IMAGE_NAME=" .env; then | ||
echo "IMAGE_NAME=${{ secrets.IMAGE_NAME_DEV }}" >> .env | ||
fi | ||
if ! grep -q "SECRET_MANAGER_TOKEN=" .env; then | ||
echo "SECRET_MANAGER_TOKEN=${{ secrets.SECRET_MANAGER_TOKEN }}" >> .env | ||
fi | ||
if ! grep -q "SECRET_MANAGER_WORKSPACE_ID=" .env; then | ||
echo "SECRET_MANAGER_WORKSPACE_ID=${{ secrets.SECRET_MANAGER_WORKSPACE_ID }}" >> .env | ||
fi | ||
# 기존 .env 파일 삭제 및 새로 생성 | ||
rm -f .env # 기존 .env 파일을 삭제합니다. | ||
# .env 파일 새로 생성 | ||
echo "REGISTRY_URL=${{ secrets.REGISTRY_URL_DEV }}" >> .env | ||
echo "IMAGE_NAME=${{ secrets.IMAGE_NAME_DEV }}" >> .env | ||
echo "SECRET_MANAGER_TOKEN=${{ secrets.SECRET_MANAGER_TOKEN }}" >> .env | ||
echo "SECRET_MANAGER_WORKSPACE_ID=${{ secrets.SECRET_MANAGER_WORKSPACE_ID }}" >> .env | ||
# 배포 스크립트 실행 | ||
sudo ./deploy.sh |
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,71 +1,75 @@ | ||
name: deploy-prod | ||
name: CD-prod | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-20.04 | ||
deploy-ci: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
- name: Checkout Latest Repo | ||
uses: actions/checkout@v3 | ||
# 최신 저장소에서 체크아웃 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: 17 | ||
distribution: 'temurin' | ||
cache: gradle | ||
distribution: 'corretto' | ||
java-version: '17' | ||
# 자바 버전을 JDK 17로 설정 | ||
|
||
- name: Create application-secret.yml | ||
run: | | ||
pwd | ||
cd ./smeem-bootstrap/src/main/resources | ||
touch ./application-secret.yml | ||
echo "${{ secrets.APPLICATION_SECRET_YML }}" >> ./application-secret.yml | ||
cat ./application-secret.yml | ||
- name: Configure AWS credentials | ||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_PROD_ACCESS_KEY }} | ||
aws-secret-access-key: ${{ secrets.AWS_PROD_SECRET_KEY }} | ||
aws-region: ${{ secrets.AWS_REGION }} | ||
aws-region: ap-northeast-2 | ||
# AWS 자격 증명 설정 | ||
|
||
- name: Set FCM_JSON_PATH | ||
run: echo "FCM_JSON_PATH=smeem-output-notification/src/main/resources/firebase-config/smeem_fcm_prod.json" >> $GITHUB_ENV | ||
- name: Set FCM JSON File Path | ||
run: | | ||
echo "FCM_JSON_PATH=smeem-output-notification/src/main/resources/firebase-config/smeem_fcm_prod.json" >> $GITHUB_ENV | ||
# FCM JSON 파일 위치 경로 설정 | ||
|
||
- name: Create FireBase JSON file From AWS | ||
- name: Create FCM JSON File from AWS | ||
run: aws s3 cp --region ap-northeast-2 ${{ secrets.AWS_S3_FCM_JSON_URI_PROD }} ${{ env.FCM_JSON_PATH }} | ||
# FCM JSON 파일 복사 | ||
|
||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
shell: bash | ||
# gradlew 파일에 실행 권한 부여 | ||
|
||
- name: Build with Gradle | ||
run: | | ||
chmod +x ./gradlew | ||
./gradlew build -x test | ||
run: ./gradlew clean build -x test | ||
shell: bash | ||
# 그래들로 빌드 | ||
|
||
- name: Set docker | ||
- name: Set Docker | ||
uses: docker/[email protected] | ||
# 도커 설정 | ||
|
||
- name: Login docker | ||
- name: Login Docker | ||
uses: docker/[email protected] | ||
with: | ||
username: ${{ secrets.DOCKERHUB_LOGIN_USERNAME_PROD }} | ||
password: ${{ secrets.DOCKERHUB_LOGIN_ACCESSTOKEN_PROD }} | ||
# 도커에 로그인 | ||
|
||
- name: Build docker image | ||
- name: Docker Build | ||
run: | | ||
docker build --platform linux/amd64 -t smeemprod/smeem-prod:latest -f Dockerfile-prod . | ||
docker push smeemprod/smeem-prod:latest | ||
deploy-cd: | ||
needs: build | ||
runs-on: ubuntu-20.04 | ||
needs: deploy-ci | ||
runs-on: ubuntu-latest | ||
# deploy-ci 이후 작업 실행 | ||
|
||
steps: | ||
- name: SSH로 서버 접속 | ||
- name: Connect to EC2 and Deploy | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.RELEASE_SERVER_IP_PROD }} | ||
|
@@ -78,19 +82,14 @@ jobs: | |
wget https://raw.githubusercontent.com/Team-Smeme/Smeme-server-renewal/main/script/deploy.sh -O deploy.sh | ||
chmod +x deploy.sh | ||
# .env 파일 추가 | ||
if ! grep -q "REGISTRY_URL=" .env; then | ||
echo "REGISTRY_URL=${{ secrets.REGISTRY_URL_PROD }}" >> .env | ||
fi | ||
if ! grep -q "IMAGE_NAME=" .env; then | ||
echo "IMAGE_NAME=${{ secrets.IMAGE_NAME_PROD }}" >> .env | ||
fi | ||
if ! grep -q "SECRET_MANAGER_TOKEN=" .env; then | ||
echo "SECRET_MANAGER_TOKEN=${{ secrets.SECRET_MANAGER_TOKEN }}" >> .env | ||
fi | ||
if ! grep -q "SECRET_MANAGER_WORKSPACE_ID=" .env; then | ||
echo "SECRET_MANAGER_WORKSPACE_ID=${{ secrets.SECRET_MANAGER_WORKSPACE_ID }}" >> .env | ||
fi | ||
# 기존 .env 파일 삭제 및 새로 생성 | ||
rm -f .env # 기존 .env 파일을 삭제합니다. | ||
# .env 파일 새로 생성 | ||
echo "REGISTRY_URL=${{ secrets.REGISTRY_URL_PROD }}" >> .env | ||
echo "IMAGE_NAME=${{ secrets.IMAGE_NAME_PROD }}" >> .env | ||
echo "SECRET_MANAGER_TOKEN=${{ secrets.SECRET_MANAGER_TOKEN }}" >> .env | ||
echo "SECRET_MANAGER_WORKSPACE_ID=${{ secrets.SECRET_MANAGER_WORKSPACE_ID }}" >> .env | ||
# 배포 스크립트 실행 | ||
sudo ./deploy.sh |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
version: '3.8' | ||
|
||
services: | ||
prometheus: | ||
image: prom/prometheus:latest | ||
container_name: prometheus | ||
volumes: | ||
- ./prometheus.yml:/etc/prometheus/prometheus.yml | ||
command: | ||
- --config.file=/etc/prometheus/prometheus.yml | ||
ports: | ||
- "9090:9090" | ||
networks: | ||
- monitoring-network | ||
|
||
grafana: | ||
image: grafana/grafana:latest | ||
container_name: grafana | ||
ports: | ||
- "3000:3000" | ||
networks: | ||
- monitoring-network | ||
|
||
networks: | ||
monitoring-network: | ||
driver: bridge |
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,8 @@ | ||
global: | ||
scrape_interval: 15s | ||
|
||
scrape_configs: | ||
- job_name: prometheus | ||
metrics_path: '/actuator/prometheus' | ||
static_configs: | ||
- targets: ['host.docker.internal:8080'] |
Oops, something went wrong.