From git push to Production
The path from your first commit to a live, secure deployment: every tool in the right order, plus the must-haves a modern production setup needs in 2027.
Watch the intro: how code really reaches production
Getting code to production is not one skill.
It is a chain of five small, boring, repeatable steps:
Git is the single source of truth for your code.
Docker packages your app so it runs the same everywhere.
Terraform / OpenTofu creates the servers, networks and databases your app runs on, from code.
CI/CD connects all of it: every push is tested, built, and deployed automatically.
Production is where real users are. It needs secrets, monitoring, backups and a way to roll back.
The goal is simple: a deploy should be a non-event. You merge a pull request, the pipeline does the rest, and you go get coffee.
Learn it in this order
Open a step, watch the tutorial or read the official docs, then move to the next one. Each tool builds on the one before it.
Step 01 ยท Version controlGitYour code's full history, and the single source of truth. Tap to open โโถ Video tutorial+
What it is. Version control: a full history of every change, who made it, and why.
- Trunk-based development. Short-lived branches merged into
mainoften, not long-running branches that diverge for weeks. - Protected
main. No direct pushes. Require a PR, passing checks and at least one review. - Everything lives in Git. Application code, Dockerfiles, Terraform files, pipeline definitions. If it is not in Git, it does not exist.
- Secrets never enter Git. Add a proper
.gitignore, turn on secret scanning (push protection), and assume anything committed once is compromised forever. - Signed commits are worth enabling once your team grows: they prove who actually wrote the code.
Committing .env files "just for now". Rotate any secret that ever touched a repo, even a private one.
Step 02 ยท ContainersDockerPack your app into one box that runs the same everywhere. Tap to open โโถ Video tutorial+
What it is. A way to bundle your app and everything it needs into an image, which runs as a container.
- Multi-stage build. Build in one stage, copy only the result into a small final stage. Smaller image, smaller attack surface.
- Run as a non-root user.
- Minimal base image. Slim or Alpine variants, distroless images, or Docker Hardened Images (free and open source under Apache 2.0 since late 2025).
- A
.dockerignoreso.git,node_modulesand.envnever end up inside the image. - Tag immutably. Tag images with the Git commit SHA. Never rely on
latestin production. - Scan in CI. Docker Scout, Trivy or Grype, and fail the build on critical findings.
Baking secrets or environment-specific config into the image. The image must be identical in staging and production. Only the config injected at runtime differs.
Step 03 ยท Infrastructure as codeTerraform / OpenTofuCreate servers, networks and databases from code, not clicks. Tap to open โโถ Video tutorial+
What it is. You describe your infrastructure (servers, networks, databases, DNS) in code. The tool compares that description to reality and makes the changes needed. No more clicking around a cloud console.
init โ plan (preview the changes) โ apply (make them).The original HashiCorp tool, under the Business Source License since 2023. Choose it if your company or tooling already standardizes on it.
The open-source fork (Linux Foundation / CNCF, MPL license) with native state encryption. Same HCL language, same workflow.
For a beginner the concepts are identical. Pick one, learn it well, and you can switch in an afternoon.
- Remote state with locking. Never keep state only on your laptop. Recent versions support native locking on S3 without a separate lock table.
- Encrypt state at rest. State can contain secrets in plain text.
- Review the
plan. Post the plan output in every PR. Reading the plan is your safety net. - Separate environments. Staging and production get separate state and separate cloud accounts or projects.
- Pin versions of the tool and providers so a surprise upgrade does not change your infrastructure.
- Detect drift. If someone changes something by hand in the console, code and reality disagree. Run a scheduled
planto catch it.
Running apply from a laptop against production. Production changes should only come from the pipeline, after review.
Step 04 ยท AutomationCI/CDA robot that tests, builds and ships your code on every push. Tap to open โ๐ Official docs+
What it is. CI (Continuous Integration): every push is automatically built and tested. CD (Continuous Delivery / Deployment): passing builds are automatically released.
Build once, promote the same artifact. The exact image that passed tests in staging is the one that goes to production. You never rebuild for production.
- No long-lived cloud keys. Use OIDC (workload identity federation): the pipeline proves its identity and receives short-lived credentials that expire when the run ends. Lock the cloud role's trust policy to your repository and branch or environment.
- Least-privilege permissions. Start every workflow read-only and grant more only where needed.
- Pin third-party actions to a full commit SHA, not a floating tag. Supply-chain attacks on CI are now a primary attack surface.
- Protected environments. Production deploys require approval and can only run from
main. - Concurrency control. Never let two deploys to the same environment run at once.
- Automated dependency updates (Dependabot or Renovate), so you are not running year-old packages.
A pipeline that only runs tests, while someone still SSHes into a server to deploy by hand.
Step 05 ยท Going liveProductionSecrets, monitoring, backups and a way to roll back. Tap to open โ๐ Official docs+
What it is. Production is where real users are. Getting there safely means a runtime to run on, secrets kept out of code, eyes on what is happening, and a way back when a release goes wrong.
Treating "it runs" as "it is production-ready". It is only ready when you can rebuild it, see it, recover it and trust it.
Pick the simplest runtime that fits
You have an image and infrastructure. Now choose where it runs.
One VPS + Docker Compose
Good for: Side projects, early products, learning
Trade-off: You own patching and uptime.
Managed container platform
Good for: Most real products
Trade-off: Less control, a bit more cost.
AWS ECS / Fargate ยท Google Cloud Run ยท Azure Container Apps ยท Fly.ioKubernetes
Good for: Many services, large teams, special scaling needs
Trade-off: Real operational complexity.
Honest advice: most products never need Kubernetes. Start boring. Move up only when you can name the specific problem the simpler option cannot solve.
Six habits that keep production boring
Day-one practices for secrets, visibility, releases, security, recovery and cost. None of them are optional.
Secrets and config
- Config comes from the environment, not from the code or the image.
- Secrets live in a secrets manager (AWS Secrets Manager / SSM, Google Secret Manager, Azure Key Vault, Doppler, 1Password), not in files, chat or Git.
- Separate secrets per environment: the staging database password must differ from production.
- Rotate regularly, and immediately after any suspected leak.
- Give each service only the secrets it needs.
Observability
- Health checks: a
/healthendpoint your platform checks, so unhealthy instances are replaced automatically. - Structured logs sent to one searchable place, not trapped on a server.
- Metrics: error rate, latency, CPU and memory, request volume.
- Uptime monitoring from outside your infrastructure, plus error tracking such as Sentry.
- Alert on symptoms users feel (errors, slowness, downtime), not on every internal blip.
Release safety
- A rollback plan: images tagged by commit SHA mean rolling back is redeploying the previous tag. Practice it.
- Pick a strategy: rolling, blue/green or canary.
- Database migrations are the dangerous part. Use expand and contract: add backward-compatible structure first, remove the old one later.
- Feature flags separate deploy from release.
- A staging environment that mirrors production.
Security
- MFA on everything: cloud account, GitHub, registry, domain registrar.
- Least-privilege IAM. No shared admin keys, no wildcard permissions.
- Databases and internal services stay on private networks.
- Keep everything patched: base images, dependencies, the OS if you run servers.
- HTTPS everywhere, with free automatic certificates.
Backups and recovery
- Backups you have actually restored. An untested backup is only a hope.
- RPO (Recovery Point Objective): how much data can you afford to lose?
- RTO (Recovery Time Objective): how long can you stay down?
- Choose backup frequency and recovery steps from those two numbers.
- Prefer a managed database over running your own in a container.
Cost
- Set a budget alert on day one. A forgotten resource can produce a surprise bill fast.
- Tag resources so you know what belongs to what.
- Destroy what you do not use. Infrastructure as code makes cleaning up (and rebuilding) cheap.
- Pick resource sizes from real usage and review costs regularly.
What a release looks like, end to end
Put everything together and one merge takes your code all the way to users.
Open a branch and write code. Small, focused changes.
Open a pull request. CI runs tests, scans, and shows the infrastructure plan.
A teammate reviews and approves. Review is part of the system.
Merge to main. The only trigger for a release.
The pipeline builds the Docker image, tags it with the commit SHA and pushes it to the registry.
It deploys to staging and runs smoke tests.
After approval it promotes the same image to production, using short-lived OIDC credentials.
Monitoring confirms the release is healthy. If not, roll back to the previous tag.
The rules experienced teams swear by
The pipeline is the only door to production. A "quick fix in the console" creates drift that will bite you later.
Zero long-lived credentials. OIDC for CI to cloud, short-lived tokens wherever the platform offers them.
Treat your CI like production. Pin actions to SHAs, restrict who can trigger deploys, review workflow changes like app code.
AI makes code cheaper, so guardrails matter more. Tests, CI checks, scanning and review keep bad changes out. Never ship code you cannot explain.
Build once, promote the same image digest. Rebuilding per environment is how "it worked in staging" happens.
Start with the boring runtime. One VPS or a managed container service carries you very far. Add complexity only for a named problem.
Read every plan. Most infrastructure disasters are a destroy-and-recreate nobody noticed.
Automate dependency updates and keep the pipeline fast. A slow pipeline gets bypassed.
Write a one-page runbook: how to deploy, how to roll back, who to call, where the dashboards and logs are.
Test your restore, not just your backup, and rehearse a rollback while nothing is on fire.
Budget alerts and MFA before anything else. Ten minutes, and they prevent the two most expensive beginner mistakes.
How close is your app to production?
Tick what you already have. Do not aim for a perfect enterprise setup on day one: start with the essentials, verify they work, and improve as you grow.
Code and Git
Docker and application
Infrastructure
CI/CD
Operations and security
Terms you will meet on the way
You have the map. Now build the real system.
Git Push to Prod takes you from an empty repo to a live AWS deployment with Docker, Terraform and CI/CD, by building one complete, real system instead of isolated demos.
PRODat checkout