conf | ||
controllers | ||
docs | ||
models | ||
out/docs/UML/plantuml/diagram_object_models | ||
routers | ||
scripts | ||
selfapi | ||
services | ||
.dockerignore | ||
.gitignore | ||
conf_template.json | ||
docker_catalog.json | ||
docker-compose.backend.yml | ||
docker-compose.multi.yml | ||
docker-compose.yml | ||
Dockerfile | ||
go.mod | ||
go.sum | ||
LICENSE | ||
local_catalog.json | ||
main.go | ||
README.md |
OC Catalog
OpenCloud Catalog API
Uses the Beego framework
To install the Beego bee command :
go install github.com/beego/bee/v2@master
Running the app locally
In order to run the application we need to correct some errors that beego generates.
Router generation
Beego generates the routers from the comment of the controllers methods. However, there seems to be some errors when we let beego generate th routers from bee run
.
We need to use bee generate routers
to have a working router file.
Swagger generation
Using bee run -downdoc=true -gendoc=true
beego download a swagger template and generate the JSON file (swagger.json) in swagger/
. However the swagger template in swagger/index.html
does not change the exemple's url for our current JSON file. When running locally we have to edit the call to construct the object holding the swagger information, with the parameter url set with the relative path to our JSON swagger file :
const ui = SwaggerUIBundle({
url: "swagger.json",
...
...
});
This issue is fixed in the Dockerfile build with two sed
to change the value of the swagger file URL.
Deployment with Docker compose
Deploy with docker:
docker-compose -f docker-compose.yml -f docker-compose.backend.yml up --build
and populate DB (or other scripts) with:
docker exec -it oc-catalog_oc-catalog_1 ./scripts/populate_models.sh ./scripts/demo.json
or out of docker ./scripts/populate_models.sh ./scripts/demo.json
Dev
- Start DB with
docker-compose up -d
- Run the API with
bee run -downdoc=true -gendoc=true
Multinode
Deploy :
docker-compose -f docker-compose.yml -f docker-compose.backend.yml -f docker-compose.multi.yml up --build
Populating the MongoDB database
From the root of the projet run :
./scripts/multinode.sh ./scripts/demo.json
This script should be updated to be ran from anywhere.