Skip to content

mqschwanda/nextjs-monorepo-docker

Repository files navigation

Next JS Monorepo Docker

Storybook

To see live example you can visit github pages.

Development Philosophies

For a detailed explanation of why certain decisions were made and what guidelines should be followed review the development philosophies documentation

Quick Start

Setup

  1. Install yarn package manager if you do not already have it on your system.

  2. From project root run the yarn cli to install all dependencies

yarn install

Development

Run Apps

  1. Run the docker build command
    yarn docker-compose-build:dev
  2. Run the docker run command
    yarn docker-compose-run:dev

NOTE: If you have not setup the database make sure to run the setup database commands.

Setup Database

  1. Run the database migration command
    docker-compose-prisma-migrate:dev
  2. Run the database reset command
    docker-compose-prisma-migrate-reset:dev

Flatten Migrations

  1. Run the database initial migration command
    docker-compose-prisma-migrate-initial:dev

Troubleshooting

File Watcher Limit

Error: ENOSPC: System limit for number of file watchers reached

Stack Overflow solution for updating max file watchers

NOTE

You should not run into this issue unless you are trying to run all (or many) workspaces dev modes at once. Having this many file watchers will crash some systems, and slow down most. Instead of watching all workspaces it is recommended that the root yarn dev script is used and any other packages that are needed are run in a separate terminal window with yarn workspace @mqs/<WORKSPACE_NAME> dev.

Production

Run Apps

  1. Create an .env.prod file be either copying the .env.dev or .env.prod.example files and making the necessary changes.

    Note: This only needs to be done once, so you can skip to step 2 if this is not the first time starting up a production instance.

    • copy the development env file and use it as the production env file
      cp .env.dev .env.prod
    • copy the production example env file and use it as the production env file
      cp .env.prod.example .env.prod

    After copying the file, make sure to update .env.prod with the proper values

  2. Run the docker build command

    yarn docker-compose-build:prod
  3. Run the docker run command

    yarn docker-compose-run:prod

Open http://localhost:3000.

To shutdown all running containers:

yarn docker-kill

What's inside?

This turborepo uses Yarn as a package manager. It includes the following packages/apps:

Workspaces

Each workspace is built with TypeScript.

Apps

Packages

  • errors: utilities to handle errors
  • eslint-config: shared eslint configurations
  • graphql-client: react client and api utilities for graphql
  • graphql-schema: graphql schema and types
  • graphql-server: graphql server and resolvers
  • jest-preset: Jest configurations
  • jobs: server workers and utilities
  • logger: Isomorphic logger (a small wrapper around console.log)
  • prisma: Database ORM
  • react-client-components: a React client component library
  • react-server-components: a React server component library
  • react-testing-lib: a React testing library
  • react-utils: a React utilities library
  • storybook: a package to build and deploy Storybook documentation
  • storybook-utils: utilities for implementing Storybook
  • style: shared css and style utilities for components and apps
  • tailwind-config: a generalized Tailwind CSS configuration
  • tokens: utility to handle access and refresh tokens
  • tsconfig: tsconfig.json;s used throughout the monorepo
  • zod: utilities for handling validation with Zod

Scripts

  • tsc: a script to turn typescript source code into javascript

Utilities

This Turborepo has some additional tools already setup for you:

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published