README + Dockerfile fixes, format config.py
This commit is contained in:
10
.env.example
10
.env.example
@@ -9,10 +9,11 @@ TIMEZONE=America/Edmonton
|
|||||||
PUBLIC_UPLOAD_PAGE_ENABLED=true
|
PUBLIC_UPLOAD_PAGE_ENABLED=true
|
||||||
|
|
||||||
# Local dedupe cache (SQLite)
|
# Local dedupe cache (SQLite)
|
||||||
STATE_DB=./data/state.db
|
#STATE_DB=./data/state.db
|
||||||
|
|
||||||
# Base URL for generating absolute invite links (recommended for production)
|
# Base URL for generating absolute invite links
|
||||||
# e.g., PUBLIC_BASE_URL=https://photos.example.com
|
# Recommended for production, also sets CORS headers
|
||||||
|
# e.g., PUBLIC_BASE_URL=https://upload.example.com
|
||||||
#PUBLIC_BASE_URL=
|
#PUBLIC_BASE_URL=
|
||||||
|
|
||||||
LOG_LEVEL=INFO
|
LOG_LEVEL=INFO
|
||||||
@@ -27,5 +28,8 @@ CHUNK_SIZE_MB=50
|
|||||||
# create a bot using @BotFather then copy the API key here
|
# create a bot using @BotFather then copy the API key here
|
||||||
# get your account's ID by messaging https://t.me/userinfobot
|
# get your account's ID by messaging https://t.me/userinfobot
|
||||||
# Leave these blank to disable
|
# Leave these blank to disable
|
||||||
|
# Example:
|
||||||
|
# TELEGRAM_BOT_API_KEY=1234567890:ABCDefghIjKlmnOPQRsT-UVWXyzABCdefGH
|
||||||
|
# TELEGRAM_BOT_OWNER_ID=12345678
|
||||||
TELEGRAM_BOT_API_KEY=
|
TELEGRAM_BOT_API_KEY=
|
||||||
TELEGRAM_BOT_OWNER_ID=
|
TELEGRAM_BOT_OWNER_ID=
|
||||||
|
|||||||
@@ -8,8 +8,7 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
|
|||||||
|
|
||||||
# Install Python deps
|
# Install Python deps
|
||||||
COPY requirements.txt .
|
COPY requirements.txt .
|
||||||
RUN pip install --no-cache-dir -r requirements.txt \
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
&& pip install --no-cache-dir python-multipart
|
|
||||||
|
|
||||||
# Copy app code
|
# Copy app code
|
||||||
COPY . /file_drop
|
COPY . /file_drop
|
||||||
|
|||||||
30
README.md
30
README.md
@@ -61,6 +61,36 @@ $ sudo docker compose up --build -d
|
|||||||
Set up nginx / a reverse proxy and point it to the web app.
|
Set up nginx / a reverse proxy and point it to the web app.
|
||||||
|
|
||||||
|
|
||||||
|
### Config Changes
|
||||||
|
|
||||||
|
If you change the `.env` file config, simply run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ sudo docker compose down
|
||||||
|
$ sudo docker compose up --build -d
|
||||||
|
```
|
||||||
|
|
||||||
|
### Updating
|
||||||
|
|
||||||
|
To update the code:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ sudo docker compose down
|
||||||
|
$ git pull --rebase
|
||||||
|
$ sudo docker compose up --build -d
|
||||||
|
```
|
||||||
|
|
||||||
|
### Telegram Bot
|
||||||
|
|
||||||
|
An optional Telegram bot can send you notifications when uploads complete. This is useful to see if random people are filling your disk up.
|
||||||
|
|
||||||
|
To create a bot, message @BotFather on Telegram. Come up with a name and username. Botfather will then send you an API key you can paste into the `.env` config directly.
|
||||||
|
|
||||||
|
Next you'll need to find your own Telegram user ID. You can message @userinfobot and it will reply with your ID. Be ware of impersonator bots (they have the name "userinfobot" but a different username).
|
||||||
|
|
||||||
|
Then message the bot you just created "/start" so that it's able to interact with you.
|
||||||
|
|
||||||
|
|
||||||
### Chunked Uploads
|
### Chunked Uploads
|
||||||
|
|
||||||
- Chunked uploads are enabled by default. Uses setting `CHUNKED_UPLOADS_ENABLED=true`.
|
- Chunked uploads are enabled by default. Uses setting `CHUNKED_UPLOADS_ENABLED=true`.
|
||||||
|
|||||||
@@ -17,13 +17,13 @@ class Settings:
|
|||||||
"""App settings loaded from environment variables (.env)."""
|
"""App settings loaded from environment variables (.env)."""
|
||||||
admin_password: str
|
admin_password: str
|
||||||
max_concurrent: int
|
max_concurrent: int
|
||||||
public_upload_page_enabled: bool = False
|
public_upload_page_enabled: bool = True
|
||||||
public_base_url: str = ""
|
public_base_url: str = ""
|
||||||
state_db: str = ""
|
state_db: str = ""
|
||||||
session_secret: str = ""
|
session_secret: str = ""
|
||||||
log_level: str = "INFO"
|
log_level: str = "INFO"
|
||||||
chunked_uploads_enabled: bool = False
|
chunked_uploads_enabled: bool = True
|
||||||
chunk_size_mb: int = 95
|
chunk_size_mb: int = 50
|
||||||
timezone: str = "UTC"
|
timezone: str = "UTC"
|
||||||
telegram_bot_api_key: str = ""
|
telegram_bot_api_key: str = ""
|
||||||
telegram_bot_owner_id: str = ""
|
telegram_bot_owner_id: str = ""
|
||||||
@@ -48,7 +48,8 @@ def load_settings() -> Settings:
|
|||||||
load_dotenv()
|
load_dotenv()
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
admin_password = os.getenv("ADMIN_PASSWORD", "admin") # Default for convenience, should be changed
|
|
||||||
|
admin_password = os.getenv("ADMIN_PASSWORD", "test123") # Default for convenience, should be changed
|
||||||
if not admin_password.startswith("pbkdf2_sha256-"):
|
if not admin_password.startswith("pbkdf2_sha256-"):
|
||||||
print("="*60)
|
print("="*60)
|
||||||
print("WARNING: ADMIN_PASSWORD is in plaintext.")
|
print("WARNING: ADMIN_PASSWORD is in plaintext.")
|
||||||
@@ -57,27 +58,34 @@ def load_settings() -> Settings:
|
|||||||
if hashed_pw:
|
if hashed_pw:
|
||||||
print(f"ADMIN_PASSWORD={hashed_pw}")
|
print(f"ADMIN_PASSWORD={hashed_pw}")
|
||||||
print("="*60)
|
print("="*60)
|
||||||
# Safe defaults: disable public uploader and invites unless explicitly enabled
|
|
||||||
def as_bool(v: str, default: bool = False) -> bool:
|
def as_bool(v: str, default: bool = False) -> bool:
|
||||||
if v is None:
|
if v is None:
|
||||||
return default
|
return default
|
||||||
return str(v).strip().lower() in {"1","true","yes","on"}
|
return str(v).strip().lower() in {"1","true","yes","on"}
|
||||||
public_upload = as_bool(os.getenv("PUBLIC_UPLOAD_PAGE_ENABLED", "false"), False)
|
|
||||||
|
public_upload = as_bool(os.getenv("PUBLIC_UPLOAD_PAGE_ENABLED", "false"), True)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
maxc = int(os.getenv("MAX_CONCURRENT", "3"))
|
maxc = int(os.getenv("MAX_CONCURRENT", "3"))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
maxc = 3
|
maxc = 3
|
||||||
state_db = os.getenv("STATE_DB", "/data/state.db")
|
|
||||||
|
state_db = os.getenv("STATE_DB", "./data/state.db")
|
||||||
session_secret = os.getenv("SESSION_SECRET") or secrets.token_hex(32)
|
session_secret = os.getenv("SESSION_SECRET") or secrets.token_hex(32)
|
||||||
log_level = os.getenv("LOG_LEVEL", "INFO").upper()
|
log_level = os.getenv("LOG_LEVEL", "INFO").upper()
|
||||||
chunked_uploads_enabled = as_bool(os.getenv("CHUNKED_UPLOADS_ENABLED", "false"), False)
|
|
||||||
|
chunked_uploads_enabled = as_bool(os.getenv("CHUNKED_UPLOADS_ENABLED", "false"), True)
|
||||||
try:
|
try:
|
||||||
chunk_size_mb = int(os.getenv("CHUNK_SIZE_MB", "95"))
|
chunk_size_mb = int(os.getenv("CHUNK_SIZE_MB", "50"))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
chunk_size_mb = 95
|
chunk_size_mb = 50
|
||||||
|
|
||||||
timezone = os.getenv("TIMEZONE", "UTC")
|
timezone = os.getenv("TIMEZONE", "UTC")
|
||||||
|
|
||||||
telegram_bot_api_key = os.getenv("TELEGRAM_BOT_API_KEY", "")
|
telegram_bot_api_key = os.getenv("TELEGRAM_BOT_API_KEY", "")
|
||||||
telegram_bot_owner_id = os.getenv("TELEGRAM_BOT_OWNER_ID", "")
|
telegram_bot_owner_id = os.getenv("TELEGRAM_BOT_OWNER_ID", "")
|
||||||
|
|
||||||
return Settings(
|
return Settings(
|
||||||
admin_password=admin_password,
|
admin_password=admin_password,
|
||||||
max_concurrent=maxc,
|
max_concurrent=maxc,
|
||||||
|
|||||||
Reference in New Issue
Block a user