Docs / Cloud & DevOps / Blue-Green Deployments on a Single Server

Blue-Green Deployments on a Single Server

By Admin · Feb 1, 2026 · Updated Apr 25, 2026 · 5 views · 3 min read

In this article, we'll walk through the complete process of working with blue-green in a server environment. Understanding deployment is essential for maintaining a reliable and performant infrastructure.

Prerequisites

  • Basic understanding of CI/CD concepts
  • Root or sudo access to the server
  • A VPS running Ubuntu 22.04 or later (2GB+ RAM recommended)

Pipeline Configuration

If you encounter issues during setup, check the system logs first. Most problems can be diagnosed by examining the output of journalctl or the application-specific log files in /var/log/.


# .github/workflows/deploy.yml
name: Deploy to Production
on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Build
        run: |
          docker build -t myapp:latest .
      - name: Deploy
        run: |
          ssh deploy@server 'cd /opt/myapp && docker compose pull && docker compose up -d'

These commands should be run as root or with sudo privileges. If you're using a non-root user, prefix each command with sudo.

Advanced Settings

After applying these changes, monitor the server's resource usage for at least 24 hours to ensure stability. Tools like htop, iostat, and vmstat can provide real-time insights into system performance.

Build and Test Setup

The deployment component plays a crucial role in the overall architecture. Understanding how it interacts with blue-green will help you make better configuration decisions.


# Set up deployment pipeline
mkdir -p /opt/myapp
cd /opt/myapp

# Create deployment script
cat << 'EOF' > deploy.sh
#!/bin/bash
set -euo pipefail
echo "Deploying version: $1"
docker pull myapp:$1
docker compose down
DOCKER_TAG=$1 docker compose up -d
echo "Deployment complete"
EOF
chmod +x deploy.sh

This configuration provides a good balance between performance and resource usage. For high-traffic scenarios, you may need to increase the limits further.

  • Implement caching at every appropriate layer
  • Profile before optimizing - measure first
  • Scale vertically before scaling horizontally

Deployment Automation

Before making changes to the configuration, always create a backup of the existing files. This ensures you can quickly roll back if something goes wrong during the setup process.


# .github/workflows/deploy.yml
name: Deploy to Production
on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Build
        run: |
          docker build -t myapp:latest .
      - name: Deploy
        run: |
          ssh deploy@server 'cd /opt/myapp && docker compose pull && docker compose up -d'

Each line in the configuration serves a specific purpose. The comments explain the reasoning behind each setting, making it easier to customize for your specific use case.

Environment Management

The blue-green configuration requires careful attention to resource limits and security settings. On a VPS with limited resources, it's important to tune these parameters according to your available RAM and CPU cores.


# Set up deployment pipeline
mkdir -p /opt/myapp
cd /opt/myapp

# Create deployment script
cat << 'EOF' > deploy.sh
#!/bin/bash
set -euo pipefail
echo "Deploying version: $1"
docker pull myapp:$1
docker compose down
DOCKER_TAG=$1 docker compose up -d
echo "Deployment complete"
EOF
chmod +x deploy.sh

The configuration above sets the recommended values for a VPS with 2-4GB of RAM. Adjust the memory-related settings proportionally if your server has different specifications.

Summary

You've successfully configured blue-green on your VPS. Remember to monitor performance, keep your software updated, and maintain regular backups. If you run into issues, consult the official documentation or open a support ticket for assistance.

Was this article helpful?