Automation
← Projectsinfra-lab
Phase 2 / 3 in progressA DevOps project documenting the deployment of a Go application across three infrastructure paradigms: VM, Docker, Kubernetes.
- Stack
- Go · Docker · Terraform · AWS
- Deployment time
- 1 min 37 → 8 s
- Provisioning
- 37 s
The idea is to understand why each technology exists by first running into the problems it solves. Each step is documented day by day on the project site.
Progression
-
Phase 1 · Complete
Deployment on a virtual machine
The server and its network are described as code with Terraform on AWS. The app is first deployed by hand, then with a script.
-
Phase 2 · In progress
Containerization
The app, its PostgreSQL database and Prometheus run in containers orchestrated by Docker Compose, with a separate configuration for development and production.
-
Phase 3 · Upcoming
Orchestration
Moving to Kubernetes, Git-driven deployments with ArgoCD, and monitoring across the whole cluster.
Technical Architecture
What Each Step Solved
Deploying by hand. Installing Go, creating a dedicated user, copying files, writing the system service: a first manual deployment takes 15 to 20 minutes, and every step is a chance to get something wrong. A missing user or a port already in use is enough to keep the app from starting.
A script to automate it. The script chains everything, from creating the server to starting the app, in 1 min 37. It also handles the cases that broke the first attempts: a port already taken, a launch from another directory. But it stays tied to the state of the server it runs on.
Containers. With Docker, the app starts in under 8 seconds. A multi-stage build separates compilation from execution: the final image holds only the Go binary, on an Alpine base. The three containers together (app, database and monitoring) use about 61 MB of memory.
Starting in the right order. The app must not start before its database is ready: each container checks its own health, and the startup order depends on it.
Keeping the data. PostgreSQL data survives restarts thanks to Docker volumes, and backup and restore scripts were written and tested.
Separating development and production. A shared configuration, extended by one variant per environment: in production, passwords are read from an environment file, memory is capped and logs are kept to the essentials.
Roadmap
- To do: CI/CD pipeline with GitHub Actions
- To do: PostgreSQL database on RDS
- To do: Grafana dashboards and alerting
- To do: Log aggregation (Loki)
Built With
- Terraform
- EC2, VPC and security group provisioning on AWS
- Go 1.21
- Backend API with native Prometheus instrumentation
- Docker
- Multi-stage builds with an optimized Alpine image
- Docker Compose
- Service orchestration, dev and prod configurations
- PostgreSQL 15
- Database, persistent volumes and backup/restore scripts
- Prometheus
- System and business metrics, health checks