This repository showcases a Docker-powered self-hosted lab managed by Terraform. This setup is intended for testing demonstration and learning, with planned changes.
- Overview
- Containers
- Networks and Volumes
- Prerequisites
- Setup
- Security and Best Practices
- Future Plans
This Terraform configuration deploys a collection of Docker containers, Each container serves a specific purpose.
- Flame: Start page for centralized access to applications
- NGINX Proxy Manager: Reverse proxy with SSL capabilities
- NextCloud: Self-hosted file-sharing service
- MariaDB: Database service for Nextcloud
- Portainer: Docker container management UI
- Docker Volumes: Persistent storage for Nextcloud, MariaDB, and Portainer.
- Docker Networks: Isolated Docker network for internal communication.
- Terraform: Version 1.0+ Install Terraform
- Docker: Version 20+ Install Docker
-
Clone the repository:
git clone https://github.com/Frulexi/self_hosted.git cd self_hosted
-
Create a terraform.tfvars File Add your specific configuration in a terraform.tfvars file based on the example.
terraform init
-
Apply the Configuration
terrafom apply
Confirm the action with yes when prompted. Terraform will pull Docker images, create containers, set up volumes, and configure networks.
-
Access services
- Flame: http://localhost:5005
- Nextcloud: http://localhost:5080
- Portainer: http://localhost:801
# Define the host path for persistent data storage
host_path = "/path/to/your/storage"
admin_password = "your_secure_admin_password"
root_password = "your_secure_root_password"
admin_user = "nextcloud_admin_user"
- Replace /path/to/your/storage with the path on your system where you want persistent data to be stored.
- Use strong passwords for admin_password and root_password to ensure security.
- Docker Socket Exposure: The Docker socket is mounted for flame and portainer containers. Be cautious with this, as it grants extensive permissions.
- Environment Variables: Sensitive values like passwords are stored in terraform.tfvars, which should not be committed to version control. Use .gitignore to keep it private.
- Grafana + Prometheus: To provide metrics and performance monitoring.
- cAdvisor: For container-level monitoring of CPU, memory, and network usage.
- ELK Stack (Elasticsearch, Logstash, Kibana): For advanced log analysis