๐ฅณ ์นด์ฐํ๋ง๋ด v 2.0.0 ๐ฅณ
์ฐ๊ฒฐ
https://github.com/EndyKaufman/kaufman-bot - ๋ด์ ์์ค ์ฝ๋
https://telegram.me/KaufmanBot - ์ ๋ณด์ ํ์ฌ ๋ด
https://telegram.me/DevelopKaufmanBot - ํ ๋ ๊ทธ๋จ์ ํ์ฌ ๋ด(develop-branch)
github์์ ์ ํ๊ฒฝ "prod" ๋ง๋ค๊ธฐ
Dialogflow ํ๋ก์ ํธ ๋ง๋ค๊ธฐ
- ์ ํ๋ฆฌ์ผ์ด์ ์ Dialogflow๋ฅผ ์ถ๊ฐํ๋ ๋ฐฉ๋ฒ
์๋ฒ ํ๊ฒฝ ๋ง๋ค๊ธฐ
ํธ์คํธ ์ถ๊ฐ
SSH ํค ์ถ๊ฐ
- ssh ํค ์์ฑ ๋ฐฉ๋ฒ
๋ฐ์ดํฐ๋ฒ ์ด์ค ์ต์ ์์ฑ
๋ฃจํธ ๋น๋ฐ๋ฒํธ ์ถ๊ฐ
์ ํ๋ฆฌ์ผ์ด์ ์ฐ๊ฒฐ ๋ฌธ์์ด ์ถ๊ฐ
- ๋ฐ์ดํฐ๋ฒ ์ด์ค ์์ ์ค์ ๋ฐฉ๋ฒ
ํ ๋ ๊ทธ๋จ ํ๊ฒฝ ๋ง๋ค๊ธฐ
ํ๋ก๋์ ์ฉ ๋๋ฉ์ธ ์ถ๊ฐ
์นํ ๊ฒฝ๋ก ์ถ๊ฐ
๊ฐ๋ฐ ๋จ๊ณ์์ ํธ์คํธ ๋ณ๊ฒฝ
VPS์ dokku ์ ํ๋ฆฌ์ผ์ด์ ์์ ํ ๋ ๊ทธ๋จ ํ ํฐ ์ ๊ฑฐ
dokku config:unset kaufman-bot TELEGRAM_BOT_TOKEN --no-restart
github์ ๊ฐ๋ฐ ๋จ๊ณ์ ํ ๋ ๊ทธ๋จ ํ ํฐ ์ถ๊ฐ
github์ prod ๋จ๊ณ์ ํ ๋ ๊ทธ๋จ ํ ํฐ ์ถ๊ฐ
- ํ ๋ ๊ทธ๋จ์์ ์นํ ์ฐ๊ฒฐํ๋ ๋ฐฉ๋ฒ
๋ด ๊ด๋ฆฌ์ ID ์ถ๊ฐ
- ๊ด๋ฆฌ์ ID ์ถ๊ฐ ๋ฐฉ๋ฒ
๋ค๋ฅธ ์ด๋ฆ ๋ด์ ๋ํ ํ๊ฒฝ ์ถ๊ฐ
์์ฐ ์ค
ํ๋ก๋์ ๋ฌ์์์ด
๊ฐ๋ฐ ์ค
๊ฐ๋ฐ ๋ฌ์์์ด
VPS์์ ์ ์ ํ๋ฆฌ์ผ์ด์ ๋ง๋ค๊ธฐ
- dokku์์ ์์ฉ ํ๋ก๊ทธ๋จ์ ๋ง๋๋ ๋ฐฉ๋ฒ
์ ํ๋ฆฌ์ผ์ด์ ๋ง๋ค๊ธฐ
dokku apps:create develop-kaufman-bot
root@vps17825:~# dokku apps:create develop-kaufman-bot
-----> Creating develop-kaufman-bot...
dokku ์ ํ๋ฆฌ์ผ์ด์ ์ ๋๋ฉ์ธ ์ฐ๊ฒฐ
domains:add develop-kaufman-bot develop-kaufman-bot.site15.ru
root@vps17825:~# dokku domains:add develop-kaufman-bot develop-kaufman-bot.site15.ru
-----> Added develop-kaufman-bot.site15.ru to develop-kaufman-bot
! No web listeners specified for develop-kaufman-bot
๋งํฌ SSL ์ธ์ฆ์์ ๊ฒฝ์ฐ ํ๋ก์ ํธ๋ฅผ ๋ฐฐํฌํด์ผ ํ๋ฉฐ ์ ๋ฒ์ ์ ๊ฐ๋ฐ ๋จ๊ณ๋ฅผ ๋ฐฐํฌํด์ผ ํฉ๋๋ค.
๊ฐ๋ฐ CI ๊ตฌ์ฑ ์ ๋ฐ์ดํธ
.github/workflows/develop.deploy.yml
name: 'deploy'
# yamllint disable-line rule:truthy
on:
push:
branches:
- develop
jobs:
migrate:
runs-on: [self-hosted, develop-vps]
environment: dev
steps:
- name: Cloning repo
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Apply migrations
run: |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
. ~/.nvm/nvm.sh
nvm --version
nvm install v16.13.2
nvm use v16.13.2
npm i --force
export POSTGRES_HOST=$(dokku postgres:info global-postgres --internal-ip)
export ROOT_POSTGRES_URL=postgres://postgres:${{secrets.ROOT_POSTGRES_PASSWORD}}@${POSTGRES_HOST}:5432/postgres?schema=public
export SERVER_POSTGRES_URL=${{secrets.SERVER_POSTGRES_URL}}
npm run rucken -- postgres
export DATABASE_URL=$SERVER_POSTGRES_URL && npm run migrate
export DEPLOY_DATE=$(date +'%Y-%m-%d %H:%M:%S')
export DEPLOY_COMMIT=$GITHUB_SHA
export DEPLOY_VERSION=$(node -pe "require('./package.json')['version']")
dokku config:set --no-restart develop-kaufman-bot SERVER_POSTGRES_URL=$SERVER_POSTGRES_URL
dokku config:set --no-restart --global POSTGRES_HOST=global-postgres
dokku config:set --no-restart develop-kaufman-bot GOOGLE_APPLICATION_CREDENTIALS=google-credentials.json
dokku config:set --no-restart develop-kaufman-bot GOOGLE_CREDENTIALS=${{secrets.GOOGLE_CREDENTIALS}}
dokku config:set --no-restart develop-kaufman-bot DIALOGFLOW_PROJECT_ID=${{secrets.DIALOGFLOW_PROJECT_ID}}
dokku config:set --no-restart develop-kaufman-bot TELEGRAM_BOT_WEB_HOOKS_DOMAIN=${{secrets.TELEGRAM_BOT_WEB_HOOKS_DOMAIN}}
dokku config:set --no-restart develop-kaufman-bot TELEGRAM_BOT_WEB_HOOKS_PATH=${{secrets.TELEGRAM_BOT_WEB_HOOKS_PATH}}
dokku config:set --no-restart develop-kaufman-bot TELEGRAM_BOT_ADMINS=${{secrets.TELEGRAM_BOT_ADMINS}}
dokku config:set --no-restart develop-kaufman-bot TELEGRAM_BOT_TOKEN=${{secrets.TELEGRAM_BOT_TOKEN}}
dokku config:set --no-restart develop-kaufman-bot DEPLOY_DATE="$DEPLOY_DATE"
dokku config:set --no-restart develop-kaufman-bot DEPLOY_COMMIT=$DEPLOY_COMMIT
dokku config:set --no-restart develop-kaufman-bot DEPLOY_VERSION=$DEPLOY_VERSION
dokku config:set --no-restart develop-kaufman-bot BOT_NAMES=${{secrets.BOT_NAMES}}
dokku config:set --no-restart develop-kaufman-bot BOT_NAMES_RU=${{secrets.BOT_NAMES_RU}}
deploy:
needs: [migrate]
runs-on: ubuntu-latest
environment: dev
steps:
- name: Cloning repo
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Push to dokku
uses: dokku/github-action@master
with:
branch: 'develop'
git_remote_url: 'ssh://dokku@${{secrets.HOST}}:22/develop-kaufman-bot'
ssh_private_key: ${{secrets.SSH_PRIVATE_KEY}}
ํ๋ก๋์ ๋ฐฐํฌ ๊ตฌ์ฑ ๋ง๋ค๊ธฐ
.github/workflows/master.deploy.yml
name: 'deploy'
# yamllint disable-line rule:truthy
on:
push:
branches:
- master
jobs:
migrate:
runs-on: [self-hosted, develop-vps]
environment: prod
steps:
- name: Cloning repo
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Apply migrations
run: |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
. ~/.nvm/nvm.sh
nvm --version
nvm install v16.13.2
nvm use v16.13.2
npm i --force
export POSTGRES_HOST=$(dokku postgres:info global-postgres --internal-ip)
export ROOT_POSTGRES_URL=postgres://postgres:${{secrets.ROOT_POSTGRES_PASSWORD}}@${POSTGRES_HOST}:5432/postgres?schema=public
export SERVER_POSTGRES_URL=${{secrets.SERVER_POSTGRES_URL}}
npm run rucken -- postgres
export DATABASE_URL=$SERVER_POSTGRES_URL && npm run migrate
export DEPLOY_DATE=$(date +'%Y-%m-%d %H:%M:%S')
export DEPLOY_COMMIT=$GITHUB_SHA
export DEPLOY_VERSION=$(node -pe "require('./package.json')['version']")
dokku config:set --no-restart kaufman-bot SERVER_POSTGRES_URL=$SERVER_POSTGRES_URL
dokku config:set --no-restart --global POSTGRES_HOST=global-postgres
dokku config:set --no-restart kaufman-bot GOOGLE_APPLICATION_CREDENTIALS=google-credentials.json
dokku config:set --no-restart kaufman-bot GOOGLE_CREDENTIALS=${{secrets.GOOGLE_CREDENTIALS}}
dokku config:set --no-restart kaufman-bot DIALOGFLOW_PROJECT_ID=${{secrets.DIALOGFLOW_PROJECT_ID}}
dokku config:set --no-restart kaufman-bot TELEGRAM_BOT_WEB_HOOKS_DOMAIN=${{secrets.TELEGRAM_BOT_WEB_HOOKS_DOMAIN}}
dokku config:set --no-restart kaufman-bot TELEGRAM_BOT_WEB_HOOKS_PATH=${{secrets.TELEGRAM_BOT_WEB_HOOKS_PATH}}
dokku config:set --no-restart kaufman-bot TELEGRAM_BOT_ADMINS=${{secrets.TELEGRAM_BOT_ADMINS}}
dokku config:set --no-restart kaufman-bot TELEGRAM_BOT_TOKEN=${{secrets.TELEGRAM_BOT_TOKEN}}
dokku config:set --no-restart kaufman-bot DEPLOY_DATE="$DEPLOY_DATE"
dokku config:set --no-restart kaufman-bot DEPLOY_COMMIT=$DEPLOY_COMMIT
dokku config:set --no-restart kaufman-bot DEPLOY_VERSION=$DEPLOY_VERSION
dokku config:set --no-restart kaufman-bot BOT_NAMES=${{secrets.BOT_NAMES}}
dokku config:set --no-restart kaufman-bot BOT_NAMES_RU=${{secrets.BOT_NAMES_RU}}
deploy:
needs: [migrate]
runs-on: ubuntu-latest
environment: prod
steps:
- name: Cloning repo
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Push to dokku
uses: dokku/github-action@master
with:
branch: 'master'
git_remote_url: 'ssh://dokku@${{secrets.HOST}}:22/kaufman-bot'
ssh_private_key: ${{secrets.SSH_PRIVATE_KEY}}
ํ์ฌ ๋ณ๊ฒฝ ์ฌํญ ์ปค๋ฐ
git push
๊ธฐ๋ฅ/73 ๋ถ๊ธฐ๋ฅผ ๋ณํฉํ์ฌ ๊ฐ๋ฐ
git checkout develop
git merge feature/73
git push
ํ๋ก๋์ ๋ฐฐํฌ
๋ฆด๋ฆฌ์ค ๋ง๋ค๊ธฐ
npm run app:create-release
๋ฆด๋ฆฌ์ค๋ฅผ ๋ง์คํฐ์ ๋ณํฉ
git checkout merge
git merge develop
git push
ํ ๋ ๊ทธ๋จ์์ ์์ฐ ๋ด ํ์ธ
๋ค์ ํฌ์คํธ์์๋ ๋ชจ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ npm ๋ ์ง์คํธ๋ฆฌ์ ๊ฒ์ํ๊ณ ์ด๋ฅผ ์ฌ์ฉํ์ฌ ์ํ ๋ฆฌํฌ์งํ ๋ฆฌ๋ฅผ ์์ฑํฉ๋๋ค...
Reference
์ด ๋ฌธ์ ์ ๊ดํ์ฌ(๐ฅณ ์นด์ฐํ๋ง๋ด v 2.0.0 ๐ฅณ), ์ฐ๋ฆฌ๋ ์ด๊ณณ์์ ๋ ๋ง์ ์๋ฃ๋ฅผ ๋ฐ๊ฒฌํ๊ณ ๋งํฌ๋ฅผ ํด๋ฆญํ์ฌ ๋ณด์๋ค https://dev.to/endykaufman/kaufmanbot-v-200-1041ํ ์คํธ๋ฅผ ์์ ๋กญ๊ฒ ๊ณต์ ํ๊ฑฐ๋ ๋ณต์ฌํ ์ ์์ต๋๋ค.ํ์ง๋ง ์ด ๋ฌธ์์ URL์ ์ฐธ์กฐ URL๋ก ๋จ๊ฒจ ๋์ญ์์ค.
์ฐ์ํ ๊ฐ๋ฐ์ ์ฝํ ์ธ ๋ฐ๊ฒฌ์ ์ ๋ (Collection and Share based on the CC Protocol.)
์ข์ ์นํ์ด์ง ์ฆ๊ฒจ์ฐพ๊ธฐ
๊ฐ๋ฐ์ ์ฐ์ ์ฌ์ดํธ ์์ง
๊ฐ๋ฐ์๊ฐ ์์์ผ ํ ํ์ ์ฌ์ดํธ 100์ ์ถ์ฒ ์ฐ๋ฆฌ๋ ๋น์ ์ ์ํด 100๊ฐ์ ์์ฃผ ์ฌ์ฉํ๋ ๊ฐ๋ฐ์ ํ์ต ์ฌ์ดํธ๋ฅผ ์ ๋ฆฌํ์ต๋๋ค