Backend Development
HobbyFarm makes use of a backend service called Gargantua. Gargantua is a RESTful API written in Go. The following instructions will assist in setting up a local development environment for Gargantua.
The following instructions will assist in setting up a local development environment for Gargantua.
Requirements
Gargantua is written in Go. To develop Gargantua, knowledge of Go is required.
The following tools are required to be installed:
Setup
The following instructions will assist in setting up a local development environment for Gargantua.
Clone the Gargantua repository.
## Clone the Gargantua repository git clone https://github.com/hobbyfarm/gargantua.gitClone the HobbyFarm repository.
## Clone the HobbyFarm repository git clone https://github.com/hobbyfarm/hobbyfarm.gitChange into the HobbyFarm directory.
## Change into the Gargantua directory cd hobbyfarmModify the Docker Compose variables for the local environment as needed.
## Copy the example environment file cp .env.example .env ## Edit the file vim .envStart the Docker Compose stack. This will provide a K3d cluster for CustomResourceDefinitions (CRD).
## Start the Docker Compose stack ./compose.sh up ## Alternatively, build changes to the local development container ## Only required if a file in ./cicd/docker-local has changed ./compose.sh up --build ## To stop the Docker Compose stack ./compose.sh stop ## To destroy the Docker Compose stack ./compose.sh destroy
Compose.sh Script
The compose.sh script is a wrapper around docker-compose that performs the following fuctions:
- Connects to the external Docker network called
hobbyfarm-dev. - Mounts the external volumes for Kubernetes Service Account credentials called
hobbyfarm-kube-sa. - Calls
docker-compose upwhich starts thehf-gargcontainer, listening onlocalhost:16210. - The
hf-gargcontainer runs a watch loop on Golang files, rebuilds on detected changes.