Skip to content

sparcs-kaist/otlplus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

OTL PLUS

Online Timeplanner with Lectures Plus @ KAIST https://otl.kaist.ac.kr/

์ฑ„๋„

๋””์ž์ธ

๊ฐœ๋ฐœ ํ™˜๊ฒฝ ์„ค์ •

0. ์ค€๋น„์š”๊ฑด

  • Docker๊ฐ€ ์„ค์น˜๋˜์–ด ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
  • Windows์˜ ๊ฒฝ์šฐ wsl shell์—์„œ ๋ช…๋ น์–ด๋“ค์„ ์‹คํ–‰ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
  • Frontend๋Š” 3000, Backend๋Š” 58000, DB๋Š” 53306 ํฌํŠธ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ์ด ํฌํŠธ๋“ค์€ ์‚ฌ์šฉ๋˜์ง€ ์•Š์€ ์ƒํƒœ์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค.

1. Git cloneํ•˜๊ธฐ

git clone https://github.com/sparcs-kaist/otlplus
cd otlplus

2. Secret ์„ค์ •ํ•˜๊ธฐ

โš ๏ธ ์ดˆ๊ธฐ ์„ค์ •์—๋งŒ ๋‹ค์Œ์˜ Secret ์„ค์ •๋“ค์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.

Django secret ์„ค์ •ํ•˜๊ธฐ

DJANGO_SECRET_KEY๋Š” ์ž„์˜์˜ ๋ฌธ์ž์—ด์„ ์‚ฌ์šฉํ•ด๋„ ๋ฌด๊ด€ํ•ฉ๋‹ˆ๋‹ค.

mkdir keys && touch ./keys/sso_secret && echo "DJANGO_SECRET_KEY" > ./keys/django_secret

SPARCS SSO secret ์„ค์ •ํ•˜๊ธฐ

  1. SPARCS ๊ณ„์ •์œผ๋กœ sparcssso.kaist.ac.kr ๋กœ๊ทธ์ธํ•œ ํ›„ ์ƒ๋‹จ์˜ Dev Center๋กœ ์ ‘์†
  2. Test Services์˜ register๋ฅผ ๋ˆ„๋ฆ…๋‹ˆ๋‹ค.
  3. ๋‹ค์Œ์˜ ์ •๋ณด๋ฅผ ์ž…๋ ฅํ•˜์—ฌ Test Service๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.

Alias: (Any name)
Main URL: http://localhost:3000
Login Callback URL: http://localhost:58000/session/login/callback
Unregister URL: http://localhost:58000/session/unregister
Cooltime: 0

  1. Dev Center ํ™ˆ์œผ๋กœ ๋Œ์•„๊ฐ€ ์ƒ์„ฑ๋œ Test Service์— ์œ„์น˜ํ•œ Modify ๋ฒ„ํŠผ์„ ๋ˆ„๋ฆ…๋‹ˆ๋‹ค.
  2. otlplus ํด๋”์— ./settings_local.py๋ฅผ ์ƒ์„ฑํ•œ ํ›„ 4์—์„œ ๋“ค์–ด๊ฐ„ ํŽ˜์ด์ง€์— ์ ํžŒ Name๊ณผ Secret Key๋ฅผ ์ฐธ๊ณ ํ•˜์—ฌ ๋‹ค์Œ์˜ ํ˜•์‹์œผ๋กœ ์ž‘์„ฑํ•ฉ๋‹ˆ๋‹ค.
SSO_IS_BETA = False
SSO_CLIENT_ID = "test0000000000000000" # SSO์˜ 'Name' (๋˜๋Š” 'Client ID') ํ•„๋“œ
SSO_SECRET_KEY = "00000000000000000000" # SSO์˜ 'Secret Key' ํ•„๋“œ

3. Backend ์‹œ์ž‘ํ•˜๊ธฐ

Backend๋ฅผ ์‹œ์ž‘ํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด otlplus ํด๋”์—์„œ ๋‹ค์Œ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.

OTLPLUS_DB_PASSWORD=p@ssw0rd docker compose up

WSL์—์„œ docker ๋ช…๋ น์–ด ์—†์Œ์œผ๋กœ ๋œฌ๋‹ค๋ฉด,
Docker ์‹คํ–‰ ํ›„ settings > resources >wsl integration >enable integration with ~ ๋ฅผ ์ผœ์ค๋‹ˆ๋‹ค.

[์ดˆ๊ธฐ ํ•„์ˆ˜] Migrateํ•˜๊ธฐ

