This is an example of a monorepo with typescript and docker.
This repository uses Yarn workspaces as a package manager and Turborepo as a task runner.
- Yarn Workspaces Workspace is a yarn feature that hoists our node modules into the root level in our monorepo while keeping symbolic links for the dependencies within the monorepo—allowing us to work on multiple codebases within a monorepo without manually linking dependencies.
- Turborepo Turborepo is a tool that builds a dependency graph of our packages and runs pipelines to respect the hierarchy of dependencies. Instead of worrying about running build in all of the packages an application depends on, Turborepo takes care of that for us.
It includes the following packages/apps:
web
: a Next.js appapi
: an Express serverui
: ui: a React component libraryeslint-config-custom
:eslint
configurations for client side applications (includeseslint-config-next
andeslint-config-prettier
)eslint-config-custom-server
:eslint
configurations for server side applications (includeseslint-config-next
andeslint-config-prettier
)scripts
: Jest configurationslogger
: Isomorphic logger (a small wrapper around console.log)tsconfig
: tsconfig.json;s used throughout the monorepo
Each package/app is 100% TypeScript.
This repo is configured to be built with Docker, and Docker compose. To build all apps in this repo:
# Create a network, which allows containers to communicate
# with each other, by using their container name as a hostname
docker network create app_network
# Build prod using new BuildKit engine
COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker-compose -f docker-compose.yml build --parallel
# Start prod in detached mode
docker-compose -f docker-compose.yml up -d
Open http://localhost:3000.
To shutdown all running containers:
# Stop all running containers
docker kill $(docker ps -q) && docker rm $(docker ps -a -q)
This repository has some additional tools already setup for you:
- TypeScript for static type checking
- ESLint for code linting
- Jest test runner for all things JavaScript
- Prettier for code formatting