-
Notifications
You must be signed in to change notification settings - Fork 5
Add local MinIO S3 service to Docker Compose and update related scripts #129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -25,7 +25,8 @@ services: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| environment: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| APPEND_PORT: "postgres:5432" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ALLOW_ADDR_REGEX: ".*" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| LOG_TRAFFIC: "true" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| LOG_TRAFFIC: "false" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| LOG_CONN_INFO: "true" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ports: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - "5433:80" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| depends_on: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -59,5 +60,19 @@ services: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ports: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - "8288:8288" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Local MinIO S3 (TCP on 9000) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| minio: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| image: minio/minio:latest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| command: server /data --console-address ":9001" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| environment: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MINIO_ROOT_USER: minioadmin | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MINIO_ROOT_PASSWORD: minioadmin | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ports: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - "9000:9000" # S3 API endpoint | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - "9001:9001" # Web console | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+71
to
+72
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Limit MinIO exposure to loopback. Binding to all interfaces exposes the S3 API and console to your LAN. Prefer loopback in dev. - - "9000:9000" # S3 API endpoint
- - "9001:9001" # Web console
+ - "127.0.0.1:9000:9000" # S3 API endpoint
+ - "127.0.0.1:9001:9001" # Web console📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| volumes: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - minio_data:/data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+63
to
+74
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Add a healthcheck for MinIO. Lets minio:
image: minio/minio:RELEASE.2025-09-07T15-34-20Z
command: server /data --console-address ":9001"
+ healthcheck:
+ test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/ready"]
+ interval: 10s
+ timeout: 5s
+ retries: 5
environment:
MINIO_ROOT_USER: minioadmin
MINIO_ROOT_PASSWORD: minioadmin📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| volumes: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pg_data: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| minio_data: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,6 +5,15 @@ set -euo pipefail | |||||||||||||||||||||||||||
| ROOT_DIR="$(cd -- "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" | ||||||||||||||||||||||||||||
| cd "$ROOT_DIR" | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # Load environment vars from .env.local from repo root | ||||||||||||||||||||||||||||
| ENV_FILE="$ROOT_DIR/.env.local" | ||||||||||||||||||||||||||||
| if [ -f "$ENV_FILE" ]; then | ||||||||||||||||||||||||||||
| echo "💉 Loading $ENV_FILE" | ||||||||||||||||||||||||||||
| set -a | ||||||||||||||||||||||||||||
| . "$ENV_FILE" | ||||||||||||||||||||||||||||
| set +a | ||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||
|
Comment on lines
+10
to
+15
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Silence ShellCheck for dynamic env sourcing. Avoid false positives on if [ -f "$ENV_FILE" ]; then
echo "💉 Loading $ENV_FILE"
set -a
+ # shellcheck disable=SC1090
. "$ENV_FILE"
set +a
fi📝 Committable suggestion
Suggested change
🧰 Tools🪛 Shellcheck (0.11.0)[warning] 13-13: ShellCheck can't follow non-constant source. Use a directive to specify location. (SC1090) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # Allow overriding the compose command (e.g., DOCKER_COMPOSE="docker-compose") | ||||||||||||||||||||||||||||
| DOCKER_COMPOSE="${DOCKER_COMPOSE:-docker compose}" | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
@@ -60,15 +69,79 @@ wait_for_port "127.0.0.1" 6379 "Redis" | |||||||||||||||||||||||||||
| wait_for_port "127.0.0.1" 8079 "SRH (Upstash-compatible HTTP)" | ||||||||||||||||||||||||||||
| # Inngest Dev Server | ||||||||||||||||||||||||||||
| wait_for_port "127.0.0.1" 8288 "Inngest Dev Server" | ||||||||||||||||||||||||||||
| # MinIO S3 API | ||||||||||||||||||||||||||||
| wait_for_port "127.0.0.1" 9000 "MinIO S3 API" | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # --- MinIO bucket setup ------------------------------------------------------ | ||||||||||||||||||||||||||||
| # Defaults for local emulator if not provided in .env.local | ||||||||||||||||||||||||||||
| : "${R2_ACCESS_KEY_ID:=minioadmin}" | ||||||||||||||||||||||||||||
| : "${R2_SECRET_ACCESS_KEY:=minioadmin}" | ||||||||||||||||||||||||||||
| : "${R2_BUCKET:=development}" | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| echo "🪣 Ensuring MinIO bucket exists: ${R2_BUCKET}" | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # Cross-platform networking for the disposable mc container | ||||||||||||||||||||||||||||
| OS="$(uname -s || echo unknown)" | ||||||||||||||||||||||||||||
| if [[ "$OS" == "Linux" ]]; then | ||||||||||||||||||||||||||||
| MC_NET_FLAG="--network=host" | ||||||||||||||||||||||||||||
| MINIO_ENDPOINT="http://localhost:9000" | ||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||
| MC_NET_FLAG="" | ||||||||||||||||||||||||||||
| MINIO_ENDPOINT="http://host.docker.internal:9000" | ||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # Reuse a persistent config volume so the 'local' alias persists across runs | ||||||||||||||||||||||||||||
| docker volume create mc-config >/dev/null | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # 1) define/update the alias | ||||||||||||||||||||||||||||
| if ! docker run --rm $MC_NET_FLAG \ | ||||||||||||||||||||||||||||
| -v mc-config:/root/.mc \ | ||||||||||||||||||||||||||||
| minio/mc alias set local "$MINIO_ENDPOINT" "$R2_ACCESS_KEY_ID" "$R2_SECRET_ACCESS_KEY" >/dev/null; then | ||||||||||||||||||||||||||||
| echo "⚠️ Warning: Could not set MinIO alias (may already exist)" | ||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # 2) create bucket if missing | ||||||||||||||||||||||||||||
| if ! docker run --rm $MC_NET_FLAG -v mc-config:/root/.mc minio/mc ls "local/${R2_BUCKET}" >/dev/null 2>&1; then | ||||||||||||||||||||||||||||
| docker run --rm $MC_NET_FLAG -v mc-config:/root/.mc minio/mc mb -p "local/${R2_BUCKET}" | ||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # 3) 🔓 allow anonymous GET (public-read) so the browser can load images | ||||||||||||||||||||||||||||
| docker run --rm $MC_NET_FLAG -v mc-config:/root/.mc minio/mc anonymous set download "local/${R2_BUCKET}" >/dev/null | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # 4) quick listing | ||||||||||||||||||||||||||||
| docker run --rm $MC_NET_FLAG -v mc-config:/root/.mc minio/mc ls local | sed -n '1,5p' || true | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # --- Done! (hopefully) ------------------------------------------------------ | ||||||||||||||||||||||||||||
| echo | ||||||||||||||||||||||||||||
| echo "🎉 Local infra is ready!" | ||||||||||||||||||||||||||||
| echo " Postgres: postgres://postgres:postgres@localhost:5432/main" | ||||||||||||||||||||||||||||
| echo " wsproxy: ws://localhost:5433/v1 (driver uses this automatically)" | ||||||||||||||||||||||||||||
| echo " Redis: redis://localhost:6379" | ||||||||||||||||||||||||||||
| echo " SRH: http://localhost:8079" | ||||||||||||||||||||||||||||
| echo " Inngest: http://localhost:8288" | ||||||||||||||||||||||||||||
| echo " * Postgres: postgres://postgres:postgres@localhost:5432/main" | ||||||||||||||||||||||||||||
| echo " * wsproxy: ws://localhost:5433/v1 (driver uses this automatically)" | ||||||||||||||||||||||||||||
| echo " * Redis: redis://localhost:6379" | ||||||||||||||||||||||||||||
| echo " * SRH: http://localhost:8079" | ||||||||||||||||||||||||||||
| echo " * Inngest: http://localhost:8288" | ||||||||||||||||||||||||||||
| echo " * MinIO: http://localhost:9000 (console: http://localhost:9001)" | ||||||||||||||||||||||||||||
| echo | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| echo "📜 Following logs (Ctrl+C to stop log tail; services keep running)…" | ||||||||||||||||||||||||||||
| exec $DOCKER_COMPOSE logs -f --tail=100 | ||||||||||||||||||||||||||||
| # graceful shutdown on Ctrl+C / SIGTERM | ||||||||||||||||||||||||||||
| cleanup() { | ||||||||||||||||||||||||||||
| echo | ||||||||||||||||||||||||||||
| echo "🛑 Ctrl+C detected — shutting down Docker stack…" | ||||||||||||||||||||||||||||
| # stop the log tail first (if running) | ||||||||||||||||||||||||||||
| if [[ -n "${LOG_PID:-}" ]]; then | ||||||||||||||||||||||||||||
| kill "$LOG_PID" 2>/dev/null || true | ||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||
| # bring the stack down | ||||||||||||||||||||||||||||
| if $DOCKER_COMPOSE down; then | ||||||||||||||||||||||||||||
| exit 130 # standard code for user-initiated Ctrl+C | ||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||
| exit $? # propagate failure from `down` | ||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| trap cleanup INT TERM | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| echo "📜 Following logs (Ctrl+C to stop AND shut down services)…" | ||||||||||||||||||||||||||||
| $DOCKER_COMPOSE logs -f --tail=100 & | ||||||||||||||||||||||||||||
| LOG_PID=$! | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # wait on the log tail; if it exits (or you press Ctrl+C), the trap runs | ||||||||||||||||||||||||||||
| wait "$LOG_PID" | ||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
Docs align; consider a short safety tip.
Looks great. Optional: note that MinIO ports can be bound to 127.0.0.1 in docker-compose to avoid LAN exposure.
🤖 Prompt for AI Agents