4.8 KiB
4.8 KiB
Docker Deployment Guide
This guide explains how to deploy the EzSepa Bank Payment landing page using Docker.
Prerequisites
- Docker installed (version 20.10 or higher)
- Docker Compose installed (version 1.29 or higher)
Quick Start
Option 1: Using Docker Compose (Recommended)
# Build and start the container
docker-compose up -d
# View logs
docker-compose logs -f
# Stop the container
docker-compose down
The application will be available at http://localhost:8080
Option 2: Using Docker Commands
# Build the image
docker build -t ezsepa-landing:latest .
# Run the container
docker run -d \
--name ezsepa-landing \
-p 8080:80 \
--restart unless-stopped \
ezsepa-landing:latest
# View logs
docker logs -f ezsepa-landing
# Stop and remove the container
docker stop ezsepa-landing
docker rm ezsepa-landing
Production Deployment
Using a Custom Port
# Change the port mapping in docker-compose.yml or use:
docker-compose up -d -p 80:80
Environment Variables
You can customize the deployment by setting environment variables:
environment:
- NODE_ENV=production
- PORT=80
Behind a Reverse Proxy (Nginx/Apache)
If you're deploying behind a reverse proxy, map to a different port:
docker run -d \
--name ezsepa-landing \
-p 3000:80 \
ezsepa-landing:latest
Then configure your reverse proxy to forward requests to http://localhost:3000
Using Docker Hub
# Tag the image
docker tag ezsepa-landing:latest yourusername/ezsepa-landing:latest
# Push to Docker Hub
docker push yourusername/ezsepa-landing:latest
# Pull and run on any server
docker pull yourusername/ezsepa-landing:latest
docker run -d -p 8080:80 yourusername/ezsepa-landing:latest
Health Checks
The container includes a health check that runs every 30 seconds:
# Check container health status
docker ps
docker inspect --format='{{json .State.Health}}' ezsepa-landing
Nginx Configuration
The container uses a custom nginx configuration (nginx.conf) that includes:
- Gzip compression for better performance
- Security headers (X-Frame-Options, CSP, etc.)
- Static asset caching (1 year for images, CSS, JS)
- HTML no-cache for latest content
- Custom error pages
Volume Mounting (Development)
For development with hot-reload:
docker run -d \
--name ezsepa-landing-dev \
-p 8080:80 \
-v $(pwd)/dist:/usr/share/nginx/html \
ezsepa-landing:latest
Troubleshooting
Container won't start
# Check logs
docker logs ezsepa-landing
# Check if port is already in use
netstat -ano | findstr :8080 # Windows
lsof -i :8080 # Linux/Mac
Permission issues
# On Linux, if you encounter permission issues:
sudo chown -R $USER:$USER dist/
Rebuild without cache
docker build --no-cache -t ezsepa-landing:latest .
Monitoring
Check resource usage
docker stats ezsepa-landing
Access container shell
docker exec -it ezsepa-landing sh
Cleanup
# Remove container
docker-compose down
# Remove container and image
docker-compose down --rmi all
# Remove unused Docker resources
docker system prune -a
Kubernetes Deployment (Optional)
For Kubernetes deployment, here's a basic manifest:
apiVersion: apps/v1
kind: Deployment
metadata:
name: ezsepa-landing
spec:
replicas: 3
selector:
matchLabels:
app: ezsepa-landing
template:
metadata:
labels:
app: ezsepa-landing
spec:
containers:
- name: ezsepa-landing
image: ezsepa-landing:latest
ports:
- containerPort: 80
resources:
requests:
memory: "64Mi"
cpu: "100m"
limits:
memory: "128Mi"
cpu: "200m"
---
apiVersion: v1
kind: Service
metadata:
name: ezsepa-landing-service
spec:
selector:
app: ezsepa-landing
ports:
- protocol: TCP
port: 80
targetPort: 80
type: LoadBalancer
Security Best Practices
- Use specific image versions instead of
latestin production - Scan images for vulnerabilities:
docker scan ezsepa-landing:latest - Run as non-root user (already configured in the Dockerfile)
- Keep base images updated:
docker pull nginx:alpine - Use secrets for sensitive data instead of environment variables
Performance Optimization
The Docker image is optimized for:
- Small size: Multi-stage build (~25MB)
- Fast builds: Cached layers
- Quick startup: Alpine-based images
- Efficient serving: Nginx with gzip compression
Support
For issues related to Docker deployment, please check:
- Docker logs:
docker logs ezsepa-landing - Container status:
docker ps -a - System resources:
docker system df