Skip to content

gurkanguray/monorepo

 
 

Repository files navigation

@kampus/monorepo

kamp.us web projects & packages

IMPORTANT NOTE

This repository is under heavy development, if you want to contribute either go through package.json file of each workspace and start familiarizing yourself with the technologies we are using or join our discord server and say hi to us at #kampus-projects channel.

Getting started

1. Cloning the project

  • Fork kamp-us/monorepo under your personal account.
    • eg: usirin/monorepo
  • Clone the project to your local computer:
# Download Repository
git clone [email protected]:kamp-us/monorepo.git
# Move into repository
cd monorepo
  • Install dependencies.
npm ci

2. Modifying hosts file

127.0.0.1 localhost.kamp.us
127.0.0.1 pasaport.localhost.kamp.us
127.0.0.1 pano.localhost.kamp.us
127.0.0.1 sozluk.localhost.kamp.us
127.0.0.1 gql.localhost.kamp.us

3. Setting up .env files

  • Duplicate .env.example files and rename them as .env in the following folders: db/prisma, apps/gql, apps/kampus, apps/pasaport.

4. Prisma Setup and Database Configuration

  • Move to db/prisma folder.
cd db/prisma
  • Start the image. (You should have docker installed.)
docker-compose up -d
  • Generate artifacts. (e.g. Prisma Client)
npm run prisma:generate
  • Push the Prisma schema state to the database.
npm run prisma:push
  • Run seed command to fill database with demo data.
npm run prisma:seed

5. Running dev servers

  • Run the command below at the root folder.
# Runs "gql", "kampus" and "pasaport" apps so the platform can be alive with 1 command.
npm run web
  • Now you can go to localhost.kamp.us:3000 to see it live. 🚀
# Runs all "dev" commands on each package inside the workspace
npm run dev
# Runs only "gql" server so backend work can be done separetly.
npm run gql

6. Logging in on development server(optional)

6.1 GitHub

# apps/kampus, apps/pasaport
GITHUB_ID=<Your_Client_ID>
GITHUB_SECRET=<Your_Client_Secret>
  • Now you can use Sign in with GitHub on development server.

Structure

  • /apps: services & apps
  • /db: packages that is relevant to database
  • /config: packages that is relevant to configuration
  • /packages: internal (and maybe external in the future) npm packages

These folders are registered as workspaces in package.json

Use Correct Node Version

If you haven't already install Volta, you can install install it with:

curl https://get.volta.sh | bash

Docker Setup

Dockerfile

  • We use a multi-stage build process to separate the building of applications from the final production image. This ensures smaller and more optimized production images.
  • We build three services: kampus, gql, and pasaport. Each service has its dedicated builder stage followed by its execution stage.
  • The node:18-bullseye-slim image is used to keep the final production images lean.

Docker Compose

  • We have four primary services: mysql, kampus, gql, and pasaport.
  • mysql is the database service. We ensure that its authentication is set correctly and ports are mapped to allow for local development access.
  • The other three services are built using the project's Dockerfile. These services are exposed on ports 3000, 3001, and 3002 respectively.
  • If you want to run the services with Docker Compose, copy the docker-compose.dev.yml file to docker-compose.yml. This file is ignored by Git to prevent accidental commits of sensitive information such as secrets and passwords. You will need to update the environment variables in this file to match your local environment.
cp docker-compose.dev.yml docker-compose.yml
cp .env.example .env

Running a Fully Clean Build with Docker Compose

  • To build the images and run the containers, run the following command:
docker-compose up --build -d
  • To stop the containers, run the following command:
docker-compose down

Running a Fully Clean Build with Docker

  • Build and start the services, ensuring Docker Compose builds the images from scratch without using any cache.
docker-compose up --build --force-recreate

About

kamp.us web projects & packages

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 92.4%
  • MDX 4.7%
  • JavaScript 1.2%
  • Dockerfile 1.1%
  • Other 0.6%