Dockerfile Overview
The Dockerfile uses the Defra Digital base images and includes two build stages:- development: Includes development dependencies and debugging capabilities
- production: Optimized for production with minimal dependencies and health check support
Build Arguments
The version of the Defra Digital Node.js base image
The port to expose for the application
The port to expose for Node.js debugging (development only)
Development Image
The development image includes all dependencies and supports hot-reloading for local development.Build the development image
Build the Docker image targeting the development stage:
The
--no-cache flag ensures a clean build without using cached layers.Run the development container
Start the container with the required environment variables:The application will be accessible at
http://localhost:3001.Development Image Features
- Installs all dependencies including devDependencies
- Runs with
npm run docker:devcommand - Exposes both application and debug ports
- Based on
defradigital/node-developmentimage - Includes development tools and utilities
Production Image
The production image is optimized for deployment with minimal dependencies and includes health check support.Build the production image
Build the Docker image without specifying a target (defaults to production):
Production Image Features
- Installs only production dependencies (
npm ci --omit=dev) - Runs with
node srccommand - Includes curl for health check requirements
- Based on
defradigital/nodeproduction image - Optimized for size and security
- Copies artifacts from development stage
Image Labels
Both images include labels identifying the parent image:Running with Custom Environment Variables
You can pass multiple environment variables when running the container:For a complete list of environment variables, see the Environment Variables page.
Next Steps
- Configure Environment Variables for your deployment
- Use Docker Compose for local development with all dependencies