The Activist Development Environment is a custom-built remote development solution designed to provide a cost-effective and efficient alternative to local Docker development and cloud-based development environments like GitHub Codespaces. Recognizing the resource-intensive nature of local Docker Desktop development and the higher costs associated with cloud-based alternatives, this project was created to offer a streamlined, remote development experience.
This environment leverages DigitalOcean droplets as remote development servers, managed through a combination of Terraform for infrastructure provisioning and Ansible for configuration management. The system is designed to be lightweight, secure, and easily reproducible, while maintaining the flexibility needed for modern web application development.
Key features of the environment include:
The environment is particularly well-suited for developers who:
By providing a remote development environment that balances performance, cost, and flexibility, this project aims to make development more accessible and efficient for individual developers and small teams working on the Activist application.
Install Required Tools:
# Install Terraform
brew install terraform
# Install Ansible
brew install ansible
# Install DigitalOcean CLI
brew install doctl
Configure DigitalOcean Access:
# Authenticate with DigitalOcean
doctl auth init
# Add your SSH key to DigitalOcean
doctl compute ssh-key create <key-name> --public-key-file ~/.ssh/id_rsa.pub
Clone the Repository:
git clone https://github.com/your-username/activist-dev-env.git
cd activist-dev-env
Configure Environment Variables:
Set the DO_TOKEN environment variable:
export DO_TOKEN="your_digitalocean_api_token"
Initialize Terraform:
cd terraform/environments/dev
terraform init
Create Infrastructure:
terraform apply
Deploy with Ansible:
cd ../../ansible
ansible-playbook -i inventory/dev playbooks/deploy.yml
Access Your Environment:
# Get the droplet IP
DROPLET_IP=$(terraform output -raw droplet_ip)
# SSH into the droplet
ssh root@$DROPLET_IP
.
├── ansible/ # Ansible configuration and playbooks
├── terraform/ # Terraform infrastructure definitions
├── scripts/ # Utility scripts for development
├── .env # Environment variables
├── README.md # Project documentation
└── .gitignore # Git ignore rules
ansible/
├── playbooks/ # Deployment playbooks
├── inventory/ # Inventory files for different environments
├── roles/ # Custom Ansible roles
├── templates/ # Configuration templates
└── ansible.cfg # Ansible configuration
terraform/
├── environments/ # Environment-specific configurations
│ ├── dev/ # Development environment
│ ├── staging/ # Staging environment
│ └── production/ # Production environment
├── modules/ # Reusable Terraform modules
└── shared/ # Shared Terraform configurations
scripts/
├── droplet-manager.sh # Main management script
├── ssh-tunnel.sh # SSH tunnel management
└── utils/ # Utility scripts
ansible/group_vars/: Group variables for Ansible
ansible/host_vars/: Host-specific variables for Ansible
ansible.cfg: Ansible configuration
terraform/shared/provider.tf: Terraform provider configuration
terraform/shared/versions.tf: Terraform version requirements
The only required environment variable is:
DO_TOKEN: Your DigitalOcean API tokenTo set this up:
Add to Shell Configuration:
Add the following to your shell’s rc file (~/.bashrc, ~/.zshrc, etc.):
export DO_TOKEN="your_digitalocean_api_token"
Reload Shell Configuration:
source ~/.bashrc # or ~/.zshrc
The project uses a config.yml file for application and environment-specific settings. To set up your configuration:
Copy the Template:
cp config.yml.template config.yml
Edit the Configuration:
Open config.yml in your text editor and fill in the appropriate values. Refer to the template file for the complete structure and available options.
Save the File:
After filling in the values, save the file as config.yml.
The configuration file is organized into the following sections:
<your-username>) with actual values.Start Development Environment:
./scripts/droplet-manager.sh start
Set Up SSH Tunnel:
./scripts/ssh-tunnel.sh start
Deploy Application:
cd ansible
ansible-playbook -i inventory/dev playbooks/deploy.yml
Initialize Terraform:
cd terraform/environments/staging
terraform init
Create Infrastructure:
terraform apply
Deploy Application:
cd ../../ansible
ansible-playbook -i inventory/staging playbooks/deploy.yml
Initialize Terraform:
cd terraform/environments/production
terraform init
Create Infrastructure:
terraform apply
Deploy Application:
cd ../../ansible
ansible-playbook -i inventory/production playbooks/deploy.yml
Create Droplet:
doctl compute droplet create <name> \
--region nyc3 \
--image ubuntu-22-04-x64 \
--size s-1vcpu-1gb \
--ssh-keys <your-key-fingerprint>
Configure Firewall:
doctl compute firewall create \
--name activist-firewall \
--inbound-rules "protocol:tcp,ports:22,address:0.0.0.0/0" \
--outbound-rules "protocol:tcp,ports:all,address:0.0.0.0/0"
Clone the Repository:
git clone https://github.com/your-username/activist-dev-env.git
cd activist-dev-env
Set Up Environment Variables:
Create a .env file with your DigitalOcean API token:
export DO_TOKEN="your_digitalocean_api_token"
Install Dependencies:
brew install terraform ansible doctl
Initialize Development Environment:
./scripts/droplet-manager.sh start
shellcheck for lintingset -euo pipefail for error handlingansible-lint for lintingterraform fmt for formattingbats for unit testingmolecule for testing rolesterraform validate for syntax checkingmainThis project is licensed under the MIT License. Below is a summary of the key terms:
The full text of the MIT License is included in the LICENSE file in the root of this repository.
By contributing to this project, you agree to license your contributions under the same MIT License terms.
This project may include third-party libraries or tools, each with its own license. Please refer to the respective documentation for their licensing terms.
We welcome contributions from the community! Here’s how you can help improve the Activist Development Environment:
Fork the Repository: Click the “Fork” button on the GitHub repository page to create your own copy.
Clone Your Fork:
git clone https://github.com/your-username/activist-dev-env.git
cd activist-dev-env
Set Up Development Environment: Follow the Development section to set up your local environment.
Create a Feature Branch:
git checkout -b feature/your-feature-name
Commit Your Changes:
Use descriptive commit messages:
git commit -m "Add feature: your feature description"
Push to Your Fork:
git push origin feature/your-feature-name
Check Existing Issues: Search the issue tracker to see if your issue has already been reported.
Create a New Issue:
All contributors are expected to follow our Code of Conduct. Please be respectful and considerate in all interactions.
We appreciate all contributions, whether it’s code, documentation, or bug reports. Thank you for helping make this project better!
This repository includes a real-time code synchronization system that automatically syncs your local code changes to the remote droplet. This ensures that your development environment is always up-to-date with your latest changes.
The code sync feature is automatically set up and started as part of the droplet-manager.sh --create process. When you create a new droplet, the code sync service will:
brew install fswatch)The code sync service runs automatically, but you can control it manually if needed:
# Stop the code sync service
./code-sync.sh stop
# Start the code sync service in interactive mode
./code-sync.sh interactive
# Start the code sync service in automatic mode
./code-sync.sh
The real-time code sync service:
rsync for efficient file transfersfswatchTo monitor the sync process:
# View sync logs
cat code-sync.log
# Check if the service is running
ps aux | grep code-sync
# Restart the service if needed
./code-sync.sh stop && ./code-sync.sh
The sync script is generated based on your config.yml settings: