Container
Deploy NEXTDEVKIT using Docker containers to various cloud platforms
Deploy your NEXTDEVKIT application using Docker containers to various cloud platforms for maximum flexibility and control.
🌟 Why Choose Container Deployment?
Container deployment is ideal for applications requiring:
- 🔧 Full Control: Complete control over runtime environment and dependencies
- 🌐 Platform Flexibility: Deploy to any cloud provider or on-premises
- 📦 Consistent Environment: Same environment across development, staging, and production
- 🔄 Easy Scaling: Horizontal scaling with orchestration platforms
- 🛡️ Isolation: Process and resource isolation for security
- ⚡ Fast Deployment: Quick rollouts and rollbacks
🚀 Deployment Steps
Step 1: Configure Environment Variables
Please refer to the Environment Guide for the detailed environment variables.
Copy .env.example
to .env.production
or .env
and update the environment variables.
Step 2: Use Dockerfile
Use the Dockerfile
in your project root:
# Use the official Node.js runtime as base image
FROM node:20-alpine AS base
# Install dependencies only when needed
FROM base AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app
# Install dependencies based on the preferred package manager
COPY package.json pnpm-lock.yaml* ./
COPY source.config.ts ./
COPY src/content ./src/content
RUN corepack enable pnpm && pnpm i --frozen-lockfile
# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Build the application
RUN corepack enable pnpm && pnpm run build
# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app
ENV NODE_ENV production
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
# Copy the built application
COPY --from=builder /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs
EXPOSE 3000
ENV PORT 3000
ENV HOSTNAME "0.0.0.0"
# Start the application
CMD ["node", "server.js"]
Update the next.config.ts
file to enable standalone output:
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
output: "standalone",
};
export default nextConfig;
Step 3: Build and Test Locally
# Build the Docker image
docker build -t nextdevkit:latest .
# Run the container locally
docker run -p 3000:3000 --env-file .env nextdevkit:latest
Step 4: Deploy to Cloud Platform
Choose your preferred cloud platform:
Recommended Platforms
For universal container deployment, NEXTDEVKIT supports all major cloud providers:
Platform | Type | Website |
---|---|---|
Azure Container Apps | Microsoft Cloud | azure.microsoft.com |
Google Cloud Run | Google Cloud | cloud.google.com |
Railway | Developer-friendly | railway.app |
Fly.io | Global edge containers | fly.io |
Dokploy | Self-hosted | dokploy.com |
Coolify | Self-hosted | coolify.io |
AWS ECS (Elastic Container Service)
Recommended to use SST AWS ECS to deploy the container.
Your NEXTDEVKIT application is now containerized and ready for deployment! 🐳🚀