-
Notifications
You must be signed in to change notification settings - Fork 0
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
build: 개발용 docker compose 파일 #67
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# 42seoul_club_42jiphyeonjeon_dev 캔버스 참고: | ||
# https://42born2code.slack.com/canvas/C03BAMF3727 | ||
|
||
MYSQL_DATABASE=jip_serv | ||
MYSQL_USER=saseo | ||
MYSQL_PASSWORD= | ||
MYSQL_ROOT_PASSWORD= | ||
MYSQL_HOST="127.0.0.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
### Node ### | ||
node_modules/ | ||
|
||
.env* | ||
!.env.example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,67 @@ | ||
# backend-nest | ||
|
||
6차 개발팀은 nestjs 로 새로 작성하기로 했습니다 | ||
|
||
## 개발 환경 설정 | ||
|
||
### 환경 변수 | ||
|
||
[.env.example](./.env.example)의 내용을 참고하여 루트 디렉토리에 `.env` 파일을 생성합니다. | ||
|
||
### 백엔드 | ||
|
||
```sh | ||
$ brew install corepack | ||
$ corepack enable | ||
``` | ||
|
||
[corepack](https://github.com/nodejs/corepack?tab=readme-ov-file#how-to-install)으로 pnpm을 설치합니다. | ||
|
||
> [!NOTE] | ||
> mac OS 환경에서는 `corepack` 패키지가 `yarn`과 `pnpm` 패키지와 충돌이 있을 수 있습니다. | ||
> 이 경우 두 패키지를 모두 삭제하고 `corepack`을 설치해야 합니다. | ||
|
||
```sh | ||
$ pnpm install | ||
``` | ||
|
||
프로젝트 의존성을 설치합니다. | ||
|
||
### DB | ||
|
||
```sh | ||
$ docker compose -f compose-dev.yml up --remove-orphans | ||
# (다른 터미널에서) | ||
$ docker compose -f compose-dev.yml exec database /bin/sh | ||
# mysql -h 127.0.0.1 -P 3306 -u root -p | ||
mysql> use jip_serv; | ||
mysql> source /내려받은/DB/덤프/파일/경로.sql; | ||
``` | ||
|
||
초기 실행 시 [DB 덤프 파일](https://discord.com/channels/1277878039090565139/1277878039593619468/1278599701532377088)을 사용해 [데이터베이스를 초기화해야 합니다.](https://stackoverflow.com/questions/17666249/how-to-import-an-sql-file-using-the-command-line-in-mysql) | ||
|
||
``` | ||
mysql> show databases; | ||
+--------------------+ | ||
| Database | | ||
+--------------------+ | ||
| information_schema | | ||
| jip_serv | | ||
| performance_schema | | ||
+--------------------+ | ||
3 rows in set (0.01 sec) | ||
``` | ||
|
||
다음과 같이 데이터베이스가 생성되어 있는지 확인합니다. | ||
|
||
### docker compose 실행 | ||
|
||
```sh | ||
$ pnpm dev | ||
``` | ||
|
||
위 명령어로 개발용 docker compose를 실행합니다. | ||
|
||
![](./swagger.webp) | ||
|
||
<http://localhost:3000/api> 경로에 접근하여 API 명세가 올바르게 표시되는지 확인합니다. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM node:22-slim AS base | ||
ENV PNPM_HOME="/pnpm" | ||
ENV PATH="$PNPM_HOME:$PATH" | ||
RUN corepack enable | ||
|
||
WORKDIR /app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,5 +76,6 @@ | |
], | ||
"coverageDirectory": "../coverage", | ||
"testEnvironment": "node" | ||
} | ||
}, | ||
"packageManager": "[email protected]+sha512.4abf725084d7bcbafbd728bfc7bee61f2f791f977fd87542b3579dcb23504d170d46337945e4c66485cd12d588a0c0e570ed9c477e7ccdd8507cf05f3f92eaca" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
services: | ||
database: | ||
platform: linux/x86_64 | ||
container_name: database | ||
image: mysql:8.0 | ||
environment: | ||
- TZ=Asia/Seoul | ||
|
||
ports: | ||
- 3306:3306 | ||
|
||
env_file: .env | ||
|
||
backend: | ||
container_name: backend | ||
restart: on-failure | ||
build: | ||
context: backend | ||
dockerfile: Dockerfile.dev | ||
|
||
entrypoint: ["pnpm", "run", "start:dev"] | ||
volumes: | ||
- ./backend:/app | ||
- ./backend/logs:/app/backend/logs | ||
ports: | ||
- 3000:3000 | ||
environment: | ||
- MYSQL_HOST=database | ||
env_file: .env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packageManager 가 어떤 역할을 하는지 알려주시면 감사하겠습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packagemanager는 corepack에서 사용할 패키지 매니저 (npm, yarn, pnpm 등) 버전을 고정하기 위해 사용하는 식별자입니다. 다음을 참고해주세요: