Skip to content

Commit

Permalink
ver 0.1 (#3)
Browse files Browse the repository at this point in the history
* member GET API

* add member status

* implt member CRUD API

* add tags

* add AWS ECR image push step

* comment github action condition

* fix trigger condition

* light weight github action

* fix typo

* add ecr login step

* fix typo

* last typo?

* add info API

* add gitattribute

* implt github module

* add octokit

* eol lf

* lf normalize files

* update git attr

* npm run lint

* update README

* use poapper db

* member entity

* member dto

* re-design github action

* add docker-stack

* limit event counts

* update stack config

* add nginx config

* mask ecr pw

* update entity

* update column properties

* nullable...
  • Loading branch information
BlueHorn07 authored Sep 17, 2023
1 parent e7e0dae commit cf9b93e
Show file tree
Hide file tree
Showing 21 changed files with 1,342 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ DATABASE_HOST=xxxxxxxxxxxx
DATABASE_PORT=3306
DATABASE_USERNAME=xxxxxxxxxxxx
DATABASE_PASSWORD=xxxxxxxxxxxx
DATABASE_DATABASE=xxxxxxxxxxxx
DATABASE_DATABASE=poapper
50 changes: 50 additions & 0 deletions .gitattribute
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Encrypt the repository
# Remove/modify this line if the repository is meant to be open-source
*.* filter=git-crypt diff=git-crypt
.gitattributes !filter !diff

# These files are text and should be normalized (Convert crlf => lf)
*.php text
*.css text
*.js text
*.htm text
*.html text
*.xml text
*.txt text
*.ini text
*.inc text
.htaccess text

# These files are binary and should be left untouched
# (binary is a macro for -text -diff)
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.ico binary
*.mov binary
*.mp4 binary
*.mp3 binary
*.flv binary
*.fla binary
*.swf binary
*.gz binary
*.zip binary
*.7z binary
*.ttf binary

# Auto detect text files and perform LF normalization
# http://davidlaing.com/2012/09/19/customise-your-gitattributes-to-become-a-git-ninja/
* text=auto

# Documents
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
71 changes: 50 additions & 21 deletions .github/workflows/github-action.yaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,60 @@
on:
push:
branches:
- main
- master
release:
types: [published]

name: Github Action
name: Docker Build and Push

env:
ECR_REGISTRY: 151345152001.dkr.ecr.ap-northeast-2.amazonaws.com
ECR_REPOSITORY: poapper-api

jobs:
npm-build:
name: npm build check
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'npm'
- run: npm ci
- run: npm run build
docker-build:
name: Docker build check
runs-on: ubuntu-20.04
docker_build_and_push:
name: Docker build and push
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- run: docker build . -t nestjs-boilerplate
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
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
uses: aws-actions/amazon-ecr-login@v1
with:
mask-password: 'true'
- name: Determine Prod/Dev Stage
run: |
if [[ ${{ github.event_name }} == 'release' ]]; then
echo "PROD"
echo "IMAGE_TAG=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
else
echo "DEV"
echo "IMAGE_TAG=latest" >> $GITHUB_ENV
fi
- name: Build and Push
uses: docker/build-push-action@v3
with:
context: .
tags: ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max
push: true

deploy_health_check:
name: Check Application Status
needs: docker_build_and_push
runs-on: ubuntu-latest
steps:
- name: Check the deployed service URL
uses: jtalk/url-health-check-action@v3
with:
url: https://api.poapper.club|https://api-dev.poapper.club
follow-redirect: true
max-attempts: 3
retry-delay: 10s
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# NestJS Boilerplate
# PoApper API

PoApper 동아리 회원 관리 및 Github PoApper 연동을 위한 proxy



## Develop

Expand All @@ -9,6 +13,6 @@ npm run start:debug
or with Docker

```bash
docker build . -t nestjs-boilerplate
docker build . -t poapper-api
docker compose -f docker-compose.dev.yaml up -d
```
6 changes: 3 additions & 3 deletions docker-compose.dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ services:
- --character-set-server=utf8mb4 # 한글 인코딩
- --collation-server=utf8mb4_unicode_ci # 한글 인코딩
api:
image: nestjs-boilerplate
container_name: nestjs-api
image: poapper-api
container_name: poapper-api
ports:
- "4000:4000"
depends_on:
- database
env_file:
env_file:
- .env.development
42 changes: 42 additions & 0 deletions docker-stack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
version: '3.3'
services:
dev:
image: 151345152001.dkr.ecr.ap-northeast-2.amazonaws.com/poapper-api:latest
ports:
- 6001:4000
secrets:
- source: poapper_api_dot_env
target: /usr/src/app/.env
logging:
driver: local
options:
max-size: 10m
deploy:
labels:
swarmpit.service.deployment.autoredeploy: 'true'
placement:
constraints:
- node.role != manager
- node.labels.application == poapper_web
prod:
image: 151345152001.dkr.ecr.ap-northeast-2.amazonaws.com/poapper-api:vX.X.X
ports:
- 4001:4000
secrets:
- source: poapper_api_dot_env
target: /usr/src/app/.env
logging:
driver: local
options:
max-size: 10m
deploy:
labels:
swarmpit.service.deployment.autoredeploy: 'true'
placement:
constraints:
- node.role != manager
- node.labels.application == poapper_web

secrets:
poapper_api_dot_env:
external: true
11 changes: 11 additions & 0 deletions nginx/poapper-api-dev.nginx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
server {
server_name api-dev.poapper.club;
client_max_body_size 10M;

location / {
proxy_pass http://localhost:6001;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
11 changes: 11 additions & 0 deletions nginx/poapper-api.nginx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
server {
server_name api.poapper.club;
client_max_body_size 10M;

location / {
proxy_pass http://localhost:4001;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Loading

0 comments on commit cf9b93e

Please sign in to comment.