Skip to content

Commit

Permalink
build(#111): build
Browse files Browse the repository at this point in the history
  • Loading branch information
mjh000526 committed Dec 5, 2024
1 parent e3c5acb commit a30f195
Show file tree
Hide file tree
Showing 264 changed files with 28,345 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Bug template
about: 버그 픽스
title: ''
labels: ''
assignees: ''

---

## 어떤 기능인가요?

> 추가하려는 기능에 대해 간결하게 설명해주세요
## 작업 상세 내용

- [ ] TODO
- [ ] TODO
- [ ] TODO

## 참고할만한 자료(선택)
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature template
about: task 기능
title: ''
labels: ''
assignees: ''

---

## 어떤 기능인가요?

> 추가하려는 기능에 대해 간결하게 설명해주세요
## 작업 상세 내용

- [ ] TODO
- [ ] TODO
- [ ] TODO

## 참고할만한 자료(선택)
15 changes: 15 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## #️⃣연관된 이슈

> ex) #이슈번호, #이슈번호
## 📝작업 내용

> 이번 PR에서 작업한 내용을 간략히 설명해주세요(이미지 첨부 가능)
### 스크린샷 (선택)

## 💬리뷰 요구사항(선택)

> 리뷰어가 특별히 봐주었으면 하는 부분이 있다면 작성해주세요
>
> ex) 메서드 XXX의 이름을 더 잘 짓고 싶은데 혹시 좋은 명칭이 있을까요?
57 changes: 57 additions & 0 deletions .github/workflows/be-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: froxy BE Continuous Delivery

on:
push:
branches:
- deploy

jobs:
be-cd:
runs-on: ubuntu-20.04 # 빌드가 진행될 환경 설정

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

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }} # DockerHub 사용자 이름
password: ${{ secrets.DOCKER_PASSWORD }} # DockerHub 비밀번호

#이미지 이름 저장
- name: Set Docker image tag as a variable
run: echo "DOCKER_TAG=${{ secrets.DOCKER_USERNAME }}/froxy-server:latest" >> $GITHUB_ENV

- name: Create .env file
run: |
echo "${{ secrets.BE_ENV }}" > ./apps/backend/.env
- name: Build Docker image
run: |
docker build -t $DOCKER_TAG .
- name: Push Docker image to Docker Hub
run: |
docker push $DOCKER_TAG
- name: Setup SSH
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

- name: Deploy
run: |
ssh -o StrictHostKeyChecking=no [email protected] "
if [ \$(docker ps -a -q -f name=froxy-container) ]; then
docker stop froxy-container
docker rm froxy-container
fi
docker pull ${{ secrets.DOCKER_USERNAME }}/froxy-server:latest && \
docker run --network host -d --name froxy-container -v /var/run/docker.sock:/var/run/docker.sock ${{ secrets.DOCKER_USERNAME }}/froxy-server:latest
docker image prune -f
"
49 changes: 49 additions & 0 deletions .github/workflows/be-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Froxy-BE Continuous Integration

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
be-ci:
runs-on: ubuntu-20.04
if: contains(github.event.pull_request.labels.*.name, '💻 Be')

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

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 9

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20' # 적절한 Node.js 버전으로 설정
cache: 'pnpm' # pnpm 캐싱 활성화

- name: Create .env file
run: |
echo "${{ secrets.BE_ENV }}" > ./apps/backend/.env
- name: Install dependencies #라이브러리설치
run: |
pnpm install --no-frozen-lockfile
- name: Run lint & Turbo build
run: |
pnpm lint --filter=backend
pnpm turbo run build --filter=backend
#FE CI : pnpm turbo run build --filter=frontend
#전역 CI : pnpm turbo run build

#테스트코드 빌드는 테스트코드를 추가할때 사용
#- name: Run Turbo tests
# run: |
# pnpm turbo run test --filter=be
50 changes: 50 additions & 0 deletions .github/workflows/fe-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Froxy-FE Continuous Integration

on:
push:
branches:
- deploy

jobs:
fe-cd:
runs-on: ubuntu-20.04

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

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 9

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20' # 적절한 Node.js 버전으로 설정
cache: 'pnpm' # pnpm 캐싱 활성화

