diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..7e37309 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,39 @@ +# Contributing + +Thank you for your interest in contributing to this repository. To ensure a smooth and collaborative environment, please follow these guidelines. Before contributing, set up the project locally using the steps outlined in [README.md](./README.md). + +## Why these guidelines ? + +Our goal is to create a healthy and inclusive space for contributions. Remember that open-source contribution is a collaborative effort, not a competition. + +## General guidelines + +- Work only on one issue at a time since it will provide an opportunity for others to contribute as well. + +- Note that each open-source repository generally has its own guidelines, similar to these. Always read them before starting your contributions. + +## How to get an issue assigned + +- To get an issue assigned, provide a small description as to how you are planning to tackle this issue. + +> Ex - If the issue is about UI changes, you should create a design showing how you want it to look on the UI (make it using figma, paint, etc) + +- This will allow multiple contributors to discuss their approach to tackle the issue. The maintainer will then assign the issue. + +## After getting the issue assigned + +- Create your own branch instead of working directly on the main branch. + +- Provide feedback every 24-48 hours if an issue is assigned to you. Otherwise, it may be reassigned. + +- When submitting a pull request, please provide a screenshot or a screen-recording showcasing your work. + +## Don't while contributing + +- Avoid comments like "Please assign this issue to me" or "can i work on this issue ?" + +- Refrain from tagging the maintainer to assign issues or review pull requests. + +- Don't make any pull request for issues you are not assigned to. It will be closed without merging. + +Happy Contributing! diff --git a/README.md b/README.md new file mode 100644 index 0000000..6f3519d --- /dev/null +++ b/README.md @@ -0,0 +1,133 @@ +

Muzer - 100xDevs

