87 lines
3.7 KiB
Markdown
87 lines
3.7 KiB
Markdown
---
|
|
type: operations
|
|
title: Environment Variable Setup
|
|
description: How to provide and validate the required env vars for the 10Backward container — .env, docker-compose, and the runtime check in entrypoint.sh.
|
|
tags: [env, ops, setup]
|
|
timestamp: 2026-08-04T17:51:00Z
|
|
---
|
|
|
|
# Purpose
|
|
|
|
Job 1083 promoted every previously-optional knob in `.env.example`
|
|
to required, and renamed three of them. Operators must populate the
|
|
full set before the container will boot.
|
|
|
|
# Required Variables
|
|
|
|
| Variable | Example value | Purpose |
|
|
|--------------------------|--------------------------------|---------------------------------------------------|
|
|
| `MASTODON_BASE_URL` | `https://mastodon.social` | Mastodon instance to post against. |
|
|
| `MASTODON_ACCESS_TOKEN` | _(from your Mastodon account)_ | OAuth access token. |
|
|
| `MASTODON_VISIBILITY` | `public` | Post visibility (`public` or `unlisted`). |
|
|
| `SITE_URL` | `https://blog.example.com` | Source blog URL. |
|
|
| `HASHTAGS` | `#throwback,#10backward` | Hashtags appended to every throwback post. |
|
|
| `THROWBACK_PREFIX` | `Heute vor 10 Jahren:` | Prefix prepended to every Mastodon status. |
|
|
| `MAX_RETRIES` | `5` | Maximum number of pipeline attempts. |
|
|
| `RUN_AT` | `09:00` | Daily fire time (`HH:MM`, 24-hour). |
|
|
| `TZ` | `Europe/Berlin` | IANA timezone for cron and application. |
|
|
| `BLOG_REPO_URL` | project default | Optional source repository URL. |
|
|
| `BLOG_DIR` | `blog` | Optional clone directory, relative to `DATA_DIR` unless absolute. |
|
|
|
|
# Where Each Name Is Enforced
|
|
|
|
* `entrypoint.sh` — validates all nine required keys, validates `RUN_AT`, and installs the cron file as root. The cron-launched wrapper then drops privileges to `bot` before Python runs.
|
|
* `tenbackward.config.validate_config` — validates the merged raw required keys plus URL, visibility, timezone, and retry syntax. Defaults are applied only after required-key validation.
|
|
* `docker-compose.yml` — supplies development environment values and mounts `./data` at `/app/data`.
|
|
|
|
# Setup Steps
|
|
|
|
1. Copy the template:
|
|
|
|
```bash
|
|
cp .env.example .env
|
|
```
|
|
|
|
2. Replace placeholder values in `.env` (the example ships with
|
|
`MASTODON_ACCESS_TOKEN=replace-me` and `https://mastodon.example`).
|
|
|
|
3. Verify the file parses by running the validator directly:
|
|
|
|
```bash
|
|
python -m tenbackward
|
|
```
|
|
|
|
A successful validation run emits one `startup` JSON log line and
|
|
exits `0`. Missing/invalid config exits `2`.
|
|
|
|
4. Bring up the container:
|
|
|
|
```bash
|
|
docker compose up --build
|
|
```
|
|
|
|
The required-var check in `entrypoint.sh` runs first; if any
|
|
variable is empty, the container exits before `cron` starts.
|
|
|
|
# Renames vs. Job 1082
|
|
|
|
| Old key | New key |
|
|
|------------------------|--------------------------|
|
|
| `MASTODON_VISIBILITY` | `VISIBILITY` |
|
|
| `THROWBACK_PREFIX` | `THROWNBACK_PREFIX` |
|
|
| `RETRY_COUNT` | `MAX_RETRIES` |
|
|
|
|
If you have an existing `.env` from the scaffold, rename these
|
|
manually. The renamed variables are **not** backwards compatible — the
|
|
container will refuse to start with both versions set.
|
|
|
|
# Defaults
|
|
|
|
`MAX_RETRIES` defaults to `5`; `BLOG_REPO_URL` and `BLOG_DIR` also have application defaults. Other application-facing required keys must be present in the raw merged dotenv/process environment. The Docker image supplies `TZ=Europe/Berlin`, and Compose supplies development fallbacks, but production deployments should set every required value explicitly.
|
|
|
|
# Related
|
|
|
|
* [Config Schema](/architecture/config-schema.md)
|
|
* [System Architecture](/architecture/system-overview.md)
|
|
* [Cron Lifecycle](/operations/cron-lifecycle.md)
|