Skip to content

canonical/products-api

Repository files navigation

Products API

Centralized API for accessing release and support lifecycle information for all Canonical products.

Why

Canonical products have different release cadences and support models. This API provides a single source of truth for release dates and support lifecycles.

Local development

The simplest way to run the API locally is using dotrun:

docker-compose up -d
dotrun

Once the server has started, you can visit http://0.0.0.0:8040/ in your browser.

After you close the server with <ctrl>+c you should run docker-compose down to stop the database.

Prerequisites

Install dependencies

dotrun install

If you need to run migrations locally, use a host-local virtualenv:

python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip setuptools==69.5.1
pip install -r requirements.txt

Run the API

docker-compose up -d
dotrun serve

The API will start at http://0.0.0.0:8040/ with a health endpoint at /v1/health.

On Linux, DATABASE_URL in .env uses localhost.

On macOS and Windows, Docker networking can behave differently. If the API cannot connect to Postgres, create a local override file .env.local and set:

DATABASE_URL=postgresql://postgres:pw@host.docker.internal:5433/products_db

Database migrations (local)

Run migrations from the host virtualenv (not through dotrun exec):

source .venv/bin/activate
set -a && source .env && set +a
export FLASK_APP=webapp.app
docker-compose up -d postgres
flask db upgrade

Useful checks:

flask db current
flask db heads

Note: avoid dotrun exec flask db ... for local migrations, as that runtime may use a different network/path context than the host .env values.

Testing

dotrun test

On Linux, TEST_DATABASE_URL in .env uses localhost.

On macOS and Windows, Docker networking can behave differently. If tests cannot connect to Postgres, create a local override file .env.local and set:

TEST_DATABASE_URL=postgresql://postgres:pw@host.docker.internal:5433/test_products_db

Linting and formatting

dotrun lint-python  # Run linters
dotrun format-python  # Auto-format Python code

Project layout

  • app.py – WSGI entrypoint for production servers
  • webapp/app.py – Flask application using FlaskBase
  • requirements.txt – Python dependencies
  • package.json – Node.js scripts and development tasks

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors