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

Introduce mono repo #361

Merged
merged 29 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f774ae2
Introduce Mono Repo structure using pnpm
choidabom Sep 28, 2024
e2adfbc
Add setting for pnpm installation in docker
choidabom Sep 28, 2024
9c3e147
Change `pnpm ci` to `pnpm i` & `lint-staged` location
choidabom Sep 28, 2024
21d8f0a
Fix README.md about full stack development mode
choidabom Sep 28, 2024
8dd96e0
Change version in root package.json
choidabom Sep 28, 2024
1f112d0
Change formatting
choidabom Sep 28, 2024
0db47c5
Remove redundant pnpm installation step
choidabom Sep 28, 2024
c8a60f8
Use `pnpm install --frozen-lockfile` for CI environments
choidabom Sep 28, 2024
3eb94cd
Clarify instruction in README.md
choidabom Sep 28, 2024
eb58c80
Fix instructions about package.json and version
choidabom Sep 28, 2024
d114743
Add generate prisma script
choidabom Sep 28, 2024
f6ebdb4
Fix frontend build error
choidabom Sep 28, 2024
a52aaf2
Add dependency
choidabom Sep 28, 2024
2136ef7
Change off to error
choidabom Sep 28, 2024
f90623b
Change into new pnpm-lock.yaml
choidabom Sep 30, 2024
6530596
Add cache "pnpm" in CI
choidabom Sep 30, 2024
1251da7
Manage the version only in root `package.json`
choidabom Sep 30, 2024
59dd7cf
Remove version pnpm
choidabom Sep 30, 2024
e22b7c4
Add dockerfile
blurfx Sep 30, 2024
b4f121e
Delete ./backend/Dockerfile
choidabom Sep 30, 2024
9c2dd80
Add package.json version
choidabom Oct 1, 2024
4ed445f
Add necessary setting in Dockerfile
choidabom Oct 1, 2024
32458e7
Fix tab indentation and format script
choidabom Oct 1, 2024
a53ee47
Fix MAINTAINING.md
choidabom Oct 9, 2024
d8aa32f
Fix format
choidabom Oct 9, 2024
a698b51
Fix frontend, backend readme.md
choidabom Oct 9, 2024
7c4e837
Delete # @format in yaml
choidabom Oct 10, 2024
42d665d
Fix frontend readme.md
choidabom Oct 10, 2024
06ea66a
Fix Dockerfile and location of .dockerignore
choidabom Oct 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions .github/workflows/ci_backend.yaml
choidabom marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# @format

name: CI Backend
on:
push:
Expand All @@ -22,20 +24,27 @@ jobs:
env:
working-directory: ./backend
steps:
- uses: actions/checkout@v4
- name: Checkout 🛎️
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "pnpm"
- name: Install packages
run: npm ci
run: pnpm install --frozen-lockfile
working-directory: ${{ env.working-directory }}
- name: Generate prisma
run: pnpm db:generate
working-directory: ${{ env.working-directory }}
- name: Prettier
run: npm run format:check
run: pnpm run format:check
working-directory: ${{ env.working-directory }}
- name: Lint
run: npm run lint
run: pnpm run lint
working-directory: ${{ env.working-directory }}
- name: Build
run: npm run build
run: pnpm run build
working-directory: ${{ env.working-directory }}
16 changes: 11 additions & 5 deletions .github/workflows/ci_frontend.yaml
choidabom marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# @format

choidabom marked this conversation as resolved.
Show resolved Hide resolved
name: CI Frontend
on:
push:
Expand All @@ -22,20 +24,24 @@ jobs:
env:
working-directory: ./frontend
steps:
- uses: actions/checkout@v4
- name: Checkout 🛎️
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "pnpm"
- name: Install packages
run: npm ci
run: pnpm install --frozen-lockfile
working-directory: ${{ env.working-directory }}
- name: Prettier
run: npm run format:check
run: pnpm run format:check
working-directory: ${{ env.working-directory }}
- name: Lint
run: npm run lint
run: pnpm run lint
working-directory: ${{ env.working-directory }}
- name: Build
run: npm run build
run: pnpm run build
working-directory: ${{ env.working-directory }}
13 changes: 8 additions & 5 deletions .github/workflows/gh_pages.yaml
choidabom marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# @format

name: GitHub Page Publish

on:
Expand All @@ -12,13 +14,14 @@ jobs:
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Setup Node 🔧
uses: actions/setup-node@v4
with:
node-version: "18"
cache: "npm"
cache-dependency-path: frontend/package-lock.json
cache: "pnpm"
cache-dependency-path: pnpm-lock.yaml

- name: Setup Sentry Env 🛠️
working-directory: ${{ env.working-directory }}
Expand All @@ -32,8 +35,8 @@ jobs:
env:
NODE_OPTIONS: "--max_old_space_size=4096"
run: |
npm ci
npm run build
pnpm install --frozen-lockfile
pnpm run build

- name: Deploy 🚀
uses: JamesIves/[email protected]
Expand Down
51 changes: 51 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Stage 1: build codepair backend
# Start from the node base image
FROM node:alpine3.18 AS base
choidabom marked this conversation as resolved.
Show resolved Hide resolved
# Set pnpm installation directory and add it to the PATH
RUN corepack enable
RUN corepack use pnpm@9

