Skip to content

Commit 6b55982

Browse files
committed
Testing stack
1 parent 1c021b9 commit 6b55982

13 files changed

Lines changed: 468 additions & 0 deletions

File tree

docker-testing/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
SHELL := /bin/bash
2+
3+
COMPOSE := docker compose -f compose.yaml
4+
MEDIA_VIDEO := media/sample-video.mp4
5+
MEDIA_AUDIO := media/sample-audio.wav
6+
7+
.PHONY: setup serve destroy
8+
9+
setup:
10+
chmod +x media/generate.sh
11+
./media/generate.sh
12+
$(COMPOSE) pull
13+
$(COMPOSE) build
14+
15+
serve:
16+
$(COMPOSE) up -d --build
17+
18+
destroy:
19+
$(COMPOSE) down --volumes --remove-orphans --rmi local
20+
rm -f $(MEDIA_VIDEO) $(MEDIA_AUDIO)

docker-testing/compose.yaml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
services:
2+
postgres:
3+
image: postgres:16-alpine
4+
environment:
5+
POSTGRES_DB: tooscut
6+
POSTGRES_USER: tooscut
7+
POSTGRES_PASSWORD: tooscut
8+
ports:
9+
- "5432:5432"
10+
volumes:
11+
- pgdata:/var/lib/postgresql/data
12+
- ./postgres/init.sql:/docker-entrypoint-initdb.d/init.sql:ro
13+
healthcheck:
14+
test: ["CMD-SHELL", "pg_isready -U tooscut -d tooscut"]
15+
interval: 5s
16+
timeout: 5s
17+
retries: 20
18+
start_period: 5s
19+
20+
app:
21+
build:
22+
context: ..
23+
dockerfile: Dockerfile
24+
environment:
25+
DATABASE_URL: postgresql://tooscut:tooscut@postgres:5432/tooscut
26+
DATABASE_RO_URL: postgresql://tooscut:tooscut@postgres:5432/tooscut
27+
NODE_ENV: production
28+
PORT: "3000"
29+
HOST: "::"
30+
depends_on:
31+
postgres:
32+
condition: service_healthy
33+
healthcheck:
34+
test:
35+
[
36+
"CMD",
37+
"node",
38+
"-e",
39+
"fetch('http://127.0.0.1:3000').then((r)=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))",
40+
]
41+
interval: 10s
42+
timeout: 5s
43+
retries: 12
44+
start_period: 20s
45+
46+
alb-proxy:
47+
image: nginx:alpine
48+
depends_on:
49+
app:
50+
condition: service_healthy
51+
ports:
52+
- "8080:80"
53+
volumes:
54+
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
55+
healthcheck:
56+
test: ["CMD-SHELL", "wget -q -O - http://localhost/ >/dev/null 2>&1 || exit 1"]
57+
interval: 10s
58+
timeout: 5s
59+
retries: 10
60+
start_period: 5s
61+
62+
tams-mock:
63+
image: stoplight/prism:5
64+
command: ["mock", "/app/tams.yaml", "--host", "0.0.0.0", "--port", "4010", "--multiprocess", "false"]
65+
ports:
66+
- "4010:4010"
67+
volumes:
68+
- ./tams-mock/tams.yaml:/app/tams.yaml:ro
69+
healthcheck:
70+
test:
71+
[
72+
"CMD",
73+
"node",
74+
"-e",
75+
"fetch('http://127.0.0.1:4010/service').then((r)=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))",
76+
]
77+
interval: 10s
78+
timeout: 5s
79+
retries: 10
80+
start_period: 10s
81+
82+
tams-media:
83+
image: nginx:alpine
84+
ports:
85+
- "4011:80"
86+
volumes:
87+
- ./media:/media:ro
88+
- ./media/nginx.conf:/etc/nginx/conf.d/default.conf:ro
89+
healthcheck:
90+
test: ["CMD-SHELL", "wget -q -O - http://localhost/ >/dev/null 2>&1 || exit 1"]
91+
interval: 10s
92+
timeout: 5s
93+
retries: 10
94+
start_period: 5s
95+
96+
volumes:
97+
pgdata:

docker-testing/media/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Sample Media Files
2+
3+
Sample media files are not committed to git. Generate them locally before running manual QA.
4+
5+
## Generate files
6+
7+
Requirements: ffmpeg installed locally.
8+
9+
Run:
10+
11+
./generate.sh
12+
13+
Generated files:
14+
- sample-video.mp4
15+
- sample-audio.wav

