Skip to content

Commit 9f5f75a

Browse files
ElderEvilDmytro Nedavniipre-commit-ci[bot]
authored
2.13.1 (#296)
* fix(storage): separate internal S3 endpoint from public URL Boto3 client connects to internal endpoint (RUSTFS_HOSTNAME:PORT) while public URLs use RUSTFS_PUBLIC_URL. Previously both used the same URL, causing connection failures when public URL was not resolvable internally (e.g. fallout-media.evillab.dev -> s3.evillab.dev). * chore(env): update RustFS defaults to s3.evillab.dev / s3-api.evillab.dev Update both local dev (.env.example) and TrueNAS (.env.truenas.example) templates with the new S3 endpoint configuration. * chore(env): update RustFS defaults to s3.evillab.dev / s3-api.evillab.dev Update both local dev (.env.example) and TrueNAS (.env.truenas.example) templates with the new S3 endpoint configuration. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: Dmytro Nedavnii <d.nedavnii@proton.me> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 2de962e commit 9f5f75a

4 files changed

Lines changed: 80 additions & 10 deletions

File tree

backend/.env.example

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,15 @@ REDIS_PORT=6379
4747
MINIO_PUBLIC_URL=https://media.yourdomain.com
4848

4949
# RustFS is an S3-compatible object storage (uses boto3)
50-
# External endpoint: https://s3.evillab.dev
51-
RUSTFS_HOSTNAME=s3.evillab.dev
50+
# Internal API endpoint (boto3 client connects here)
51+
RUSTFS_HOSTNAME=s3-api.evillab.dev
5252
RUSTFS_PORT=443
53-
RUSTFS_ACCESS_KEY=your-access-key
54-
RUSTFS_SECRET_KEY=your-secret-key
53+
RUSTFS_USE_HTTPS=True
54+
# Shared dev credentials — do NOT use in production
55+
RUSTFS_ACCESS_KEY=admin
56+
RUSTFS_SECRET_KEY=4P^2F2bwB7&kwhN!
5557
RUSTFS_DEFAULT_BUCKET=fallout-shelter
58+
# Public URL for generating file links
5659
RUSTFS_PUBLIC_URL=https://s3.evillab.dev
5760

5861
#============================================

backend/app/services/storage/rustfs_adapter.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ def enabled(self) -> bool:
5151
return self._enabled
5252

5353
def _get_endpoint_url(self) -> str:
54-
public_url = getattr(settings, "RUSTFS_PUBLIC_URL", "")
55-
if public_url:
56-
return public_url.rstrip("/")
54+
"""Internal S3 endpoint for boto3 client connections."""
5755
hostname = getattr(settings, "RUSTFS_HOSTNAME", None) or "s3.evillab.dev"
5856
port = getattr(settings, "RUSTFS_PORT", "")
5957
use_https = getattr(settings, "RUSTFS_USE_HTTPS", False)
@@ -62,6 +60,13 @@ def _get_endpoint_url(self) -> str:
6260
return f"{scheme}://{hostname}:{port}"
6361
return f"{scheme}://{hostname}"
6462

63+
def _get_public_base_url(self) -> str:
64+
"""Public-facing URL for generating file URLs. Falls back to internal endpoint."""
65+
public_url = getattr(settings, "RUSTFS_PUBLIC_URL", "")
66+
if public_url:
67+
return public_url.rstrip("/")
68+
return self._get_endpoint_url()
69+
6570
def _ensure_bucket_exists(self, bucket_name: str) -> None:
6671
if not self.enabled:
6772
return
@@ -204,7 +209,7 @@ def public_url(
204209
return ""
205210

206211
bucket_name = bucket_name or self.default_bucket_name
207-
base_url = self._get_endpoint_url()
212+
base_url = self._get_public_base_url()
208213
return f"{base_url}/{bucket_name}/{file_name}"
209214

210215
def delete_file(

docs/examples/.env.truenas.example

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# ============================================
2+
# IMAGE VERSIONS
3+
# Auto-updated by CI/CD, or pin to specific version
4+
# ============================================
5+
BE_VERSION=latest
6+
FE_VERSION=latest
7+
8+
# ============================================
9+
# URLS
10+
# ============================================
11+
FRONTEND_URL=https://fallout.evillab.dev
12+
API_URL=https://fallout-api.evillab.dev
13+
14+
# ============================================
15+
# SECRETS (CRITICAL - generate new values!)
16+
# ============================================
17+
# Generate with: openssl rand -hex 32
18+
SECRET_KEY=CHANGE-ME-USE-openssl-rand-hex-32
19+
20+
# ============================================
21+
# DATABASE
22+
# ============================================
23+
POSTGRES_USER=postgres
24+
POSTGRES_PASSWORD=postgres
25+
POSTGRES_DB=fallout_db
26+
27+
# ============================================
28+
# INITIAL ADMIN USER
29+
# ============================================
30+
FIRST_SUPERUSER_USERNAME=ElderEvil
31+
FIRST_SUPERUSER_EMAIL=elder.evil.dev@proton.me
32+
FIRST_SUPERUSER_PASSWORD=CHANGE-ME-strong-password
33+
34+
# ============================================
35+
# AI PROVIDER
36+
# ============================================
37+
AI_PROVIDER=openai
38+
AI_MODEL=gpt-4o
39+
OPENAI_API_KEY=sk-your-openai-key-here
40+
41+
# ============================================
42+
# EMAIL (uses Mailpit by default for staging)
43+
# ============================================
44+
SMTP_HOST=mailpit
45+
SMTP_PORT=1025
46+
SMTP_USER=
47+
SMTP_PASSWORD=
48+
SMTP_TLS=false
49+
SMTP_SSL=false
50+
EMAIL_FROM_ADDRESS=noreply@falloutshelter.com
51+
EMAIL_FROM_NAME=Fallout Shelter
52+
53+
# ============================================
54+
# RUSTFS (external S3-compatible storage)
55+
# Internal API endpoint for boto3 client connections
56+
# ============================================
57+
RUSTFS_HOSTNAME=s3-api.evillab.dev
58+
RUSTFS_PORT=443
59+
RUSTFS_USE_HTTPS=True
60+
RUSTFS_ACCESS_KEY=admin
61+
RUSTFS_SECRET_KEY=CHANGE-ME-use-openssl-rand-hex-32
62+
RUSTFS_DEFAULT_BUCKET=fallout-shelter
63+
# Public URL for generating user-facing file links
64+
RUSTFS_PUBLIC_URL=https://s3.evillab.dev

docs/examples/docker-compose.truenas.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,5 +199,3 @@ services:
199199
RUSTFS_DEFAULT_BUCKET: ${RUSTFS_DEFAULT_BUCKET:-fallout-shelter}
200200
RUSTFS_PUBLIC_URL: ${RUSTFS_PUBLIC_URL:-}
201201
RUSTFS_USE_HTTPS: ${RUSTFS_USE_HTTPS:-False}
202-
203-

0 commit comments

Comments
 (0)