A dynamic Python script for automating app deployments to cloud servers. Supports multiple project types by downloading and executing project-specific deployer scripts from separate repositories, using a flexible configuration file for easy management of server details, SSH keys, and deployment paths.
- Project-specific deployment configuration using JSON files
- Support for multiple project types (currently Phoenix and Rust)
- Automatic download and update of project-specific deployer scripts
- Logging of deployment process with timestamps
- Error handling and validation of required parameters
- Flexible command execution for different project types
- SSH-based deployment to remote servers
- Optional database handling for Phoenix projects
- Dynamic script selection based on project type
- Automatic creation of log directories
- Real-time console output for deployment progress
- Parameterized deployment allowing for project name and deployment directory specification
- Version checking and updating of deployer scripts
- Secure handling of SSH keys and server credentials
- Cross-platform compatibility using PowerShell for certain operations
- Clone the repository to your local machine.
To use the cloud-deployer, follow these steps:
-
Ensure you have a
config.json
file in your deployment directory with the necessary configuration for your project(s). -
Open a command prompt or terminal.
-
Navigate to the directory containing the
main.py
script. -
Run the script with the following command structure:
python main.py -pn <PROJECT_NAME> -cd <CLOUD_DIRECTORY>
Where:
-pn
: Specifies the project name (must match a project name in yourconfig.json
)-dd
: Specifies the deployment directory (where yourconfig.json
is located)
Example:
python main.py -pn my_phoenix_app -cd C:\deployments\my_phoenix_app
-
The script will automatically:
- Load the configuration for the specified project
- Download or update the appropriate deployer script (Phoenix or Rust)
- Execute the deployment process
- Log all actions to a timestamped log file in the
logs
subdirectory of your deployment directory
-
Monitor the console output for real-time deployment progress and check the log file for detailed information.
Ensure your config.json
file in the deployment directory has the following structure for each project:
{
"project_name": {
"type": "phoenix|rust",
"ssh_key": "path/to/ssh_key.pem",
"ssh_username": "username",
"server_address": "server_address",
"code_dir": "path/to/code/directory",
"command": "deployment_command",
"db": true|false
}
}
- The
type
field should be either "phoenix" or "rust". - The
ssh_key
field should point to the path of your SSH key file. - The
ssh_username
is the username used for SSH connection. - The
server_address
is the IP address or domain of your deployment server. - The
code_dir
is the directory where your project code is located. - The
command
field specifies the deployment command to run. - The
db
field is a boolean indicating whether database operations are required (primarily for Phoenix projects). - For Phoenix projects, both
command
anddb
fields are required. - For Rust projects, the
db
field is optional and typically set tofalse
.
Ensure that all paths are correct and accessible, and that the SSH key has the necessary permissions for deployment.