Skip to content

Commit

Permalink
Merge pull request #127 from sparcs-kaist/release/0.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
withSang authored Sep 17, 2023
2 parents 0941391 + 6a5411c commit ec2e0af
Show file tree
Hide file tree
Showing 86 changed files with 8,343 additions and 4,640 deletions.
2 changes: 2 additions & 0 deletions .docker/.env.development.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
MONGO_PORT=
REDIS_PORT=
13 changes: 13 additions & 0 deletions .docker/.env.prod.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#Dotenv file needed for `docker-compose`
SSO_CLIENT_ID=
SSO_SECRET=
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
SESSION_SECRET=
JWT_SECRET=
S3_BUCKET=
SLACK_WEBHOOK_URL=
SERVER_PORT=
AWS_S3_DUMP_BUCKET_NAME=
AWS_S3_DUMP_BUCKET_ACCESS_KEY_ID=
AWS_S3_DUMP_BUCKET_SECRET_ACCESS_KEY=
15 changes: 15 additions & 0 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:16-alpine


RUN apk add --no-cache git

WORKDIR '/app'

COPY ./package.json ./
COPY ./yarn.lock ./
RUN yarn

COPY . .

EXPOSE 80
ENTRYPOINT [ "yarn", "start" ]
13 changes: 13 additions & 0 deletions .docker/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:16.19.1

RUN apt update

RUN apt install git -y

WORKDIR /app

EXPOSE 6001

VOLUME [ "/app" ]

CMD ["yarn", "dev"]
20 changes: 20 additions & 0 deletions .docker/docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
services:
mongo:
container_name: zabo-mongo-dev
extends:
file: ./docker-compose.yml
service: zabo-mongo
restart: unless-stopped
ports:
- ${MONGO_PORT:-27017}:27017
redis:
container_name: zabo-redis-dev
extends:
file: ./docker-compose.yml
service: zabo-redis
restart: unless-stopped
ports:
- ${REDIS_PORT:-6379}:6379

volumes:
zabo-mongo-data:
63 changes: 63 additions & 0 deletions .docker/docker-compose.stage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
version: "3"

services:
zabo-server:
container_name: zabo-server
restart: always
image: ghcr.io/sparcs-kaist/zabo-server:dev
ports:
- "${SERVER_PORT}:6001"
depends_on:
- zabo-mongo
- zabo-redis
volumes:
- zabo-server-log:/app/log
environment:
- NODE_ENV=${NODE_ENV:-production}
- MINIMUM_LOG_LEVEL=info
- SSO_CLIENT_ID=${SSO_CLIENT_ID}
- SSO_SECRET=${SSO_SECRET}
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
- SESSION_SECRET=${SESSION_SECRET}
- JWT_SECRET=${JWT_SECRET}
- S3_BUCKET=${S3_BUCKET}
- MONGODB_URL=mongodb://zabo-mongo:27017/zabo
- REDIS_URL=redis://zabo-redis:6379
- SLACK_WEBHOOK_URL=${SLACK_WEBHOOK_URL}

zabo-mongo:
container_name: zabo-mongo
restart: always
image: mongo:4.4
volumes:
- zabo-mongo-data:/data/db

zabo-redis:
container_name: zabo-redis
restart: always
image: redis:7.0.4-alpine

zabo-scheduler:
container_name: zabo-scheduler
restart: always
build:
context: ..
dockerfile: .scheduler/Dockerfile
environment:
- AWS_ACCESS_KEY_ID=${AWS_S3_DUMP_BUCKET_ACCESS_KEY_ID}
- AWS_SECRET_ACCESS_KEY=${AWS_S3_DUMP_BUCKET_SECRET_ACCESS_KEY}
- BUCKET=${AWS_S3_DUMP_BUCKET_NAME}
- BACKUP_FOLDER=mongodb-dump/
- MONGODB_HOST=zabo-mongo:27017
- DB_STR=zabo
volumes:
- zabo-scheduler-log:/backup_log:rw

volumes:
zabo-server-log:
external: true
zabo-mongo-data:
external: true
zabo-scheduler-log:
external: true
63 changes: 63 additions & 0 deletions .docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
version: "3"

services:
zabo-server:
container_name: zabo-server
restart: always
image: ghcr.io/sparcs-kaist/zabo-server:latest
ports:
- "${SERVER_PORT}:6001"
depends_on:
- zabo-mongo
- zabo-redis
volumes:
- zabo-server-log:/app/log
environment:
- NODE_ENV=${NODE_ENV:-production}
- MINIMUM_LOG_LEVEL=info
- SSO_CLIENT_ID=${SSO_CLIENT_ID}
- SSO_SECRET=${SSO_SECRET}
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
- SESSION_SECRET=${SESSION_SECRET}
- JWT_SECRET=${JWT_SECRET}
- S3_BUCKET=${S3_BUCKET}
- MONGODB_URL=mongodb://zabo-mongo:27017/zabo
- REDIS_URL=redis://zabo-redis:6379
- SLACK_WEBHOOK_URL=${SLACK_WEBHOOK_URL}

zabo-mongo:
container_name: zabo-mongo
restart: always
image: mongo:4.4
volumes:
- zabo-mongo-data:/data/db