# Download dependency for Prisma
RUN apk upgrade --update-cache --available && \
apk add openssl && \
rm -rf /var/cache/apk/*
choidabom marked this conversation as resolved.
Show resolved Hide resolved

# Download dependencies for Puppeteer
RUN apk add --no-cache \
chromium \
nss \
freetype \
harfbuzz \
ca-certificates \
ttf-freefont
choidabom marked this conversation as resolved.
Show resolved Hide resolved

# Download Korean font for Puppeteer
RUN mkdir /usr/share/fonts/nanumfont && \
wget http://cdn.naver.com/naver/NanumFont/fontfiles/NanumFont_TTF_ALL.zip && \
choidabom marked this conversation as resolved.
Show resolved Hide resolved
unzip NanumFont_TTF_ALL.zip -d /usr/share/fonts/nanumfont && \
fc-cache -f -v

# Set the environment variables
ENV NODE_ENV production
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
ENV PUPPETEER_EXECUTABLE_PATH /usr/bin/chromium-browser
choidabom marked this conversation as resolved.
Show resolved Hide resolved

# Stage 2: build stage
FROM base AS build
COPY . /usr/src/app
WORKDIR /usr/src/app
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm backend db:generate
RUN pnpm backend build
RUN pnpm deploy --filter=backend --prod /prod/backend
WORKDIR /prod/backend
RUN pnpx prisma generate
choidabom marked this conversation as resolved.
Show resolved Hide resolved

# Stage 3: deploy stage
FROM base AS backend
COPY --from=build /prod/backend /prod/backend
WORKDIR /prod/backend
choidabom marked this conversation as resolved.
Show resolved Hide resolved
EXPOSE 3000

# Run the backend server
CMD ["pnpm", "run", "start:prod"]
choidabom marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 4 additions & 2 deletions MAINTAINING.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<!-- @format -->

# Maintaining CodePair

## Releasing a New Version

### 1. Update the version number.

- Update `version` in [package.json in `frontend/`](https://github.com/yorkie-team/codepair/blob/1f10dff1d9c253f921ba136c812383fbb292078f/frontend/package.json#L5) and [package.json in `backend/`](https://github.com/yorkie-team/codepair/blob/1f10dff1d9c253f921ba136c812383fbb292078f/backend/package.json#L3).
- Update `version` in `package-lock.json` in `frontend/` and `backend/`. It will be automatically updated when you run `npm install`.
- Update the `version` field in the root `package.json` file to reflect the overall version of the monorepo.
- Also, update `version` fields in the [`frontend` package.json](https://github.com/yorkie-team/codepair/blob/1f10dff1d9c253f921ba136c812383fbb292078f/frontend/package.json#L3) and [`backend` package.json](https://github.com/yorkie-team/codepair/blob/1f10dff1d9c253f921ba136c812383fbb292078f/backend/package.json#L3).

### 2. Write changelog of this version in [CHANGELOG.md](https://github.com/yorkie-team/codepair/blob/main/CHANGELOG.md).

Expand Down
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,19 @@ We offer two options. Choose the one that best suits your needs:
docker-compose -f ./backend/docker/docker-compose-full.yml up -d
```

3. Run the Frontend application:
3. Install dependencies from the root.

```bash
cd frontend
npm install
npm run dev
pnpm install
```

4. Visit http://localhost:5173 to enjoy your CodePair.
4. Run the Frontend application.

```bash
pnpm frontend dev
```

5. Visit http://localhost:5173 to enjoy your CodePair.

### 3-2. Full Stack Development Mode

Expand All @@ -91,20 +95,17 @@ We offer two options. Choose the one that best suits your needs:
docker-compose -f ./backend/docker/docker-compose.yml up -d
```

3. Run the Backend application:
3. Install dependencies from the root.

```bash
cd backend
npm install
npm run start:dev
pnpm install
```

4. Run the Frontend application:
4. Run the Backend application and the Frontend application:

```bash
cd ../frontend
npm install
npm run dev
pnpm backend start:dev
pnpm frontend dev
```

5. Visit http://localhost:5173 to enjoy your CodePair.
Expand Down
22 changes: 0 additions & 22 deletions backend/.eslintrc.js

This file was deleted.

69 changes: 0 additions & 69 deletions backend/Dockerfile
devleejb marked this conversation as resolved.
Outdated
Show resolved Hide resolved

This file was deleted.

23 changes: 14 additions & 9 deletions backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,20 @@ This project is the backend part of the CodePair service developed using NestJS.
docker-compose -f ./backend/docker/docker-compose.yml up -d
```

4. Run the Backend application:
4. Install dependencies from the root.

```bash
cd backend
npm install
npm run start:dev
pnpm install
```

5. Visit http://localhost:3000 to enjoy your CodePair.
5. Run the Backend application:

```bash
# In the root directory of the repository and run.
pnpm backend start:dev
```

6. Visit http://localhost:3000 to enjoy your CodePair.

## API Specification

Expand All @@ -46,31 +51,31 @@ You can access the Swagger-based REST API specification at `<API_URL>/api` when
### Building the Project:

```bash
npm run build
pnpm backend build
```

Builds the project.

### Linting the Code:

```bash
npm run lint
pnpm backend lint
```

Lints TypeScript files using ESLint. Fixes any fixable linting errors.

### Testing:

```bash
npm test
pnpm backend test
```

Runs unit tests using Jest.

### Running in Production:

```bash
npm start
pnpm backend start
```

Starts the server in production mode.
Expand Down
Loading