CI/CD configuration
The approach recommended by Hosty to deploy the code and manage environemnts is through CI/CD platforms like CircleCI, TravisCI, Github Actions and similar.
Hosty has a special user role called Release manager who has permissions to create, update and delete environments on the hosting. It was designed specifically for use in CI/CD platforms.
The recommended deployment workflow consists of several subsequent steps:
- Checkout the git branch and install project dependencies
- Install and configure Hosty CLI
- Install VPN client and connect to the cluster's VPN
- Build and deploy the code
- Run post-deploy scripts
- Disconnect from VPN
This is simplified example is made using syntax for CircleCI platform, however, similar steps can be applied to any other CI/CD platform.
In this example CI uses compose.yaml file in a project root, which will be used by Docker Compose to perform operations via Hosty CLI:
In order to store AWS access key, secret key and VPN configuration profile we use environmental variables. Access keys of a dedicated user with Release manager role are stored in AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY variables. The VPN configuration profile file is encoded using base64 (base64 -i *.ovpn -o encoded.txt) and stored in AWS_VPN_CLIENT_CONFIG variable.
Here are the contents of .circleci/config.yml file: