plugins/apps-js/Docker.md
This directory contains multiple Docker configurations for the apps-js Node.js application, each optimized for different deployment scenarios.
Dockerfile (Production)Purpose: Standard production deployment Features:
Usage:
# Build the image
docker build -f plugins/apps-js/Dockerfile -t apps-js:latest .
# Run the container
docker run -d -p 8080:8080 --name apps-js apps-js:latest
# Test health endpoint
curl http://localhost:8080/health
Dockerfile.datadog (Monitoring)Purpose: Production deployment with Datadog APM monitoring Features:
Usage:
# Build the image
docker build -f plugins/apps-js/Dockerfile.datadog -t apps-js:datadog .
# Run with Datadog environment variables
docker run -d -p 8080:8080 \
-e DD_API_KEY=your_datadog_api_key \
-e DD_SITE=datadoghq.com \
-e DD_SERVICE=apps-js \
-e DD_ENV=production \
--name apps-js-datadog apps-js:datadog
The application supports the following environment variables:
| Variable | Default | Description |
|---|---|---|
PORT | 3000 | Server port (set to 8080 in Docker) |
NODE_ENV | development | Node.js environment |
DD_API_KEY | - | Datadog API key (for monitoring) |
DD_SITE | datadoghq.com | Datadog site |
DD_SERVICE | apps-js | Service name for Datadog |
DD_ENV | - | Environment name for Datadog |
All Docker images include a health check endpoint:
GET /health{"status":"ok"}All containers run as a non-root user (nodejs:1001) for enhanced security:
Using Node.js 18 Alpine provides:
The .dockerignore file excludes:
The Dockerfiles use multi-stage builds to:
Build process optimizes for Docker layer caching:
version: '3.8'
services:
apps-js:
build:
context: .
dockerfile: plugins/apps-js/Dockerfile
ports:
- "8080:8080"
environment:
- NODE_ENV=production
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
interval: 30s
timeout: 3s
retries: 3
restart: unless-stopped
apiVersion: apps/v1
kind: Deployment
metadata:
name: apps-js
spec:
replicas: 3
selector:
matchLabels:
app: apps-js
template:
metadata:
labels:
app: apps-js
spec:
containers:
- name: apps-js
image: apps-js:latest
ports:
- containerPort: 8080
env:
- name: NODE_ENV
value: "production"
livenessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 30
periodSeconds: 10
readinessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 5
periodSeconds: 5
Port Conflicts
-p 8081:8080Permission Errors
Health Check Failures
docker logs <container_name>curl http://localhost:8080/healthDatadog Issues
# View container logs
docker logs apps-js
# Execute shell in running container
docker exec -it apps-js sh
# Inspect container configuration
docker inspect apps-js
# View resource usage
docker stats apps-js
Recommended resource limits for production:
docker run -d \
--memory=512m \
--cpus=0.5 \
-p 8080:8080 \
apps-js:latest
For high-traffic deployments:
Regularly scan images for vulnerabilities:
# Using Docker Scout
docker scout cves apps-js:latest
# Using Trivy
trivy image apps-js:latest