โš ๏ธ ์ดˆ๊ธฐ ์„ค์ •์ด๊ฑฐ๋‚˜ DB ๊ตฌ์กฐ๊ฐ€ ๋ณ€๊ฒฝ๋œ ๊ฒฝ์šฐ์—๋งŒ ๋‹ค์Œ์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.

  1. docker compose up์„ ์‹คํ–‰ํ•œ ๋ฐฉ๊ธˆ ํ„ฐ๋ฏธ๋„์„ ๊ทธ๋Œ€๋กœ ๋‘ก๋‹ˆ๋‹ค.
  2. ์ƒˆ๋กœ์šด ํ„ฐ๋ฏธ๋„์„ ์ผญ๋‹ˆ๋‹ค.
  3. ๋‹ค์Œ์„ ํ•œ ์ค„์”ฉ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.
docker exec -it otlplus-back /bin/bash
python manage.py migrate
exit

[์„ ํƒ] DB Dump ํŒŒ์ผ ์ ์šฉํ•˜๊ธฐ

โš ๏ธ ๊ธฐ์กด DB Dump ํŒŒ์ผ์„ ์ ์šฉํ•˜๊ณ  ์‹ถ์€ ๊ฒฝ์šฐ์—๋งŒ ๋‹ค์Œ์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.

  1. ๋‹ด๋‹น์ž์—๊ฒŒ ์š”์ฒญํ•ด์„œ dump.sql ํŒŒ์ผ์„ ๋‹ค์šด๋กœ๋“œ ๋ฐ›์Šต๋‹ˆ๋‹ค.
  2. otlplus ํด๋” ๊ธฐ์ค€ ./volumes/dump/dump.sql ๊ฒฝ๋กœ๋กœ dump.sql์„ ์˜ฎ๊น๋‹ˆ๋‹ค.
  3. ๋‹ค์Œ์„ ํ•œ ์ค„์”ฉ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.
docker exec -it otlplus-db /bin/bash
mysql -uroot -p'p@ssw0rd' -Dotlplus < /dump/dump.sql
exit

4.Frontend ์‹œ์ž‘ํ•˜๊ธฐ

ํ”„๋ก ํŠธ์—”๋“œ ์ฝ”๋“œ๋Š” otlplus-web ๋ ˆํฌ์— ์žˆ์Šต๋‹ˆ๋‹ค. ์•„๋ž˜ ๋ช…๋ น์–ด์™€ ๊ฐ™์ด ์›ํ•˜๋Š” ์œ„์น˜์— ํ•ด๋‹น ๋ ˆํฌ๋ฅผ ํด๋ก ํ•œ ํ›„ ์‹คํ–‰ํ•ด ์ฃผ์„ธ์š”.

cd ..
git clone https://github.com/sparcs-kaist/otlplus-web
cd otlplus-web

npm i
npm start

5. DB ์ ‘์†ํ•˜๊ธฐ

DB ์ ‘์†์„ ์›ํ•˜๋Š” ๊ฒฝ์šฐ ๋‹ค์Œ์˜ ์ •๋ณด๋ฅผ ์‚ฌ์šฉํ•˜์„ธ์š”.

host: localhost
port: 53306
user: root
password: p@ssw0rd
name: otlplus

6. ์ •๋ฆฌํ•˜๊ธฐ

๋งŒ์•ฝ ์‹คํ–‰ํ–ˆ๋˜ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์„ ์ •๋ฆฌํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด ์•„๋ž˜ ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”.

docker compose down
rm -rf ./volumes/db

TroubleShooting

(Windows) git clone์‹œ ์œ ์˜์‚ฌํ•ญ

local window์— clone ํ›„, wsl shell๋กœ ์‹คํ–‰ํ•˜๋ฉด ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค. (local window์— cloneํ•˜๋ฉด user@desktop:mnt/ ์—์„œ ์‹คํ–‰๋ฉ๋‹ˆ๋‹ค.)

wsl2 shell์„ ์‹คํ–‰ํ•œ ๋’ค, wsl2 shell ์ƒ์—์„œ git clone์„ ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

(Windows) wsl ์ƒ์—์„œ docker compose up ์‹œ ์œ ์˜์‚ฌํ•ญ

docker ๋ช…๋ น์–ด ์—†๋‹ค๋Š” ์ฝ˜์†”์ฐฝ์ด ๋œจ๋ฉด ์•„๋ž˜ ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•˜์—ฌ wsl version์ด 1์ธ distro๋ฅผ ํ™•์ธ ํ•œ ๋’ค, wsl version 2๋กœ ๋ฐ”๊พธ์–ด์ค๋‹ˆ๋‹ค.

