Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸ“ [Docs] Ghostpong 싀행방법 #598

Open
jis-kim opened this issue Aug 4, 2023 · 0 comments
Open

πŸ“ [Docs] Ghostpong 싀행방법 #598

jis-kim opened this issue Aug 4, 2023 · 0 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@jis-kim
Copy link
Contributor

jis-kim commented Aug 4, 2023

1. Development ν™˜κ²½μœΌλ‘œ μ‹€ν–‰

개발 λ‹¨κ³„μ—μ„œ μ‹€μ‹œκ°„μœΌλ‘œ 컴파일이 ν•„μš”ν•œ 경우

  • backend directory μ—μ„œ .env.development μž‘μ„±

  • yarn -> yarn db -> yarn start:dev ν˜Ήμ€ yarn start:prod μ‹€ν–‰

  • seeding 이 ν•„μš”ν•˜λ‹€λ©΄ yarn seed [number] μ‹€ν–‰

    • 기쑴에 seeding 을 μ§„ν–‰ν•œ 적이 μžˆλ‹€λ©΄ volume (db_dev_data) 이 μ €μž₯되기 λ•Œλ¬Έμ— μ‹€ν–‰ν•˜μ§€ μ•Šμ•„λ„ λ©λ‹ˆλ‹€.
  • frontend directory μ—μ„œ yarn -> yarn dev ν˜Ήμ€ yarn prod μ‹€ν–‰

  • ν•„μˆ˜λ‘œ λ³€κ²½ν•΄μ•Ό ν•  κ°’

    • κΈ°μ‘΄ DB_ λ³€μˆ˜λ“€μ„ POSTGRES_ 둜 λ³€κ²½ν•΄μ£Όμ„Έμš”.
    • POSTGRES_HOST λŠ” localhost 둜 μ§€μ •ν•΄μ£Όμ„Έμš”.
    • λ‘œμ»¬μ— postgres κ°€ 돌고 있으면 κΈ°λ³Έ 포트인 5432 와 좩돌이 λ‚  수 있기 λ•Œλ¬Έμ— 가급적 5432 이외 μ‚¬μš©ν•˜μ§€ μ•ŠλŠ” 포트λ₯Ό ν™˜κ²½λ³€μˆ˜λ‘œ μ„€μ •ν•΄ μ£Όμ‹œκΈΈ λ°”λžλ‹ˆλ‹€.
    • db μ»¨ν…Œμ΄λ„ˆ λ‘œκ·Έκ°€ 이런 식이면 포트 좩돌일 κ°€λŠ₯성이 λ†’μŠ΅λ‹ˆλ‹€.
      Screenshot 2023-08-09 at 3 39 45 PM

    env.development

    NODE_ENV=development
    POSTGRES_PORT=
    POSTGRES_HOST=localhost
    POSTGRES_NAME=
    POSTGRES_USER=
    POSTGRES_PASSWORD=
    

2. Production ν™˜κ²½μœΌλ‘œ μ‹€ν–‰

server, client, DB λ₯Ό λͺ¨λ‘ λ„μ»€λΌμ΄μ§•ν•˜κ³  ν…ŒμŠ€νŠΈν•˜κ³  싢을 경우

  • backend directory μ—μ„œ .env μž‘μ„±

  • root directory μ—μ„œ docker compose up --build μ‹€ν–‰

  • ν•„μˆ˜λ‘œ λ³€κ²½ν•΄μ•Ό ν•  κ°’

    • κΈ°μ‘΄ DB_ λ³€μˆ˜λ“€μ„ POSTGRES_ 둜 λ³€κ²½ν•΄μ£Όμ„Έμš”.
    • POSTGRES_HOST λŠ” ghostgres 둜 μ§€μ •ν•΄μ£Όμ„Έμš”.

    .env

    NODE_ENV=production
    POSTGRES_PORT=
    POSTGRES_HOST=ghostgres
    POSTGRES_NAME=
    POSTGRES_USER=
    POSTGRES_PASSWORD=
    

이전 μ‹€ν–‰ 방법

nest.js app 초기 μ‹€ν–‰

backend 디렉토리 μ•ˆμ—μ„œ μ‹€ν–‰ν•΄μ£Όμ„Έμš”.

  • .env.sample 파일 μ°Έκ³ ν•΄μ„œ .env 파일 μž‘μ„±
  • yarn install
  • yarn db
  • yarn start:prod λ˜λŠ” yarn start:dev
    • yarn start:prod : NODE_ENV=production ν™˜κ²½λ³€μˆ˜ μ„€μ •ν•΄μ„œ ν΄λΌμ΄μ–ΈνŠΈκ°€ Authorization header둜 'token' λ‹΄μ•„μ„œ 톡신할 λ•Œ μ‚¬μš©
    • yarn start:dev : NODE_ENV=development ν™˜κ²½λ³€μˆ˜ μ„€μ •ν•΄μ„œ ν΄λΌμ΄μ–ΈνŠΈκ°€ x-my-id header둜 'user id' λ‹΄μ•„μ„œ 톡신할 λ•Œ μ‚¬μš©

DB ν…Œμ΄λΈ”μ΄ μ‘΄μž¬ν•˜λŠ” μƒνƒœμ—μ„œ μ‹€ν–‰

  • psql μ‹€ν–‰ 없이 yarn db ν›„ λ°”λ‘œ yarn run start ν•΄μ£Όμ‹œλ©΄ λ©λ‹ˆλ‹€.
  • yarn db:reset 으둜 λ³Όλ₯¨μ„ μ‚­μ œν•˜κ³  λ‹€μ‹œ 초기 μ‹€ν–‰ν•  μˆ˜λ„ μžˆμŠ΅λ‹ˆλ‹€.

DB seeding

  • .env νŒŒμΌμ— TEST_DB_NAME μ„€μ • λ˜μ—ˆλŠ”μ§€ ν™•μΈν•©λ‹ˆλ‹€. (ν•΄λ‹Ή ν™˜κ²½λ³€μˆ˜λ₯Ό μ½μ–΄μ„œ μ‹€ν–‰ν•©λ‹ˆλ‹€.)
  • yarn seed:reset && yarn seed [number]
    • yarn seed:reset μ‹œ ν…ŒμŠ€νŠΈ λ°μ΄ν„°λ² μ΄μŠ€κ°€ λ‚ μ•„κ°”λ‹€κ°€ λ‹€μ‹œ μƒμ„±λ˜λ―€λ‘œ μ‚¬μš©μ— μ£Όμ˜ν•΄μ£Όμ„Έμš”!
    • [number] μžλ¦¬μ—λŠ” μƒμ„±ν•˜κ³ μž ν•˜λŠ” auth 의 row 수λ₯Ό μž…λ ₯ν•©λ‹ˆλ‹€. ν™•λ₯ μ— 따라 user, friendship, message, game_history κ°€ μ°¨λ‘€λ‘œ μƒμ„±λ©λ‹ˆλ‹€.

Swagger

  • nest app μ‹€ν–‰ν•΄μ£Όμ‹œκ³  localhost:${APP_PORT}/api 둜 μ ‘μ†ν•˜μ‹œλ©΄ swagger 둜 ν…ŒμŠ€νŠΈ ν•˜μ‹€ 수 μžˆμŠ΅λ‹ˆλ‹€.
@jis-kim jis-kim added the documentation Improvements or additions to documentation label Aug 4, 2023
@jis-kim jis-kim self-assigned this Aug 4, 2023
@jis-kim jis-kim pinned this issue Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant