# Docker Deployment Guide ## 📦 Prerequisites - Docker Desktop installed - Docker Compose installed (included with Docker Desktop) ## 🚀 Quick Start ### 1. Build the Docker Image ```bash docker build -t antrean-operasi:latest . ``` ### 2. Run with Docker Compose ```bash # Make sure .env file exists with your configuration # Docker Compose will automatically use .env file docker-compose up -d ``` ### 3. Run without Docker Compose ```bash 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 ```bash docker build -t antrean-operasi:latest . ``` ### Start containers ```bash docker-compose up -d ``` ### Stop containers ```bash docker-compose down ``` ### View logs ```bash docker-compose logs -f antrean-operasi ``` ### Rebuild and restart ```bash docker-compose up -d --build ``` ### Access container shell ```bash docker exec -it antrean-operasi sh ``` ## 🌐 Access Application After starting the container, access the application at: - **http://localhost:3005** ## 📝 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 ```bash # 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 ```bash docker pull yourusername/antrean-operasi:latest ``` ## 🔍 Troubleshooting ### Check container status ```bash docker ps -a ``` ### View detailed logs ```bash docker logs antrean-operasi ``` ### Check container resource usage ```bash docker stats antrean-operasi ``` ### Restart container ```bash docker restart antrean-operasi ``` ### Remove all containers and images ```bash 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: ```yaml 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: ```bash 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.