wsl.exe -l -v 
wsl.exe --set-version (distro name) 2 

๊ฐœ๋ฐœ ํ™˜๊ฒฝ ์„ค์ • (Deprecated)

2023.5.5. ๊นŒ์ง€ ์‚ฌ์šฉํ–ˆ๋˜ Docker Compose ์—†๋Š” ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์ž…๋‹ˆ๋‹ค.

Django ํ™˜๊ฒฝ ์„ค์ •

Working directory: PROJECT_ROOT @sboh1214: [email protected] ๊ณผ [email protected] ์—์„œ ์ •์ƒ์ž‘๋™ ํ™•์ธํ•˜์˜€์Šต๋‹ˆ๋‹ค. (2023-03-10)

# ๊ฐ€์ƒํ™˜๊ฒฝ ์„ค์ •
$ python3 -m venv env # Python ๋ฒ„์ „ 3.6 ์ด์ƒ ๊ถŒ์žฅ
$ source env/bin/activate

# ํŒจํ‚ค์ง€ ์„ค์น˜
$ pip install -r requirements.txt # unixodbc, [email protected] ๋“ฑ์„ ๋จผ์ € ์„ค์น˜ํ•ด์•ผ ํ•  ์ˆ˜ ์žˆ์Œ (apt, brew ๋“ฑ์œผ๋กœ ์„ค์น˜)

# Secret key ์„ค์ •
$ mkdir keys
$ vi keys/django_secret # Random string ์ž…๋ ฅ, Django SECRET_KEY ๋ช…์„ธ ์ฐธ๊ณ 
$ touch keys/sso_secret

# DB migrate
$ python manage.py migrate

๋งŒ์•ฝ ํŒŒ์ด์ฌ ํŒจํ‚ค์ง€ ์„ค์น˜๊ฐ€ ์ •์ƒ์ ์œผ๋กœ ์ด๋ฃจ์–ด์ง€์ง€ ์•Š๋Š”๋‹ค๋ฉด ์•„๋ž˜ ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.

pip install -r requirements.txt --use-feature=2020-resolver

๊ฐœ๋ฐœ์šฉ DB ์„ค์ • (Optional)

dump ๋ฐ์ดํ„ฐ๋Š” PM์—๊ฒŒ ์š”์ฒญํ•˜์„ธ์š”.
Working directory: PROJECT_ROOT

# Dump ํŒŒ์ผ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ
$ python manage.py load-dev-data dumps/otldump_DATE_info.json

SPARCS SSO ์„ค์ •

SSO ์„ค์ • ๋ฐฉ๋ฒ•์€ ๋ณ€๊ฒฝ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. SSO ๊ณต์‹ ์„ค์ • ๋ฐฉ๋ฒ•์„ ์ฐธ๊ณ ํ•˜์„ธ์š”.
URL: sparcssso.kaist.ac.kr > Dev Center > Test Services > Register

Alias: (Any name)
Main URL: http://localhost:8000
Login Callback URL: http://localhost:8000/session/login/callback
Unregister URL: http://localhost:8000/session/unregister
Cooltime: 0

Working directory: PROJECT_ROOT

$ vi settings_local.py

File: PROJECT_ROOT/settings_local.py

# ...

SSO_IS_BETA = False
SSO_CLIENT_ID = "test0000000000000000" # SSO์˜ 'Name' (๋˜๋Š” 'Client ID') ํ•„๋“œ
SSO_SECRET_KEY = "00000000000000000000" # SSO์˜ 'Secret Key' ํ•„๋“œ

React ํ™˜๊ฒฝ ์„ค์ •

Working directory: PROJECT_ROOT/react

# ํŒจํ‚ค์ง€ ์„ค์น˜
$ npm install

# ๊ฐœ๋ฐœ ์„œ๋ฒ„ ์‹คํ–‰
$ npm start

# ํ”„๋กœ์ ํŠธ ๋นŒ๋“œ
$ npm run build

์„œ๋ฒ„ ์‹คํ–‰

Working directory: PROJECT_ROOT

$ python manage.py runserver 0.0.0.0:8000

์ด๋•Œ ๋ฐ˜๋“œ์‹œ ๋ธŒ๋ผ์šฐ์ €์—์„œ http://localhost:8000์œผ๋กœ ์ ‘์†ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

