Skip to content

Commit

Permalink
Merge pull request #211 from Kernel360/develop
Browse files Browse the repository at this point in the history
[merge] main 브랜치에 develop 브랜치 커밋 반영
  • Loading branch information
linglong67 authored Feb 28, 2024
2 parents 51bf5e1 + c980f25 commit 1b0560f
Show file tree
Hide file tree
Showing 215 changed files with 8,482 additions and 2,190 deletions.
127 changes: 127 additions & 0 deletions .github/workflows/cicd-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
name: CI and CD in WashPedia Project

on:
push:
branches: [ "develop" ]

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: "17"
distribution: "temurin"

- name: Replace SQL Queries
run: |
file_path="${{ secrets.TARGET_SQL_PATH }}"
old_text="changeRequired"
new_text="${{ secrets.PUBLIC_KEY }}"
sed -i "s/$old_text/$new_text/g" $file_path
- name: Set application yml file (api)
uses: microsoft/variable-substitution@v1
with:
files: ./module-api/src/main/resources/application.yml
env:
spring.profiles.active: "dev"

- name: Set application yml file (batch)
uses: microsoft/variable-substitution@v1
with:
files: ./module-batch/src/main/resources/application.yml
env:
spring.profiles.active: "dev"

- name: Set application-dev yml file (api)
uses: microsoft/variable-substitution@v1
with:
files: ./module-api/src/main/resources/application-dev.yml
env:
spring.datasource.url: ${{ secrets.DB_URL }}
spring.datasource.username: ${{ secrets.DB_USER }}
spring.datasource.password: ${{ secrets.DB_PW }}
spring.mail.username: ${{ secrets.SMTP_GOOGLE_EMAIL }}
spring.mail.password: ${{ secrets.SMTP_PASSWORD }}
spring.data.redis.host: ${{ secrets.REDIS_DEV_HOST }}
spring.data.redis.password: ${{ secrets.REDIS_DEV_PASSWORD }}
constants.host-url: ${{ secrets.DEV_HOST_URL }}
aws.credentials.access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws.credentials.secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws.s3.bucket.name: ${{ secrets.AWS_S3_BUCKET_NAME }}
aws.s3.bucket.url: ${{ secrets.AWS_S3_BUCKET_URL }}

- name: Set application-dev yml file (batch)
uses: microsoft/variable-substitution@v1
with:
files: ./module-batch/src/main/resources/application-dev.yml
env:
spring.datasource.url: ${{ secrets.DB_URL }}
spring.datasource.username: ${{ secrets.DB_USER }}
spring.datasource.password: ${{ secrets.DB_PW }}
external.ecolife-api.path: ${{ secrets.ECOLIFE_PATH }}
external.ecolife-api.service-key: ${{ secrets.ECOLIFE_KEY }}

- name: Grant execute permission And Build with Gradle (api)
working-directory: ./module-api
run: |
chmod +x ./gradlew
./gradlew bootJar
- name: Grant execute permission And Build with Gradle (batch)
working-directory: ./module-batch
run: |
chmod +x ./gradlew
./gradlew bootJar
- name: DockerHub Login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Docker Image Build And Push (api)
working-directory: ./module-api
run: |
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.MODULE_API_NAME }} . --platform=linux/amd64
docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.MODULE_API_NAME }}
- name: Docker Image Build And Push (batch)
working-directory: ./module-batch
run: |
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.MODULE_BATCH_NAME }} . --platform=linux/amd64
docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.MODULE_BATCH_NAME }}
- name: Application Run
uses: appleboy/[email protected]
with:
host: ${{ secrets.VULTR_IP }}
username: ${{ secrets.VULTR_USERNAME }}
password: ${{ secrets.VULTR_PW }}
script: |
# Install Docker and Docker Compose
dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
dnf install -y docker-ce docker-ce-cli containerd.io
systemctl start docker
systemctl enable docker
curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
# Docker Compose
mkdir -p deploy
cd deploy
echo "${{ secrets.DB_INIT_SQL }}" > init.sql
echo "${{ secrets.DEV_REDIS_CONF }}" > redis.conf
echo "${{ secrets.DOCKER_COMPOSE }}" > docker-compose.yml
docker-compose pull
docker-compose down
docker-compose up -d
106 changes: 106 additions & 0 deletions .github/workflows/cicd-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: Project CI/CD with AWS

on:
push:
branches: [ "main" ]

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: "17"
distribution: "temurin"

- name: Replace SQL Queries
run: |
file_path="${{ secrets.TARGET_SQL_PATH }}"
old_text="changeRequired"
new_text="${{ secrets.PUBLIC_KEY }}"
sed -i "s/$old_text/$new_text/g" $file_path
- name: Set application yml file (api)
uses: microsoft/variable-substitution@v1
with:
files: ./module-api/src/main/resources/application.yml
env:
spring.profiles.active: "prod"

