Skip to content

Commit ec0dfd6

Browse files
committed
Add optional MinIO compose profile for upload testing
\`docker compose --profile s3 up\` brings up a MinIO container plus a one-shot minio/mc sidecar that pre-creates the \`cohorts-binaries\` bucket. Plain \`docker compose up\` is unchanged. The S3 API is only reachable inside the compose network at \`http://s3:9000\`; the admin console is forwarded at http://localhost:59001 (cohorts/cohortscohorts). Verified: - plain up: 2 services (db, app), no MinIO - --profile s3 up: 4 services; bucket auto-created - boto3 upload from the app container lands in the bucket - host :9001 console reachable, host :9000 not forwarded
1 parent 766d1c2 commit ec0dfd6

2 files changed

Lines changed: 54 additions & 0 deletions

File tree

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,28 @@ docker compose exec app uv run flask import_json # one-shot seed from config.js
2828

2929
The API is exposed on http://localhost:5000. Postgres data persists in the `cohorts-pg-data` named volume, run `docker compose down -v` if you want a fresh database.
3030

31+
### Optional: fake S3 for upload testing
32+
33+
The `s3` compose profile brings up a local MinIO container plus a one-shot sidecar that pre-creates a `cohorts-binaries` bucket, so the `fetch_firmware` upload path can be exercised without real S3 credentials:
34+
35+
```
36+
docker compose --profile s3 up -d
37+
```
38+
39+
Admin console at http://localhost:59001 (user `cohorts`, pass `cohortscohorts`). The S3 API itself is only reachable from inside the compose network at `http://s3:9000` — it is not forwarded to the host.
40+
41+
To point `fetch_firmware` at it, export the matching env on the host before bringing the stack up (or `docker compose --profile s3 restart app` to pick up changes), then run the command as usual:
42+
43+
```
44+
export AWS_ACCESS_KEY=cohorts AWS_SECRET_KEY=cohortscohorts
45+
export S3_BUCKET=cohorts-binaries S3_ENDPOINT=http://s3:9000
46+
export MEMFAULT_TOKEN=<your key>
47+
docker compose --profile s3 restart app
48+
docker compose --profile s3 exec app uv run flask fetch_firmware
49+
```
50+
51+
The MinIO bucket contents persist in the `cohorts-s3-data` named volume — `docker compose down -v` clears them along with Postgres.
52+
3153
## Firmware data
3254

3355
Firmware rows live in the `firmwares` table, keyed by `(hardware, kind, version)`. Multiple versions per `(hardware, kind)` are allowed so rollback works by submitting an older version with a newer timestamp — `/cohort?select=fw` always returns the latest row per requested kind by `timestamp` descending.

docker-compose.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,37 @@ services:
3737
condition: service_healthy
3838
command: sh -c "uv run flask db upgrade && uv run python serve_debug.py"
3939

40+
# Optional: `docker compose --profile s3 up` brings up a local S3-compatible
41+
# MinIO plus a one-shot sidecar that creates the `cohorts-binaries` bucket.
42+
# The S3 API is reachable inside the compose network at http://s3:9000 and
43+
# is intentionally not forwarded to the host; the admin console is forwarded
44+
# at http://localhost:59001.
45+
s3:
46+
image: minio/minio:latest
47+
profiles: ["s3"]
48+
command: server /data --console-address ":9001"
49+
environment:
50+
MINIO_ROOT_USER: cohorts
51+
MINIO_ROOT_PASSWORD: cohortscohorts
52+
ports:
53+
- "59001:9001"
54+
volumes:
55+
- cohorts-s3-data:/data
56+
57+
s3-init:
58+
image: minio/mc:latest
59+
profiles: ["s3"]
60+
depends_on:
61+
- s3
62+
entrypoint: >
63+
sh -c "
64+
until mc alias set local http://s3:9000 cohorts cohortscohorts >/dev/null 2>&1; do sleep 1; done;
65+
mc mb --ignore-existing local/cohorts-binaries;
66+
mc anonymous set download local/cohorts-binaries;
67+
echo 'bucket ready: cohorts-binaries';
68+
"
69+
restart: "no"
70+
4071
volumes:
4172
cohorts-pg-data:
73+
cohorts-s3-data:

0 commit comments

Comments
 (0)