docker-testing/media/generate.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
cd "$(dirname "$0")"
4+
5+
ffmpeg -y -f lavfi -i testsrc2=duration=10:size=1920x1080:rate=25 \
6+
-c:v libx264 -preset ultrafast -pix_fmt yuv420p sample-video.mp4
7+
8+
ffmpeg -y -f lavfi -i sine=frequency=440:duration=10:sample_rate=48000 \
9+
-c:a pcm_s16le sample-audio.wav
10+
11+
echo "Sample media generated."

docker-testing/media/nginx.conf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
server {
2+
listen 80;
3+
server_name _;
4+
root /media;
5+
6+
add_header Access-Control-Allow-Origin "*" always;
7+
add_header Access-Control-Allow-Methods "GET, HEAD, OPTIONS" always;
8+
add_header Access-Control-Allow-Headers "*" always;
9+
10+
if ($request_method = OPTIONS) {
11+
return 204;
12+
}
13+
14+
location / {
15+
autoindex on;
16+
try_files $uri =404;
17+
}
18+
}
938 KB
Binary file not shown.
17.5 MB
Binary file not shown.

docker-testing/nginx/default.conf

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
map $http_upgrade $connection_upgrade {
2+
default upgrade;
3+
'' close;
4+
}
5+
6+
server {
7+
listen 80;
8+
server_name _;
9+
10+
location / {
11+
proxy_pass http://app:3000;
12+
13+
proxy_http_version 1.1;
14+
proxy_set_header Upgrade $http_upgrade;
15+
proxy_set_header Connection $connection_upgrade;
16+
17+
proxy_set_header Host $host;
18+
proxy_set_header X-Real-IP $remote_addr;
19+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
20+
proxy_set_header X-Forwarded-Proto $scheme;
21+
22+
proxy_set_header x-amzn-oidc-identity "test-user-sub-00000001";
23+
proxy_set_header x-amzn-oidc-data "eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.eyJzdWIiOiJ0ZXN0LXVzZXItc3ViLTAwMDAwMDAxIiwibmFtZSI6IlRlc3RpIEVkaXRvaWphIiwiZW1haWwiOiJ0ZXN0aS5lZGl0b2lqYUBkb21haW4udGxkIn0.";
24+
25+
proxy_buffering off;
26+
}
27+
}

docker-testing/postgres/init.sql

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
CREATE TABLE IF NOT EXISTS projects (
2+
id TEXT PRIMARY KEY,
3+
user_id TEXT NOT NULL,
4+
name TEXT NOT NULL DEFAULT 'Untitled Project',
5+
settings JSONB NOT NULL DEFAULT '{}',
6+
content JSONB NOT NULL DEFAULT '{}',
7+
thumbnail TEXT,
8+
archived BOOLEAN NOT NULL DEFAULT FALSE,
9+
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
10+
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
11+
);
12+
13+
CREATE INDEX IF NOT EXISTS idx_projects_user_active
14+
ON projects (user_id, updated_at DESC)
15+
WHERE archived = FALSE;
16+
17+
CREATE INDEX IF NOT EXISTS idx_projects_user_archived
18+
ON projects (user_id, updated_at DESC)
19+
WHERE archived = TRUE;
20+
21+
INSERT INTO projects (id, user_id, name, settings, content) VALUES (
22+
'test-project-001',
23+
'test-user-sub-00000001',
24+
'Sample Project',
25+
'{"resolution":{"width":1920,"height":1080},"frameRate":25}',
26+
'{}'
27+
) ON CONFLICT (id) DO NOTHING;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[
2+
{
3+
"id": "c3d4e5f6-a7b8-4c9d-0e1f-2a3b4c5d6e7f",
4+
"source_id": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
5+
"format": "urn:x-nmos:format:video",
6+
"label": "Camera A - H.264 1080p",
7+
"codec": "h264",
8+
"frame_width": 1920,
9+
"frame_height": 1080
10+
},
11+
{
12+
"id": "d4e5f6a7-b8c9-4d0e-1f2a-3b4c5d6e7f8a",
13+
"source_id": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
14+
"format": "urn:x-nmos:format:video",
15+
"label": "Camera A - ProRes 1080p",
16+
"codec": "prores",
17+
"frame_width": 1920,
18+
"frame_height": 1080
19+
},
20+
{
21+
"id": "e5f6a7b8-c9d0-4e1f-2a3b-4c5d6e7f8a9b",
22+
"source_id": "b2c3d4e5-f6a7-4b8c-9d0e-1f2a3b4c5d6e",
23+
"format": "urn:x-nmos:format:audio",
24+
"label": "Mic 1 - PCM 48kHz",
25+
"codec": "pcm_s16le",
26+
"sample_rate": 48000
27+
}
28+
]

0 commit comments

Comments
 (0)