This guide covers how to set up and configure debugging on a Linux VPS. Whether you're running a production environment or a development setup, these instructions will help you get started quickly and securely.
Prerequisites
- Root or sudo access to the server
- Docker Compose v2 installed
- Basic familiarity with the Linux command line
- A VPS running Ubuntu 22.04 or later (2GB+ RAM recommended)
- Docker Engine 24.0+ installed
Creating the Docker Compose File
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.
# docker-compose.yml
version: '3.8'
services:
app:
image: debugging:latest
restart: unless-stopped
ports:
- "8080:8080"
volumes:
- app_data:/data
environment:
- NODE_ENV=production
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
interval: 30s
timeout: 10s
retries: 3
volumes:
app_data:
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.
- Scale vertically before scaling horizontally
- Use connection pooling for database connections
- Implement caching at every appropriate layer
- Start with the minimum required resources
- Profile before optimizing - measure first
Building the Container Image
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/.
# Multi-stage Dockerfile
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build
FROM node:20-alpine
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
EXPOSE 3000
CMD ["node", "dist/index.js"]
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.
Configuration Options
For production deployments, consider implementing high availability by running multiple instances behind a load balancer. This approach provides both redundancy and improved performance under heavy load.
- Test disaster recovery procedures regularly
- Document all configuration changes
- Use version control for configuration files
- Maintain runbooks for common operations
- Set up monitoring before going to production
Configuring Volumes and Networks
Regular maintenance is essential for keeping your debugging installation running smoothly. Schedule periodic reviews of log files, disk usage, and security updates to prevent issues before they occur.
# Container management commands
docker compose up -d
docker compose logs -f app
docker compose exec app sh
docker system prune -af --volumes # Caution: removes unused data
These commands should be run as root or with sudo privileges. If you're using a non-root user, prefix each command with sudo.
Managing Container Lifecycle
It's recommended to test this configuration in a staging environment before deploying to production. This helps identify potential compatibility issues and allows you to benchmark performance differences.
# docker-compose.yml
version: '3.8'
services:
app:
image: debugging:latest
restart: unless-stopped
ports:
- "8080:8080"
volumes:
- app_data:/data
environment:
- NODE_ENV=production
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
interval: 30s
timeout: 10s
retries: 3
volumes:
app_data:
Note that file paths may vary depending on your Linux distribution. The examples here are for Debian/Ubuntu; adjust paths accordingly for RHEL/CentOS-based systems.
Summary
You've successfully configured debugging 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.