Manual Deployment
Manual Deployment
Section titled “Manual Deployment”Panduan deploy manual menggunakan Docker Compose untuk infrastruktur custom.
Prerequisites
Section titled “Prerequisites”- Server dengan Docker dan Docker Compose installed
- SSH access ke server
- Domain dengan DNS pointed ke server IP
Step 1: SSH ke Server
Section titled “Step 1: SSH ke Server”ssh user@your-server-ipStep 2: Clone Repository
Section titled “Step 2: Clone Repository”cd /optgit clone https://github.com/Syskita/merq.gitcd merq/merq-backendStep 3: Setup Environment
Section titled “Step 3: Setup Environment”cp env.example .envnano .envIsi semua required variables (lihat Environment Variables Reference).
Step 4: Create Docker Network
Section titled “Step 4: Create Docker Network”docker network create merq-networkStep 5: Start Infrastructure Services
Section titled “Step 5: Start Infrastructure Services”PostgreSQL
Section titled “PostgreSQL”docker run -d \ --name merq-postgres \ --network merq-network \ -e POSTGRES_USER=merq \ -e POSTGRES_PASSWORD=your_password \ -e POSTGRES_DB=merq_production \ -v merq-pgdata:/var/lib/postgresql/data \ -p 5432:5432 \ postgres:15-alpinedocker run -d \ --name merq-redis \ --network merq-network \ -v merq-redisdata:/data \ -p 6379:6379 \ redis:7-alpineTypesense
Section titled “Typesense”docker run -d \ --name merq-typesense \ --network merq-network \ -e TYPESENSE_API_KEY=your_api_key \ -v merq-typesensedata:/data \ -p 8108:8108 \ typesense/typesense:27 \ --data-dir /data \ --api-key=your_api_keyStep 6: Build Backend Image
Section titled “Step 6: Build Backend Image”cd /opt/merq/merq-backenddocker build -t merq-backend:latest .Step 7: Run Backend Container
Section titled “Step 7: Run Backend Container”First Deploy (with migrations)
Section titled “First Deploy (with migrations)”docker run -d \ --name merq-backend \ --network merq-network \ -e RUN_MIGRATION=true \ -e RUN_SEEDER=true \ -p 8080:8080 \ --env-file .env \ merq-backend:latestMonitor logs:
docker logs -f merq-backendSubsequent Deploys (skip migrations)
Section titled “Subsequent Deploys (skip migrations)”docker run -d \ --name merq-backend \ --network merq-network \ -p 8080:8080 \ --env-file .env \ merq-backend:latestStep 8: Build & Deploy Web Dashboard
Section titled “Step 8: Build & Deploy Web Dashboard”merq-web is a static site — it is NOT containerised. Vite bakes env vars into the bundle at build time, so there is no runtime container to pass them to.
cd /opt/merq/merq-web
# Create .env.local with your production valuescp .env.example .env.local# Edit .env.local: set VITE_API_BASE_URL=https://api.yourdomain.com/api etc.nano .env.local
# Run the deploy script (installs deps, builds, copies to /var/www/merq-web)bash deploy.shThe deploy.sh script performs:
bun install— installs dependenciesbun run build— outputs static files todist/- Copies
dist/contents to/var/www/merq-web - Sets
chmod -R 755 /var/www/merq-webso Nginx can serve the files
Configure Nginx to serve /var/www/merq-web and proxy /api to the backend container (see Step 9).
Step 9: Setup Reverse Proxy
Section titled “Step 9: Setup Reverse Proxy”Using Caddy (Recommended)
Section titled “Using Caddy (Recommended)”# Install Caddysudo apt install -y debian-keyring debian-archive-keyring apt-transport-httpscurl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpgcurl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.listsudo apt updatesudo apt install caddyCaddyfile
Section titled “Caddyfile”sudo nano /etc/caddy/Caddyfileapi.yourdomain.com { reverse_proxy localhost:8080}
admin.yourdomain.com { root * /var/www/merq-web file_server try_files {path} /index.html}Apply Caddy Configuration
Section titled “Apply Caddy Configuration”sudo systemctl reload caddyStep 10: Verify
Section titled “Step 10: Verify”# Backend health checkcurl http://localhost:8080/api/health
# Check all containersdocker psUpdate Procedure
Section titled “Update Procedure”# 1. Pull latest codecd /opt/merqgit pull origin main
# 2. Rebuild backendcd merq-backenddocker build -t merq-backend:latest .
# 3. Stop & remove old containerdocker stop merq-backenddocker rm merq-backend
# 4. Start new containerdocker run -d \ --name merq-backend \ --network merq-network \ -p 8080:8080 \ --env-file .env \ merq-backend:latest
# 5. Redeploy web dashboard (static files)cd /opt/merq/merq-webbash deploy.sh
# 6. Verifydocker logs -f merq-backendSystemd Service (Optional)
Section titled “Systemd Service (Optional)”Create systemd service untuk auto-start:
sudo nano /etc/systemd/system/merq-backend.service[Unit]Description=Merq Backend ContainerRequires=docker.serviceAfter=docker.service
[Service]Type=simpleExecStart=/usr/bin/docker start -a merq-backendExecStop=/usr/bin/docker stop merq-backendRestart=alwaysRestartSec=10
[Install]WantedBy=multi-user.targetEnable:
sudo systemctl enable merq-backendsudo systemctl start merq-backendBackup Schedule
Section titled “Backup Schedule”Setup cron job untuk daily backups:
crontab -e# Daily backup at 2 AM0 2 * * * pg_dump -h localhost -U merq merq_production > /backups/merq_$(date +\%Y\%m\%d).sql