์—๋””ํ„ฐ ์„ค์ • (Optional, but highly recommended)

VSCode(Visual Studio Code) ๋ฐ ์•„๋ž˜ ์„ค์ •์„ ๊ถŒ์žฅํ•ฉ๋‹ˆ๋‹ค.

์„ค์ • ์ค‘ ์˜ค๋ฅ˜

DB migrate ์‹œ "... SQLite < 3.26 ..." ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค๋ฉด

์•„๋ž˜ ๋ช…๋ น์–ด๋กœ python์— ์ ์šฉ๋œ sqlite3 ๋ฒ„์ „ ํ™•์ธ

$ python -c "import sqlite3;print(sqlite3.sqlite_version)"

3.26.0 ์ดํ•˜๋ผ๋ฉด ๋†’์€ ๋ฒ„์ „์˜ python์œผ๋กœ ์žฌ์„ค์น˜ ํ›„ ์ฒ˜์Œ๋ถ€ํ„ฐ ์žฌ์„ค์ •

node-sass ์„ค์น˜ ์‹œ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค๋ฉด

  1. node-sass ํ˜ธํ™˜ node.js ๋ฒ„์ „์„ ํ™•์ธํ•ด์„œ ์ ์ ˆํ•œ ๋ฒ„์ „์„ ์‚ฌ์šฉ
  2. gyp: No Xcode or CLT version detected! ๋ผ๋Š” ๋ฉ”์‹œ์ง€์™€ ํ•จ๊ป˜ ์„ค์น˜์— ์‹คํŒจํ•œ๋‹ค๋ฉด ๊ด€๋ จ ์ด์Šˆ์˜ ์ฝ”๋ฉ˜ํŠธ ์ฐธ๊ณ 

mysqlclient ์„ค์น˜ ์‹œ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค๋ฉด

[email protected] (5.7 ๋ฒ„์ „์ด์–ด์•ผ ํ•˜๋Š” ์ด์œ ) ์„ ์„ค์น˜ ํ›„ PATH์— ํ•ด๋‹น ์‹คํ–‰ ํŒŒ์ผ ๋””๋ ‰ํ„ฐ๋ฆฌ๋ฅผ ์ถ”๊ฐ€ํ•œ๋‹ค. ์˜ˆ๋ฅผ ๋“ค๋ฉด (macOS ๊ธฐ์ค€),

$ brew install [email protected]
$ export PATH="/opt/homebrew/opt/[email protected]/bin:$PATH" # add this line to ~/.bashrc, .zshrc, etc.

์„ค์ • ์™„๋ฃŒ ํ›„ no-such-column ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค๋ฉด

์ผ๋ถ€ ์กฐ๊ฑด์—์„œ no such column: main_famoushumanityreviewdailyfeed_reviews.review_id ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Œ
Working directory: PROJECT_ROOT

# DB ์ดˆ๊ธฐํ™”
$ rm db.sqlite3
# DB migrate ์žฌ์‹คํ–‰
$ python manage.py migrate main 0006
$ python manage.py migrate review 0009
$ python manage.py migrate

์ดํ›„ ๊ฐœ๋ฐœ์šฉ DB ์„ค์ • ์žฌ์‹คํ–‰

(Apple Silicon) pip install์—์„œ pyobdc๊ฐ€ ์„ค์น˜๋˜์ง€ ์•Š๋Š”๋‹ค๋ฉด

/otlplus/include -arch arm64 -I/opt/homebrew/Caskroom/miniconda/base/envs/otlplus/include -arch arm64 -DPYODBC_VERSION=4.0.32 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/Caskroom/miniconda/base/envs/otlplus/include/python3.8 -c src/buffer.cpp -o build/temp.macosx-11.1-arm64-3.8/src/buffer.o -Wno-write-strings -Wno-deprecated-declarations
      In file included from src/buffer.cpp:12:
      src/pyodbc.h:56:10: fatal error: 'sql.h' file not found
      #include <sql.h>
               ^~~~~~~
      1 error generated.
      error: command '/usr/bin/gcc' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

ร— Encountered error while trying to install package.
โ•ฐโ”€> pyodbc

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

mkleehammer/pyodbc#846 (comment) ์ฐธ์กฐ

brew install unixodbc
export LDFLAGS="-L/opt/homebrew/lib"
export CFLAGS="-I/opt/homebrew/include"
export CPPFLAGS="-I/opt/homebrew/include"
pip install -r requirements.txt