2. Native
Since the KatApp backend can be compiled, a native deployment can also be carried out without much effort.
The required dependencies, such as the databases and block memory, are not deployed here. These must be provided separately, for example via Docker containers or a manual installation. In addition, no infrastructure is provided for the dashboard, the docs webapp etc.
Necessary tools
- A fully set-up development environment
Create code for the endpoints
As we use automatic code generation for the endpoints, we have to generate the necessary code first, otherwise the compilation will not work.
To do this, execute the VsCode task “Gen: Generate Entry Points (Gin)”. Alternatively, you can execute the following command with absolute paths.
go run tools/codegen/gincodegen/gincodegen.go --template $PWD/cmd/templates/gin/main.go --restDir $PWD/funcs/rest --websocketDir $PWD/funcs/ws --output $PWD/cmd/gin/main.go --module katapp.org/katapp-backend --projectRoot $PWD/
This gives us the file ./cmd/gin/main.go we need for compilation.
Compile the backend
Now we can compile the backend with the following command.
go build -o katapp-backend ./cmd/gin/main.go
This gives us a file with the name katapp-backend in our current folder.
Configure the environment variables
Corresponding environment variables must be set so that the backend knows which database, block memory etc. it should access. You can find an overview of all environment variables here.
You can create environment variables under Linux with the following command.
export ENV_NAME=ENV_VALUE
Start backend
Now we can start the backend with the following command.
./katapp-backend