On this page
A small product team can make releases safer without adopting a large orchestration platform. The useful starting point is a repeatable build, a health check, a record of the previous working image and a rehearsed recovery path. Deployment time and interruption depend on the application and hosting setup.
This guide shows the decisions to make before automating releases, including what a single VPS can and cannot promise.
Principle 1: Build once, promote everywhere
The single most important rule: the image you tested is the image you ship. CI builds one Docker image per commit, tags it with the git SHA, pushes it to a registry, and then staging and production both run that exact artifact with different environment variables.
The anti pattern is rebuilding per environment. "It worked in staging" while production got a different dependency resolution is a mystery you never need to debug again once artifacts are facts and rebuilds are forbidden.

Principle 2: Multi stage builds keep images honest
A multi-stage Dockerfile can separate dependency installation, build tooling and the final runtime image. Copy only the runtime files and dependencies needed by the application. Run as a non-root user where practical. The exact Dockerfile depends on the framework, lockfile and build output, so validate it against the application before using it in production.
Dependencies cached, build tools excluded from the final image, a small attack surface and fast pulls. The runtime image should contain your app and nothing that can compile anything. A smaller runtime image can reduce unnecessary packages, but it still needs dependency scanning, updates and least-privilege configuration.
Principle 3: The pipeline is boring on purpose
On every push to main, four stages:
- Verify. Lint, typecheck, tests. Fail fast, before any image exists.
- Build. One image, tagged with the commit SHA, pushed to the registry.
- Stage. Deploy to staging automatically, run smoke checks against the health endpoint.
- Promote. Deploy the same image to production, automatically or behind a one click approval depending on the team's appetite.
GitHub Actions can separate these stages into jobs and use deployment environments for production approvals and scoped secrets. The workflow size depends on the repository, deployment target and checks. Keep a human-readable record of the image tag deployed to each environment.
Principle 4: Health checks are the contract with your infrastructure
Every service exposes a health endpoint that checks itself and its critical dependencies: database reachable, queue reachable. The deploy script, orchestrator or load balancer refuses to switch traffic until it passes.
A health gate can catch a missing dependency before traffic switches, provided the check reflects what the application actually needs. It cannot prevent every outage. Test failure behavior when the database is unavailable and make sure the deploy process leaves the previous version serving traffic when the new version fails its check.
Principle 5: Rollback is a pointer move, not a war room
Keep the previous known-good image available and record the exact tag in a release log. Reverting application code may be straightforward; reverting a database schema or irreversible data change may not be. Rehearse the recovery path in staging, measure how long it takes in your setup, and document who decides to switch traffic back. Do not promise a fixed rollback time before testing it.
Principle 6: Configuration lives in the environment
Images are identical everywhere; behavior comes from environment variables. Secrets live in the platform's secret store, never in the repo and never baked into images. The test: if you cannot rotate a credential without rebuilding, it is stored in the wrong place.
What about zero downtime and scaling?
A second healthy instance behind a traffic switch can reduce interruption during replacement. A single VPS running one application instance may have a gap while the container restarts. Even with two instances, incompatible migrations, session state, background workers and proxy behavior can cause errors. Test a real deployment under traffic before describing it as uninterrupted.
Choose the deployment platform from your availability needs, operational skills and recovery requirements. Kubernetes may be justified for some teams; a smaller service or VPS can be enough for others.
The payoff
A repeatable build and a tested recovery plan reduce release uncertainty. The goal is to know which image is running, whether it is healthy and what to do if the new version fails.
Single-VPS rollback decision checklist
| Check before release | If the answer is no |
|---|---|
| Is the previous image still available by an immutable tag or digest? | Preserve it before deploying. |
| Can the old application run against the new database schema? | Use a backward-compatible migration or a separate recovery plan. |
| Does the health check cover critical dependencies without exposing secrets? | Fix the check and test a failed start. |
| Is there capacity to run old and new versions together? | Plan for a maintenance window or brief interruption. |
| Can you switch traffic back and verify user-facing requests? | Rehearse that path in staging before release. |
For a single VPS, the recovery sequence is: stop the rollout if the new version fails its health check; keep or restore the previous image; verify database compatibility; route traffic to the healthy version; run a user-facing smoke test; and record the incident. This is a decision flow, not a command recipe. Exact commands depend on Compose files, proxy setup, registry and database migrations.
GitHub documents deployment environments and protection rules. Docker documents Compose in production and image digests.
Plan deployment around your application
If releases depend on manual steps or one person's server knowledge, review the build, deployment and recovery process together. My cloud and DevOps service covers deployment work, while backend engineering addresses the application changes behind it. Describe your current release process and the failure you want to prevent.
Need this built?
These services can turn the ideas in this article into production software.
