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

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7d3cacb
Introduce Mono Repo structure using pnpm
choidabom Sep 28, 2024
3064751
Add setting for pnpm installation in docker
choidabom Sep 28, 2024
4a0ff83
Change `pnpm ci` to `pnpm i` & `lint-staged` location
choidabom Sep 28, 2024
836aa77
Fix README.md about full stack development mode
choidabom Sep 28, 2024
b4e48c2
Change version in root package.json
choidabom Sep 28, 2024
3c75f6d
Change formatting
choidabom Sep 28, 2024
e3bdd88
Remove redundant pnpm installation step
choidabom Sep 28, 2024
c314c71
Use `pnpm install --frozen-lockfile` for CI environments
choidabom Sep 28, 2024
660ddd1
Clarify instruction in README.md
choidabom Sep 28, 2024
8ab1cf9
Fix instructions about package.json and version
choidabom Sep 28, 2024
fadf68c
Add generate prisma script
choidabom Sep 28, 2024
83f6640
Fix frontend build error
choidabom Sep 28, 2024
08eac99
Add dependency
choidabom Sep 28, 2024
63bab7e
Change off to error
choidabom Sep 28, 2024
f13c77e
Change into new pnpm-lock.yaml
choidabom Sep 30, 2024
72cfdda
Add cache "pnpm" in CI
choidabom Sep 30, 2024
b67714c
Manage the version only in root `package.json`
choidabom Sep 30, 2024
f855fd6
Remove version pnpm
choidabom Sep 30, 2024
caeb0ca
Add dockerfile
blurfx Sep 30, 2024
5d42b95
Delete ./backend/Dockerfile
choidabom Sep 30, 2024
f5bc303
Add package.json version
choidabom Oct 1, 2024
ccc87b8
Add necessary setting in Dockerfile
choidabom Oct 1, 2024
705d825
Fix tab indentation and format script
choidabom Oct 1, 2024
4873db1
Fix prettier
blurfx Oct 1, 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

# Download Korean font for Puppeteer
RUN mkdir /usr/share/fonts/nanumfont && \
wget http://cdn.naver.com/naver/NanumFont/fontfiles/NanumFont_TTF_ALL.zip && \
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
5 changes: 3 additions & 2 deletions MAINTAINING.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<!-- @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`.
- CodePair uses global version management. Update the `version` field only in the root `package.json` file when making a release.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With global version management, the value of import.meta.env.PACKAGE_VERSION is undefined.
This value is injected by vite-plugin-package-version in frontend/vite.config.ts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I was confused. But, I'm not sure how much detail to explain.


### 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.

4 changes: 4 additions & 0 deletions backend/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore artifacts:
build
coverage
dist
69 changes: 0 additions & 69 deletions backend/Dockerfile

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 run build
```

Builds the project.

### Linting the Code:

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

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

### Testing:

```bash
npm test
pnpm test
```

Runs unit tests using Jest.

### Running in Production:

```bash
npm start
pnpm start
```

Starts the server in production mode.
Expand Down
Loading