+ +## Table of Contents + +- [Table of Contents](#table-of-contents) +- [Installation](#installation) + - [With Docker](#with-docker) + - [Without Docker](#without-docker) +- [Usage](#usage) +- [Contributing](#contributing) +- [Contributors](#contributors) + +## Installation + +### With Docker + +1. Clone the repository: + ```bash + git clone https://github.com/code100x/muzer.git + ``` + +2. Navigate to the project directory: + ```bash + cd muzer + ``` + +3. Create a `.env` file based on the `.env.example` file and configure everything in both the `next-app` and `ws` folders. + +4. Run the following command to start the application: + ```bash + docker compose --env-file ./next-app/.env --env-file ./ws/.env up -d + ``` + +### Without Docker + +1. Clone the repository: + ```bash + git clone https://github.com/code100x/muzer.git + ``` + +2. Navigate to the project directory: + ```bash + cd muzer + ``` + +3. Now Install the dependencies: + ```bash + cd next-app + pnpm install + cd .. + cd ws + pnpm install + ``` +4. Create a `.env` file based on the `.env.example` file and configure everything in both the `next-app` and `ws` folders. + +5. For postgres, you need to run the following command: + ```bash + docker run -d \ + --name muzer-db \ + -e POSTGRES_USER=myuser \ + -e POSTGRES_PASSWORD=mypassword \ + -e POSTGRES_DB=mydatabase \ + -p 5432:5432 \ + postgres + ``` + +6. For redis, you need to run the following command: + ```bash + docker run -d \ + --name muzer-redis \ + -e REDIS_USERNAME=admin \ + -e REDIS_PASSWORD=root \ + -e REDIS_PORT=6379 \ + -e REDIS_HOST="127.0.0.1" \ + -e REDIS_BROWSER_STACK_PORT=8001 \ + redis/redis-stack:latest + ``` + +7. Now do the following: + ```bash + cd next-app + pnpm postinstall + cd .. + cd ws + pnpm postinstall + ``` + +8. Run the following command to start the application: + ```bash + cd next-app + pnpm dev + cd .. + cd ws + pnpm dev + ``` + +9. To access the prisma studio, run the following command: + ```bash + cd next-app + pnpm run prisma:studio + ``` + +## Usage + +1. Access the application in your browser at http://localhost:3000 +2. Access the redis stack at http://localhost:8001/redis-stack/browser +3. Access the prisma studio at http://localhost:5555 + +## Contributing + +We welcome contributions from the community! To contribute to Muzer, follow these steps: + +1. Fork the repository. + +2. Create a new branch (`git checkout -b feature/fooBar`). + +3. Make your changes and commit them (`git commit -am 'Add some fooBar'`). + +4. Push to the branch (`git push origin -u feature/fooBar`). + +5. Create a new Pull Request. + +For major changes, please open an issue first to discuss what you would like to change. + +Read our [contribution guidelines](./CONTRIBUTING.md) for more details. + +## Contributors + + + + + +If you continue to face issues, please open a GitHub issue with details about the problem you're experiencing. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..a705a51 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,107 @@ +services: + app: + container_name: muzer-docker + build: + context: ./next-app/ + dockerfile: Dockerfile.dev + env_file: + - path: ./next-app/.env + ports: + - ${APP_PORT}:3000 + depends_on: + postgres: + condition: service_healthy + redis: + condition: service_healthy + develop: + watch: + - action: sync + path: ./next-app + target: /usr/src/app + ignore: + - node_modules/ + - action: rebuild + path: ./next-app/package.json + target: /usr/src/app + ignore: + - node_modules/ + + postgres: + container_name: prisma-postgres + image: postgres:alpine + restart: always + env_file: + - path: ./next-app/.env + ports: + - ${POSTGRES_PORT}:5432 + volumes: + - postgres-data:/var/lib/postgresql/data + healthcheck: + test: ["CMD-SHELL", "pg_isready -U postgres"] + interval: 10s + timeout: 5s + retries: 5 + + prisma-studio: + container_name: prisma-studio + image: timothyjmiller/prisma-studio:latest + restart: unless-stopped + env_file: + - path: ./next-app/.env + depends_on: + - app + ports: + - ${PRISMA_STUDIO_PORT}:5555 + + redis: + container_name: redis-server + image: redis/redis-stack:latest + restart: always + env_file: + - path: ./ws/.env + ports: + - ${REDIS_PORT}:6379 + - ${REDIS_BROWSER_STACK_PORT}:8001 + environment: + REDIS_ARGS: "--requirepass ${REDIS_PASSWORD} --user ${REDIS_USERNAME} on >${REDIS_PASSWORD} ~* allcommands --user default off nopass nocommands" + volumes: + - redis-data:/data + healthcheck: + test: ["CMD", "redis-cli", "ping"] + interval: 10s + timeout: 5s + retries: 5 + + websockets: + container_name: websockets + restart: always + build: + context: ./ws/ + dockerfile: Dockerfile.dev + env_file: + - path: ./ws/.env + ports: + - ${PORT}:8080 + depends_on: + postgres: + condition: service_healthy + redis: + condition: service_healthy + develop: + watch: + - action: sync + path: ./ws + target: /usr/src/app + ignore: + - node_modules/ + - action: rebuild + path: ./ws/package.json + target: /usr/src/app + ignore: + - node_modules/ + +volumes: + postgres-data: + external: false + redis-data: + external: false \ No newline at end of file diff --git a/next-app/.dockerignore b/next-app/.dockerignore index 37d7e73..8493c1b 100644 --- a/next-app/.dockerignore +++ b/next-app/.dockerignore @@ -1,2 +1,4 @@ node_modules -.env +.git +.gitignore +.env.example \ No newline at end of file diff --git a/next-app/Dockerfile.dev b/next-app/Dockerfile.dev index 2be0e3b..6d8a742 100644 --- a/next-app/Dockerfile.dev +++ b/next-app/Dockerfile.dev @@ -2,7 +2,7 @@ FROM node:22-alpine AS installer WORKDIR /usr/src/app -RUN npm i pnpm -g +RUN corepack enable pnpm COPY package.json pnpm-lock.yaml ./ RUN pnpm install --frozen-lockfile --ignore-scripts COPY . . @@ -12,6 +12,6 @@ RUN pnpm postinstall FROM node:22-alpine AS dev WORKDIR /usr/src/app -RUN npm i pnpm -g +RUN corepack enable pnpm COPY --from=installer /usr/src/app/ ./ CMD [ "pnpm", "dev:docker" ] \ No newline at end of file diff --git a/next-app/package.json b/next-app/package.json index 19d855c..9d6e739 100644 --- a/next-app/package.json +++ b/next-app/package.json @@ -10,8 +10,8 @@ "lint": "next lint", "prisma:studio": "npx prisma studio", "postinstall": "prisma generate", - "prisma:migrate": "prisma migrate", - "dev:docker": "pnpm prisma:migrate && pnpm dev", + "prisma:migrate": "prisma migrate dev", + "dev:docker": "pnpm prisma:migrate & pnpm dev", "format:fix": "prettier --write \"**/*.{ts,tsx,json}\"", "format:check": "prettier --check \"**/*.{ts,tsx,json}\"" }, diff --git a/ws/.dockerignore b/ws/.dockerignore new file mode 100644 index 0000000..8493c1b --- /dev/null +++ b/ws/.dockerignore @@ -0,0 +1,4 @@ +node_modules +.git +.gitignore +.env.example \ No newline at end of file diff --git a/ws/.env.example b/ws/.env.example index 79f4b6e..c9a45b4 100644 --- a/ws/.env.example +++ b/ws/.env.example @@ -4,5 +4,6 @@ DATABASE_URL="" REDIS_USERNAME="" REDIS_PORT=6379 -REDIS_HOST="127.0.0.1" -REDIS_PASSWORD="" \ No newline at end of file +REDIS_HOST="127.0.0.1" # for docker change it to "redis" +REDIS_PASSWORD="" +REDIS_BROWSER_STACK_PORT=8001 \ No newline at end of file diff --git a/ws/Dockerfile.dev b/ws/Dockerfile.dev new file mode 100644 index 0000000..14829ed --- /dev/null +++ b/ws/Dockerfile.dev @@ -0,0 +1,18 @@ +FROM node:22-alpine AS installer + +WORKDIR /usr/src/app +RUN corepack enable pnpm +COPY package.json pnpm-lock.yaml ./ +RUN pnpm install --frozen-lockfile --ignore-scripts +COPY . . +RUN pnpm postinstall + + +FROM node:22-alpine AS dev + +WORKDIR /usr/src/app +RUN corepack enable pnpm +COPY --from=installer /usr/src/app/ ./ +CMD [ "pnpm", "dev" ] + + diff --git a/ws/package.json b/ws/package.json index ebedd99..6992dc7 100644 --- a/ws/package.json +++ b/ws/package.json @@ -2,12 +2,13 @@ "name": "ws", "version": "1.0.0", "description": "", - "main": "index.js", + "main": "app.ts", "scripts": { "preinstall": "npx only-allow pnpm", "dev": "nodemon src/app.ts", "start": "node dist/app.js", - "build": "prisma generate && npx tsc -b" + "build": "pnpm postinstall && npx tsc -b", + "postinstall": "npx prisma generate" }, "keywords": [], "author": "",