Files
Yusron alamsyah 8d9c2585e4 feat : add docker
2026-02-27 14:17:28 +07:00

3.7 KiB

Docker Deployment Guide

📦 Prerequisites

  • Docker Desktop installed
  • Docker Compose installed (included with Docker Desktop)

🚀 Quick Start

1. Build the Docker Image

docker build -t antrean-operasi:latest .

2. Run with Docker Compose

# Make sure .env file exists with your configuration
# Docker Compose will automatically use .env file

docker-compose up -d

3. Run without Docker Compose

docker run -d \
  --name antrean-operasi \
  -p 3005:3000 \
  -e KEYCLOAK_ISSUER=https://your-keycloak/realms/your-realm \
  -e KEYCLOAK_CLIENT_ID=your-client-id \
  -e KEYCLOAK_CLIENT_SECRET=your-client-secret \
  -e API_BASE_URL=https://your-api.com \
  -e AUTH_URL=http://localhost:3005 \
  antrean-operasi:latest

🔧 Available Commands

Build image

docker build -t antrean-operasi:latest .

Start containers

docker-compose up -d

Stop containers

docker-compose down

View logs

docker-compose logs -f antrean-operasi

Rebuild and restart

docker-compose up -d --build

Access container shell

docker exec -it antrean-operasi sh

🌐 Access Application

After starting the container, access the application at:

📝 Environment Variables

Required environment variables (set in .env file):

Variable Description Example
KEYCLOAK_ISSUER Keycloak realm URL https://keycloak.example.com/realms/myrealm
KEYCLOAK_CLIENT_ID Keycloak client ID antrean-operasi-client
KEYCLOAK_CLIENT_SECRET Keycloak client secret your-secret-here
API_BASE_URL Backend API URL https://api.example.com
AUTH_URL Application auth URL http://localhost:3005

🐳 Docker Hub (Optional)

Tag and Push to Docker Hub

# Tag the image
docker tag antrean-operasi:latest yourusername/antrean-operasi:latest

# Login to Docker Hub
docker login

# Push to Docker Hub
docker push yourusername/antrean-operasi:latest

Pull from Docker Hub

docker pull yourusername/antrean-operasi:latest

🔍 Troubleshooting

Check container status

docker ps -a

View detailed logs

docker logs antrean-operasi

Check container resource usage

docker stats antrean-operasi

Restart container

docker restart antrean-operasi

Remove all containers and images

docker-compose down --rmi all --volumes

🏗️ Production Recommendations

  1. Use environment-specific configs: Create separate .env.production files
  2. Enable HTTPS: Use a reverse proxy (Nginx, Traefik) with SSL certificates
  3. Use Docker secrets: For sensitive data in production
  4. Set resource limits: Add memory and CPU limits in docker-compose.yml
  5. Use Redis: Replace in-memory session store with Redis
  6. Setup monitoring: Add health checks and monitoring tools
  7. Regular backups: Backup mounted volumes and data

Example Production docker-compose.yml with limits:

services:
  antrean-operasi:
    # ... other config ...
    deploy:
      resources:
        limits:
          cpus: '2'
          memory: 2G
        reservations:
          cpus: '1'
          memory: 1G

📊 Health Check

The container includes a health check endpoint. Check container health:

docker inspect --format='{{json .State.Health}}' antrean-operasi

🔐 Security Notes

  • Never commit .env.docker to version control
  • Use Docker secrets for production deployments
  • Run container as non-root user (already configured)
  • Regularly update base images for security patches

📞 Support

For issues or questions, please contact the development team.