Skip to content

Commit e5b0658

Browse files
committed
PEP 458: Add RSTUF services in the Warehouse Infra
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 <kairo@dearaujo.nl>
1 parent d4c5145 commit e5b0658

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ initdb: .state/docker-build-base
101101
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';"
102102
docker compose run --rm web psql -h db -d postgres -U postgres -c "DROP DATABASE IF EXISTS warehouse"
103103
docker compose run --rm web psql -h db -d postgres -U postgres -c "CREATE DATABASE warehouse ENCODING 'UTF8'"
104+
docker compose run --rm web psql -h db -d postgres -U postgres -c "DROP DATABASE IF EXISTS rstuf"
105+
docker compose run --rm web psql -h db -d postgres -U postgres -c "CREATE DATABASE rstuf ENCODING 'UTF8'"
104106
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 -"
105107
docker compose run --rm web psql -h db -d warehouse -U postgres -c "UPDATE users SET name='Ee Durbin' WHERE username='ewdurbin'"
106108
$(MAKE) runmigrations

docker-compose.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ volumes:
88
policies:
99
vault:
1010
caches:
11+
rstuf-metadata:
1112

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

164+
rstuf-api:
165+
image: ghcr.io/repository-service-tuf/repository-service-tuf-api:v0.9.0b1
166+
ports:
167+
- 8001:80
168+
environment:
169+
- RSTUF_BROKER_SERVER=redis://redis/1
170+
- RSTUF_REDIS_SERVER=redis://redis
171+
- RSTUF_REDIS_SERVER_DB_RESULT=1
172+
- RSTUF_REDIS_SERVER_DB_REPO_SETTINGS=2
173+
174+
rstuf-worker:
175+
image: ghcr.io/repository-service-tuf/repository-service-tuf-worker:v0.11.0b1
176+
volumes:
177+
- rstuf-metadata:/var/opt/repository-service-tuf/storage
178+
- ./dev/rstuf/keys/online:/var/opt/repository-service-tuf/keystorage
179+
environment:
180+
- RSTUF_STORAGE_BACKEND=LocalStorage
181+
- RSTUF_LOCAL_STORAGE_BACKEND_PATH=/var/opt/repository-service-tuf/storage
182+
- RSTUF_BROKER_SERVER=redis://redis/1
183+
- RSTUF_REDIS_SERVER=redis://redis
184+
- RSTUF_REDIS_SERVER_DB_RESULT=1
185+
- RSTUF_REDIS_SERVER_DB_REPO_SETTINGS=2
186+
- RSTUF_SQL_SERVER=postgresql://postgres@db:5432/rstuf
187+
healthcheck:
188+
test: "exit 0"
189+
restart: always
190+
tty: true
191+
depends_on:
192+
db:
193+
condition: service_healthy
194+
163195
static:
164196
build:
165197
context: .

0 commit comments

Comments
 (0)