This repository contains Infrastructure as Code (IaC) configurations to deploy Saleor, a modular e-commerce platform, on DigitalOcean cloud infrastructure. The project demonstrates modern DevOps practices including infrastructure provisioning with Terraform and configuration management with Ansible.
The infrastructure consists of:
- VPC Network: Isolated network environment for secure communication
- Application Server: DigitalOcean droplet running Docker containers for:
- Saleor API
- Dashboard (Admin Interface)
- Storefront
- Managed Database: DigitalOcean managed PostgreSQL instance
- Managed Redis: DigitalOcean managed Redis cluster for caching
- Container Orchestration: Docker Compose for service management
sample overview
graph TD;
Internet[Internet]
VPC[VPC Network]
Droplet[Debian-Docker]
Postgres[Managed PostgreSQL]
Redis[Managed Redis]
Storefront[Storefront]
Internet --> VPC
VPC --> Droplet
VPC --> Postgres
VPC --> Redis
Droplet --> Postgres
Droplet --> Redis
Droplet --> Storefront
- DigitalOcean account with API access
- Terraform >=1.0.0
- Ansible >=2.9
- SSH key pair
- Linux/macOS environment (Windows users should use WSL2)
- VPC isolation for internal service communication
- Managed database with automated backups
- Environment-based configuration
- Secure secret management
- SSH key authentication
-
Clone this repository:
git clone https://github.com/Boximity-Dev/devops-demo.git cd saleor-cloud-infrastructure -
Create a
secrets.tfvarsfile:do_token = "your_digitalocean_api_token" ssh_key_fingerprint = "your_ssh_key_fingerprint" environment = "staging" # or "prod"
-
Initialize and apply Terraform configuration:
cd terraform terraform init terraform plan -var-file="secrets.tfvars" terraform apply -var-file="secrets.tfvars"
-
Export required environment variables:
export DROPLET_IP=$(terraform output -raw droplet_ip) export DB_HOST=$(terraform output -raw database_host) export REDIS_HOST=$(terraform output -raw redis_host) export DB_PASSWORD="your_database_password" export REDIS_PASSWORD="your_redis_password"
-
Run Ansible playbook:
cd ../ansible ansible-playbook -i inventory/hosts.yml site.yml
Modify variables.tf to adjust resource sizes:
variable "droplet_size" {
default = "s-2vcpu-4gb" # Increase for higher load
}
variable "db_size" {
default = "db-s-1vcpu-1gb" # Adjust based on data volume
}Change the region in variables.tf:
variable "region" {
default = "nyc1" # Available: fra1, lon1, sgp1, etc.
}- Infrastructure state is maintained in Terraform state files
- Ansible playbooks can be re-run for configuration updates
- DigitalOcean provides monitoring dashboards
- Logs available via Docker Compose
- Database backups are automated via DigitalOcean
- Infrastructure can be recreated with:
terraform destroy -var-file="secrets.tfvars" terraform apply -var-file="secrets.tfvars"
- Application state is restored from database backups
Estimated monthly costs (may vary):
- Droplet (s-2vcpu-4gb): ~$20
- Database (db-s-1vcpu-1gb): ~$15
- Redis (db-s-1vcpu-1gb): ~$15
- Total: ~$50/month
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
MIT License - see LICENSE file for details
Need help with:
- Custom infrastructure design?
- Production deployment?
- Infrastructure audit?
- Performance optimization?
Contact: @matthewmattice
Matthew Mattice Founder, Boximity Inc.
- GitHub: @Boximity-Dev
- LinkedIn: @MatthewMattice
Built with ❤️ using Terraform, Ansible, and DigitalOcean