zabo-redis:
container_name: zabo-redis
restart: always
image: redis:7.0.4-alpine

zabo-scheduler:
container_name: zabo-scheduler
restart: always
build:
context: ..
dockerfile: .scheduler/Dockerfile
environment:
- AWS_ACCESS_KEY_ID=${AWS_S3_DUMP_BUCKET_ACCESS_KEY_ID}
- AWS_SECRET_ACCESS_KEY=${AWS_S3_DUMP_BUCKET_SECRET_ACCESS_KEY}
- BUCKET=${AWS_S3_DUMP_BUCKET_NAME}
- BACKUP_FOLDER=mongodb-dump/
- MONGODB_HOST=zabo-mongo:27017
- DB_STR=zabo
volumes:
- zabo-scheduler-log:/backup_log:rw

volumes:
zabo-server-log:
external: true
zabo-mongo-data:
external: true
zabo-scheduler-log:
external: true
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.idea
.git
.gitignore
.dockerignore
.docker/Dockerfile
*.md
*.sh
*.yml
node_modules
32 changes: 32 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"extends": [
"airbnb-base",
"prettier"
],
"rules": {
"import/no-unresolved": 0,
"import/prefer-default-export": 0,
"import/no-import-module-exports": 0,
"no-nested-ternary": "off",
"no-unused-vars": "warn",
"no-unused-expressions": "warn",
"no-spaced-func": "off",
"no-underscore-dangle": "off",
"no-shadow": "warn",
"prefer-const": "warn",
"consistent-return": [
"warn",
{
"treatUndefinedAsUnspecified": true
}
],
"no-await-in-loop": "warn"
},
"parserOptions": {
"ecmaVersion": 2020
},
"env": {
"browser": false,
"node": true
}
}
31 changes: 31 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
name: Bug report
about: Create a report to help us improve
title: "[Bug] Bug title"
labels: bug
assignees: ''

---

# Describe the bug

<!-- 버그가 발생한 상황을 간결하고 명확하게 설명해주세요. 버그가 발생한 원인을 추측하실 수 있다면, 같이 써주셔도 좋습니다. -->

A clear and concise description of what the bug is.

# To Reproduce

<!-- 버그를 재현할 수 있는 과정을 단계별로 설명해주세요. -->

Steps to reproduce the behavior:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

# Screenshots

<!-- 스크린샷이나 영상이 버그 설명에 도움이 된다면, 함께 첨부해주시면 감사하겠습니다. -->

If applicable, add screenshots to help explain your problem.
18 changes: 18 additions & 0 deletions .github/ISSUE_TEMPLATE/issue-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
name: Issue template
about: Suggest an idea for this project
title: Issue
labels: enhancement
assignees: ''

---

# Summary <!-- 이슈에 대한 간단한 요약. -->

It implements ...

# Tasks <!-- 해야 할 태스크 체크리스트로 만들기 -->

- [ ] Task 1
- [ ] Task 2
- [ ] Task 3
11 changes: 11 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Summary <!-- PR 내용에 대한 간단한 요약 및 닫는 이슈 번호 표기. -->

It closes #issue_number

# Extra info <!-- Answer 'y' or 'n'. 필요하지 않으면 지우셔도 됩니다. -->

# Images or Screenshots <!-- PR 변경 사항에 대한 Screenshot이나 .gif 파일 -->

# Further Work <!-- PR 이후 개설할 이슈 목록 -->

- Do something...
37 changes: 37 additions & 0 deletions .github/workflows/dev-build-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Build docker image on push to develop

on:
push:
branches: ["develop"]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Log in to GitHub Container Registry
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u USERNAME --password-stdin
- name: Build and push Image
id: docker-build
uses: docker/build-push-action@v5
env:
IMAGE_TAG: dev
with:
file: ./.docker/Dockerfile
push: true
tags: "ghcr.io/sparcs-kaist/zabo-server:${{ env.IMAGE_TAG }}"
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
- name: Remove old cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
32 changes: 32 additions & 0 deletions .github/workflows/dev-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Deploy to dev server

# when dev image build action is completed, run this action
on:
workflow_run:
workflows: ["Build docker image on push to develop"]
types:
- completed

jobs:
if_workflow_success:
name: Deploy to dev server
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}

steps:
- name: pull the image and restart the container
uses: appleboy/ssh-action@v1.0.0
with:
host: ${{ secrets.DEV_HOST }}
port: ${{ secrets.DEV_PORT }}
username: ${{ secrets.DEV_USERNAME }}
password: ${{ secrets.DEV_PASSWORD }}
proxy_host: ${{ secrets.DEV_PROXY_HOST }}
proxy_port: ${{ secrets.DEV_PROXY_PORT }}
proxy_username: ${{ secrets.DEV_PROXY_USERNAME }}
proxy_password: ${{ secrets.DEV_PROXY_PASSWORD }}
script_stop: true # stop script if any command has failed
script: |
cd ${{ secrets.DEV_WORKING_DIRECTORY }}
docker compose -f .docker/docker-compose.stage.yml -p zabo --env-file=.docker/.env.prod pull
docker compose -f .docker/docker-compose.stage.yml -p zabo --env-file=.docker/.env.prod up --force-recreate --build -d
Loading

0 comments on commit ec2e0af

Please sign in to comment.