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:
- Automated setup of remote development servers
- Secure SSH tunnel management for local access
- Pre-configured development tools and dependencies
- Support for both staging and production environments
- Cost-effective resource utilization
- Cross-platform compatibility (Linux and macOS)
The environment is particularly well-suited for developers who:
- Find local Docker development too resource-intensive
- Want to avoid the higher costs of cloud-based development environments
- Need a consistent development environment across multiple machines
- Require secure access to development resources
- Want to maintain control over their development infrastructure
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.
-
Automated Infrastructure Provisioning:
- Command-line interface for environment setup
- Built-in support for multiple environments (dev, staging, production)
-
Remote Development Environment:
- Secure SSH access to remote servers
- Consistent configurations across machines
-
Cost Optimization:
- Pay-as-you-go pricing model
- Automatic shutdown of unused resources
- Environment Management:
- Easy environment replication
- Automated dependency installation
- Access Control:
- SSH key-based authentication
- VS Code Remote Development:
- Seamless integration with VS Code
- Remote debugging capabilities
- Operating Systems:
- Full support for Linux and macOS
-
Environment Configuration:
- Customizable server sizes
- Selectable operating systems
- Configurable development tools
-
Project-Specific Setup:
- Custom environment variables
- Project-specific dependencies
- Tailored deployment configurations
-
Command Line Tools:
- Git (version 2.25.0 or higher)
- Terraform (version 1.10.5 or higher)
- Ansible (version 2.18 or higher)
- DigitalOcean CLI (doctl) (version 1.94.0 or higher)
-
Development Environment:
- Python 3.8 or higher
- Node.js 16.x or higher
- Docker (for local container management)
-
Text Editors/IDEs:
- VS Code (with Remote Development extension)
- Any SSH-compatible text editor
-
DigitalOcean:
- API token with read/write permissions
- SSH key registered with DigitalOcean
-
Application:
- Environment variables for development
- Any required API keys for third-party services
-
Operating Systems:
- macOS 10.15 (Catalina) or higher
- Linux (Ubuntu 20.04 or higher, CentOS 7 or higher)
-
Hardware:
- Minimum 4GB RAM
- 10GB free disk space
- Stable internet connection
-
DigitalOcean:
- Active DigitalOcean account
- Payment method configured
-
Version Control:
- GitHub account (for repository access)
- SSH key configured for GitHub
-
Ports:
- Open SSH port (22)
- Access to DigitalOcean API endpoints
-
Firewall:
- Ability to create SSH tunnels
- Access to required development ports
-
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_TOKENenvironment 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
- Configure your development environment
- Set up VS Code Remote Development
- Explore the project structure
.
├── ansible/ # Ansible configuration and playbooks
├── terraform/ # Terraform infrastructure definitions
├── scripts/ # Utility scripts for development
├── .env # Environment variables
├── README.md # Project documentation
└── .gitignore # Git ignore rulesansible/
├── playbooks/ # Deployment playbooks
├── inventory/ # Inventory files for different environments
├── roles/ # Custom Ansible roles
├── templates/ # Configuration templates
└── ansible.cfg # Ansible configurationterraform/
├── environments/ # Environment-specific configurations
│ ├── dev/ # Development environment
│ ├── staging/ # Staging environment
│ └── production/ # Production environment
├── modules/ # Reusable Terraform modules
└── shared/ # Shared Terraform configurationsscripts/
├── droplet-manager.sh # Main management script
├── ssh-tunnel.sh # SSH tunnel management
└── utils/ # Utility scriptsansible/group_vars/: Group variables for Ansible
ansible/host_vars/: Host-specific variables for Ansibleansible.cfg: Ansible configuration
terraform/shared/provider.tf: Terraform provider configuration
terraform/shared/versions.tf: Terraform version requirementsThe only required environment variable is:
DO_TOKEN: Your DigitalOcean API token
To 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.ymlin 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:
- Application: General application settings
- Project Structure: Directory paths for the project
- DigitalOcean: DigitalOcean droplet and infrastructure settings
- SSH Tunnel: SSH tunnel configuration for remote access
- Docker: Docker and container management settings
- Deployment: Deployment and timeout settings
- Node.js: Node.js and package manager configuration
- Logging: Logging settings and file management
- Security: Security and file permission settings
- Replace placeholders (e.g.,
<your-username>) with actual values. - Ensure sensitive values (e.g., SSH keys) are kept secure.
- Use the same structure as the template to avoid errors.
-
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"
-
Public Network:
- SSH access (port 22)
- Application ports (3000, 8000, 5432)
-
Private Network:
- Database access
- Internal service communication
-
SSH Access:
- Use SSH keys instead of passwords
- Restrict access to specific IPs
- Use SSH tunnels for secure communication
-
Firewall Rules:
- Only open necessary ports
- Use DigitalOcean's built-in firewall
- Regularly review and update rules
-
Data Protection:
- Use encrypted volumes for sensitive data
- Regularly back up important data
- Use secure protocols for data transfer
-
Clone the Repository:
git clone https://github.com/your-username/activist-dev-env.git cd activist-dev-env -
Set Up Environment Variables:
Create a
.envfile 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
-
Shell Scripts:
- Use
shellcheckfor linting - Follow Google Shell Style Guide
- Use
set -euo pipefailfor error handling
- Use
-
Ansible:
- Use
ansible-lintfor linting - Follow Ansible Best Practices
- Use roles for reusable components
- Use
-
Terraform:
- Use
terraform fmtfor formatting - Follow Terraform Best Practices
- Use modules for reusable components
- Use
-
Shell Scripts:
- Use
batsfor unit testing - Test error handling and edge cases
- Verify script output and exit codes
- Use
-
Ansible Playbooks:
- Use
moleculefor testing roles - Test idempotency
- Verify playbook execution
- Use
-
Terraform Configurations:
- Use
terraform validatefor syntax checking - Test plan output
- Verify infrastructure creation
- Use
-
Branching:
- Create feature branches from
main - Use descriptive branch names
- Keep branches focused on single features
- Create feature branches from
-
Pull Requests:
- Include clear descriptions
- Reference related issues
- Ensure all tests pass
-
Code Review:
- Review for style and best practices
- Verify functionality
- Check for security issues
-
Documentation:
- Update README for new features
- Add inline comments where necessary
- Document any breaking changes
This project is licensed under the MIT License. Below is a summary of the key terms:
- Use: Free to use for any purpose, including commercial use
- Modify: Free to modify and adapt the code
- Distribute: Free to distribute the original or modified versions
- Attribution: Must include the original copyright notice and license terms in all copies or substantial portions of the software
- Liability: The software is provided "as is," without warranty of any kind
- Warranty: No guarantee of fitness for a particular purpose
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
-
Make Your Changes:
- Follow the code style guidelines
- Write tests for new functionality
- Update documentation as needed
-
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
-
Create a Pull Request:
- Go to the GitHub repository page
- Click "New Pull Request"
- Select your feature branch
-
Describe Your Changes:
- Provide a clear title and description
- Reference any related issues
- Include screenshots or test results if applicable
-
Address Feedback:
- Respond to code review comments
- Make requested changes
- Push updates to your branch
-
Reviewers:
- At least one maintainer will review your PR
- Reviews focus on code quality, functionality, and style
-
Approval:
- PRs require at least one approval before merging
- All tests must pass
-
Merging:
- Maintainers will squash and merge approved PRs
- Your changes will be included in the next release
-
Check Existing Issues: Search the issue tracker to see if your issue has already been reported.
-
Create a New Issue:
- Provide a clear title and description
- Include steps to reproduce
- Add relevant logs or screenshots
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!
- Added: Initial project setup with Terraform and Ansible
- Added: Basic droplet management scripts
- Added: SSH tunnel configuration
- Added: Documentation and README
- Added: Support for multiple environments (dev, staging, production)
- Added: Automated dependency installation
- Improved: Error handling in deployment scripts
- Fixed: SSH key management issues
- Initial Release: Basic functionality for remote development environment