Bootstrap
Here we describe how to can start new Devotion projects.
New pure API project
Project creation
To bootstrap within an existing Git project:
# ./my-new-api could already contain a .git directory, after a git cloning for instance
cd ./my-new-api
# Then, we can bootstrap right here with this:
aldev bootstrap -n MyNewApi -w --destination .
We can also bootstrap the project and git-init it right away:
cd $GITPRIV
aldev bootstrap -n MyNewApi -w --repo my-git.domain.com --group group-name[/subgroup]
# this creates and push the new project to https://my-git.domain.com/group-name[/subgroup]
The Go API code is in the /api folder.
Working with the new API
First, go into the project: cd my-new-api.
Then, for the aldev command to work, its config, the .aldev.yaml file, should be filled up / completed.
Once the config (.aldev.yaml) is set up, we run the API server with just:
aldev
Or, if you want more details about what's under the hood:
aldev -v
# or
aldev --verbose
You can learn more about aldev later, but what you can at least see from the logs is that it created 3 instances of your new API + a load balancer (Nginx) in front of them.
Which can be confirmed by checking with this:
podman ps
Don't git-push anything just yet, we'll need to do it later on, at the deployment stage.
As you'll learn later on, aldev generates config files, for local building & testing, as well as remote deployment. Depending on the configured deployment platform and CI/CD method, it might require for the project to be git-initialized - which is automatically the case if you've used aldev bootstrap with the --repo arg.
Developing & testing the API
You can start modifying the Go code in the /api folder while aldev is running.
More details about how it's architectured in the Goald documentation.
As soon as you save your changes, aldev will perform automatic operations, and locally re-deploy the updated server's instances.
This allows for quick dev & test iterations.
Testing the API
To test, do this in another terminal window:
# adapt the port to what's actually configured
curl http://localhost:42069/rest/translation/fr\?Namespace\=Common
This should return a JSON response with translations.
If you repeat this request several times, you'll see in aldev's log that the load balancing is effective.
Deploying
Handled platforms
Depending on what's configured in the .aldev.yaml file, CI/CD and infrastructure management can be assisted by aldev.
In particular:
- the config item
deploying > platforminfluences what files (e.g. Terraform configs)aldevgenerates to help with infra - the config item
deploying > cicdinfluences what files (form instance:.gitlab-ci.yml)aldevgenerates to help with CI/CD
For now:
- only the value
"azure"fordeploying > platformhas an effect: it triggers the creation of Terraform Azure configs in thedeploy/remotefolder - only the value
"gitlab"fordeploying > cicd, in conjonction withdeploying > platform = azurehas an effect: it triggers the creation of a.gitlab-ci.ymlfile, which helps continuously deploying to Azure
Learn more here about Gitlab CI/CD + Azure deployment.
As of now, the aldev-generated .gitlab-ci.yml and Terraform files already help us continuously develop & deploy to Azure.
Learn how to use it here.