Skip to content

cwcloudtech/cwcloud-api

Repository files navigation

Cwcloud CE RESTful API

Git mirrors

Getting started with docker

Prepare configurations

cp .env.dist .env
cp cloud_environments_local.yml.dist cloud_environments_local.yml

You can let run the API with thoses files, and you can also update the configurations or environment variables inside those files if needed.

Run the containers

docker compose -f docker-compose-local.yml up --build --force-recreate

Test the database

$ docker exec -it comwork_cloud_db psql -U cloud cloud
psql (13.9 (Debian 13.9-1.pgdg110+1))
Type "help" for help.

cloud=# \d
                      List of relations
 Schema |               Name               |   Type   | Owner 
--------+----------------------------------+----------+-------
 public | access                           | table    | cloud
 public | access_id_seq                    | sequence | cloud
 public | api_keys                         | table    | cloud
 public | api_keys_id_seq                  | sequence | cloud
 public | bucket                           | table    | cloud
 public | bucket_id_seq                    | sequence | cloud
 public | consumption                      | table    | cloud
 public | environment                      | table    | cloud
 public | environment_id_seq               | sequence | cloud
 public | flyway_schema_history            | table    | cloud

Init the FaaS token

docker exec -it comwork_cloud_db psql -U cloud cloud -c "INSERT INTO public.api_keys(name, access_key, secret_key, user_id) VALUES('faas', 'faas_access', 'faas_secret', (select id from public.user where is_admin = True and confirmed = True limit 1))"

Test the API

$ curl localhost:8000/v1/health
{"alive":true, "ip":"172.21.0.1","status":"ok"}
$ curl localhost:8000/v1/manifest
{"sha": "unknown yet", "tag": "unknown yet"}

You can open the swagger GUI in your browser with this URL: http://localhost:5002

Test the front (fullstack dev)

You can also run the front following the README.md of this repository: https://gitlab.comwork.io/comwork/infrastructure/comwork-cloud-ui

And updating this environment variable: REACT_APP_APIURL=http://localhost:5002

Unit tests

Here's how to run the unit test locally:

docker compose -f docker-compose-build.yml up --build --abort-on-container-exit comwork_cloud_tests

Linter

For our project, we're using ruff the fastest python linter. Here's how to run it locally:

docker compose -f docker-compose-build.yml up --build --abort-on-container-exit comwork_cloud_linter

Security Scan

For our project, we're using bandit, a tool designed to find common security issues in Python code. Here's how to run it locally:

docker compose -f docker-compose-build.yml up --build --abort-on-container-exit comwork_cloud_bandit

We're also using trivy in our CICD pipelines which is scanning the CVE inside the installed packages on docker containers.

Documentation

The restful API documentation is available here: https://doc.cloud.comwork.io/docs/tutorials/api/

You can also see the Swagger interface contracts here:

Architectures

Database

database schema

FaaS

faas schema

Observability

Cwcloud-api is providing a /metrics http endpoint that can be scrapped by Prometheus:

prometheus

If you're running locally with docker compose, you can access to Jaegger UI here: http://localhost:9090

And can also send the metrics and some traces through OTLP/Grpc. Here's example of traces with Jaegger:

jaegger

If you're running locally with docker compose, you can access to Jaegger UI here: http://localhost:16686

About

API of cloud.comwork.io

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published