Containerized PROD
Deploy Automail using serverless for PROD and UAT usage.
The following steps will install Automail in a Docker environment running on Amazon Elastic Container Service (ECS) with Gunicorn as the web application server, nginx as the reverse proxy, and a MySQL database hosted in RDS. The workflows are managed by Amazon Managed Workflows for Apache Airflow (MWAA), with a dedicated control interface.
The installation will set up a CI/CD pipeline connected to the master branch of the instance's GitHub fork. This means every push to the main branch will deploy the change automatically.
The default top-level domain for containerized deployments is lineverge.io, and all instances will automatically have a wildcard SSL certificate enrolled.
Infrastructure
The high-level infrastructure is represented in the following diagram:
Deployment
It is important to keep the stack names aligned with the forked repo name.
E.g. if the forked repo name is "automail-lv-cookie", then the AWS service name (i.e. service_name below) must also be exactly "automail-lv-cookie".
Create a new file deployment\container\terraform\settings.tfvars. The file should define the following variables, which will be used for the deployment:
Deploy Automail by navigating to deployment\container\terraform folder and running:
terraform init terraform apply -var-file="settings.tfvars"
This will take around 30 minutes to complete.
Congrats! Your Automail instance is deployed with a dedicated deployment pipeline🎉
For any updates, simply commit your changes and push to the main GitHub branch. This will trigger the pipeline, which can take 8 minutes to complete and be visible within the application.
Workflows
Workflows are set up as Airflow DAGs that run on MWAA. The schedule of each task must be defined in the project-specific project/[workflow].py file, which has the following syntax:
The workflow executable Python files (e.g. uploadfile_order.py above) must be stored within the project folder and follow the proper DAG syntax (using the Automail wrapper).
Below is an example of a DAG, which will run on a 10 minutes' interval:
Deletion
To delete the environment, run the following command:
terraform destroy -var-file="settings.tfvars"
Careful! This will completely destroy the environment including all database data. Make sure to make a backup first for all data that needs to be kept.
Debugging
Container Level
For any issues related to the containers, consult the logs in ECS.
Application Level
Application logs are accessible in CloudWatch. Use the log function for that purpose in the Python files.
Example:
Last updated