Skip to content

Commit

Permalink
PEP 458: Add RSTUF services in the Warehouse Infra
Browse files Browse the repository at this point in the history
This commit adds the RSTUF services to the Warehouse infrastructure
for development and sets the minimum required to start RSTUF services.

It adds the RSTUF API, which is used later to integrate into Warehouse
and RSTUF Worker, which is responsible for computing the TUF metadata.

The RSTUF requires the Postgres and Redis.
Postgres stores the rstuf database used for TUF metadata computing.
Redis stores the task message queue between RSTUF API and Worker, task
backend result, and live settings between RSTUF services.

RSTUF shares the same Postgres and Redis in development environment
but has a specific setup to use its own Postgres database and Redis
database ID.

Postgresql URI
`RSTUF_SQL_SERVER=postgresql://postgres@db:5432/rstuf`

Redis DB Broker and Result is id 1
`RSTUF_BROKER_SERVER=redis://redis/1`
`RSTUF_REDIS_SERVER_DB_RESULT=1`

Redis DB for TUF repository settings is 2
`RSTUF_REDIS_SERVER_DB_REPO_SETTINGS=2`

This commit also includes TUF database creation in the Makefile
during the `make initdb`.

Signed-off-by: Kairo de Araujo <[email protected]>
  • Loading branch information
kairoaraujo committed Jan 25, 2024
1 parent d4c5145 commit e5b0658
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ initdb: .state/docker-build-base
docker compose run --rm web psql -h db -d postgres -U postgres -c "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname ='warehouse';"
docker compose run --rm web psql -h db -d postgres -U postgres -c "DROP DATABASE IF EXISTS warehouse"
docker compose run --rm web psql -h db -d postgres -U postgres -c "CREATE DATABASE warehouse ENCODING 'UTF8'"
docker compose run --rm web psql -h db -d postgres -U postgres -c "DROP DATABASE IF EXISTS rstuf"
docker compose run --rm web psql -h db -d postgres -U postgres -c "CREATE DATABASE rstuf ENCODING 'UTF8'"
docker compose run --rm web bash -c "xz -d -f -k dev/$(DB).sql.xz --stdout | psql -h db -d warehouse -U postgres -v ON_ERROR_STOP=1 -1 -f -"
docker compose run --rm web psql -h db -d warehouse -U postgres -c "UPDATE users SET name='Ee Durbin' WHERE username='ewdurbin'"
$(MAKE) runmigrations
Expand Down
32 changes: 32 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ volumes:
policies:
vault:
caches:
rstuf-metadata:

services:
vault:
Expand Down Expand Up @@ -160,6 +161,37 @@ services:
ARCHIVE_FILES_BACKEND: "warehouse.packaging.services.LocalArchiveFileStorage path=/var/opt/warehouse/packages-archive/ url=http://files:9001/packages-archive/{path}"
SIMPLE_BACKEND: "warehouse.packaging.services.LocalSimpleStorage path=/var/opt/warehouse/simple/ url=http://files:9001/simple/{path}"

rstuf-api:
image: ghcr.io/repository-service-tuf/repository-service-tuf-api:v0.9.0b1
ports:
- 8001:80
environment:
- RSTUF_BROKER_SERVER=redis://redis/1
- RSTUF_REDIS_SERVER=redis://redis
- RSTUF_REDIS_SERVER_DB_RESULT=1
- RSTUF_REDIS_SERVER_DB_REPO_SETTINGS=2

rstuf-worker:
image: ghcr.io/repository-service-tuf/repository-service-tuf-worker:v0.11.0b1
volumes:
- rstuf-metadata:/var/opt/repository-service-tuf/storage
- ./dev/rstuf/keys/online:/var/opt/repository-service-tuf/keystorage
environment:
- RSTUF_STORAGE_BACKEND=LocalStorage
- RSTUF_LOCAL_STORAGE_BACKEND_PATH=/var/opt/repository-service-tuf/storage
- RSTUF_BROKER_SERVER=redis://redis/1
- RSTUF_REDIS_SERVER=redis://redis
- RSTUF_REDIS_SERVER_DB_RESULT=1
- RSTUF_REDIS_SERVER_DB_REPO_SETTINGS=2
- RSTUF_SQL_SERVER=postgresql://postgres@db:5432/rstuf
healthcheck:
test: "exit 0"
restart: always
tty: true
depends_on:
db:
condition: service_healthy

static:
build:
context: .
Expand Down

0 comments on commit e5b0658

Please sign in to comment.