- name: Create .env file
run: |
echo "${{ secrets.FE_ENV }}" > apps/frontend/.env
- name: Install dependencies #라이브러리설치
run: |
pnpm install --no-frozen-lockfile
- name: Run lint & Turbo build
run: |
pnpm lint --filter=frontend
pnpm turbo run build --filter=frontend
- name: Upload to Object Storage
env:
AWS_ACCESS_KEY_ID: ${{ secrets.NCP_ACCESS_NAME }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.NCP_ACCESS_SECRET }}
AWS_DEFAULT_REGION: 'kr-standard' # 리전 설정
run: |
# AWS CLI 설치 확인 및 설정
sudo apt-get update && sudo apt-get install -y awscli
# 빌드된 정적 파일을 오브젝트 스토리지로 업로드
aws s3 sync ./apps/frontend/dist s3://froxy-fe --endpoint-url=https://kr.object.ncloudstorage.com --acl public-read
42 changes: 42 additions & 0 deletions .github/workflows/fe-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Froxy-CI Continuous Integration

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
fe-ci:
runs-on: ubuntu-20.04
if: contains(github.event.pull_request.labels.*.name, '💻 Fe')

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

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 9

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20' # 적절한 Node.js 버전으로 설정
cache: 'pnpm' # pnpm 캐싱 활성화

- name: Create .env file
run: |
echo "${{ secrets.FE_ENV }}" > apps/frontend/.env
- name: Install dependencies #라이브러리설치
run: |
pnpm install --no-frozen-lockfile
- name: Run lint & Turbo build
run: |
pnpm lint --filter=frontend
pnpm turbo run build --filter=frontend
43 changes: 43 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# Dependencies
node_modules
.pnp
.pnp.js

# Local env files
.server.env
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

# Testing
coverage

# Turbo
.turbo

# Vercel
.vercel

# Build Outputs
.next/
out/
build
dist


# Debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Misc
.DS_Store
*.pem


#docker
mysql-data/*
27 changes: 27 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh

# 브랜치 이름과 커밋 메시지 파일 가져오기
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
COMMIT_FILE=$1

# 브랜치 이름에서 커밋 번호 추출
if [[ $BRANCH_NAME =~ [Ff]eature-#([0-9]+) ]]; then
COMMIT_NUMBER=${BASH_REMATCH[1]}

# 기존 커밋 메시지 불러오기
MESSAGE=$(cat "$COMMIT_FILE")

# 커밋 메시지에서 타입과 나머지 내용 추출 (예: Chore: 환경설정)
if [[ $MESSAGE =~ ^([A-Za-z]+):\s*(.*)$ ]]; then
COMMIT_TYPE=${BASH_REMATCH[1]}
COMMIT_CONTENT=${BASH_REMATCH[2]}

# 커밋 번호가 메시지에 없는 경우 추가
if [[ ! $COMMIT_CONTENT =~ \(#$COMMIT_NUMBER\) ]]; then
echo "$COMMIT_TYPE(#$COMMIT_NUMBER): $COMMIT_CONTENT" > "$COMMIT_FILE"
fi
fi
fi

# 커밋 메시지 유효성 검사
npx --no-install commitlint --edit "$1"
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx lint-staged
1 change: 1 addition & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx lint-staged
Empty file added .npmrc
Empty file.
10 changes: 10 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"singleQuote": true,
"trailingComma": "none",
"semi": true,
"tabWidth": 2,
"printWidth": 120,
"arrowParens": "always",
"bracketSpacing": true,
"endOfLine": "auto"
}
10 changes: 10 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"eslint.workingDirectories": [
{
"mode": "auto"
}
],
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "always"
}
}
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM node:20

WORKDIR /app

COPY package*.json ./
RUN npm install -g pnpm

COPY . .

RUN pnpm install

RUN pnpm lint --filter=backend && pnpm turbo run build --filter=backend

WORKDIR /app/apps/backend
CMD ["pnpm", "run", "start:prod"]

# 외부에서 접근할 수 있도록 포트 노출
EXPOSE 3000
Loading

0 comments on commit a30f195

Please sign in to comment.