- name: Set application-prod yml file (api)
uses: microsoft/variable-substitution@v1
with:
files: ./module-api/src/main/resources/application-prod.yml
env:
spring.datasource.url: ${{ secrets.DB_URL_AWS }}
spring.datasource.username: ${{ secrets.DB_USER }}
spring.datasource.password: ${{ secrets.DB_PW }}
spring.mail.username: ${{ secrets.SMTP_GOOGLE_EMAIL }}
spring.mail.password: ${{ secrets.SMTP_PASSWORD }}
spring.data.redis.host: ${{ secrets.REDIS_PROD_HOST }}
spring.data.redis.password: ${{ secrets.REDIS_PROD_PASSWORD }}
constants.host-url: ${{ secrets.PROD_HOST_URL }}
aws.credentials.access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws.credentials.secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws.s3.bucket.name: ${{ secrets.AWS_S3_BUCKET_NAME }}
aws.s3.bucket.url: ${{ secrets.AWS_S3_BUCKET_URL }}

- name: Grant execute permission And Build with Gradle (api)
working-directory: ./module-api
run: |
chmod +x ./gradlew
./gradlew bootJar
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v3
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Build, tag, and push docker image to Amazon ECR
working-directory: ./module-api
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: washfit-api
IMAGE_TAG: latest
run: |
docker build -t $REGISTRY/$REPOSITORY:$IMAGE_TAG .
docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG
- name: Application Run
uses: appleboy/[email protected]
with:
host: ${{ secrets.AWS_EC2_HOST }}
username: ${{ secrets.AWS_USERNAME }}
key: ${{ secrets.AWS_KEY }}
script: |
# Install Docker and Docker Compose
sudo dnf update
sudo dnf install docker
sudo systemctl start docker
sudo systemctl enable docker
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
# Docker Compose
mkdir -p deploy
cd deploy
echo "${{ secrets.PROD_REDIS_CONF }}" > redis.conf
echo "${{ secrets.DOCKER_COMPOSE_AWS }}" > docker-compose.yml
docker-compose pull
docker-compose down
docker-compose up -d
20 changes: 0 additions & 20 deletions .github/workflows/cr.yml

This file was deleted.

57 changes: 0 additions & 57 deletions .github/workflows/gradle.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ build/
.settings
.springBeans
.sts4-cache
.jqwik-database/

bin/
!**/src/main/**/bin/
!**/src/test/**/bin/
Expand Down
49 changes: 48 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,49 @@
# F1-WashPedia
세차용품 안전정보 제공 및 검증 된 세차 관련 정보를 보여주는 플랫폼

## | 프로젝트 기획 및 목적
세차용품 안전정보 제공 및 검증 된 세차 관련 정보를 보여주는 플랫폼

## | 배포 주소 (로그인 필요시, 테스트 계정 기입)
배포 주소 ::
- https://dev.washfit.site

테스트용 계정 ::
- ID : washfit01
- PW : washfit1!

## | 주요 기능
회원 :: 회원가입, 로그인, 로그아웃, 회원 기본정보 수정, 차량정보 등록/수정, 세차정보 등록/수정
제품 :: 제품 검색(키워드, 조회순, 위반제품, 최신순)
배치 :: 제품 정보 요청 및 적재

## | 기능 작성시 상세한 기획/정책/규칙 작성
회원가입/로그인/로그아웃 ::
- JWT 토큰과 해시 알고리즘을 사용하여 구현. Spring Security 사용 X

제품 정보 요청 ::
- 초록누리 API 위해제품목록 요청
- 목록 정보를 바탕으로 단일 제품 상세 정보 요청
- 상세정보를 서비스에 사용하는 Product 테이블에 추가

## | 아키텍처
### 멀티모듈 구조
![멀티모듈구조](https://github.com/Kernel360/F1-WashPedia-BE/assets/73059667/5e008117-fd3b-40b4-ac2e-2cfb52b42ae9)

<br>

### 개발서버 인프라 구조
![개발서버인프라구조](https://github.com/Kernel360/F1-WashPedia-BE/assets/73059667/4ef76ccc-6140-4ecb-8704-a4a51f591435)


## | 그 외 정보들
배포 ::
- 운영 배포는 AWS 클라우드를 사용할 예정, 개발 배포를 vultr 사용중

추후 구현해야 하는 기능 ::
- 회원탈퇴(탈퇴회원 관리 정책 필요)
- 아이디/비밀번호 찾기
- 즐겨찾기
- 세차장 위치 정보 검색
- Admin 페이지
- 금지어 필터링
- (제품 추천 시스템)
Loading

0 comments on commit 1b0560f

Please sign in to comment.