Production-ready setup for Next.js projects
Based on node:14-alpine
Run the stack
docker-compose up -d
Visit http://app.yadi.localhost:3070
Three sample environment files are included in the sample app. Normally only development mode .env
file should be included in git as others might contain sensitive data.
.env
.env.staging
.env.prod
With the COMPOSE_FILE
we load two linked configurations in development mode.
COMPOSE_FILE=docker-compose.yml:docker-compose.dev.yml
Note: On Windows use ;
as file separator instead of :
The main configuration defines:
- core services specs
- variables used in all environments
- networking
Dev configuration inherits and extends the main one and adds:
- image build instructions
- local mounted volumes
- exposed ports to host machine
- local container hotname (app.yadi.localhost)
Custom application environment, feel free to adjust or remove if not used.
APP_ENV=development # development, staging, production
Node env enables special code optimizations in production builds. Application environment such as staging
normally will benefit of the code optimizations.
Better not to be used as application environment.
NODE_ENV=development # development, production
Target environment defines the end stage of the multi-stage build
You can read more about the different stages in the main README.md
TARGET_ENV=development # dependencies, development, builder, production
APP_ENV |
NODE_ENV |
TARGET_ENV |
Notes |
---|---|---|---|
development | development | development | Normal development flow |
development | production | production | Local production build |
staging | development | development | Not very useful, can help reach certain code conditions |
staging | production | production | Production build deployed on staging server |
production | production | production | We're live |