Keep secrets out of repo

This commit is contained in:
2025-11-13 01:44:01 +08:00
parent f8e38599b0
commit 56055187f8
5 changed files with 25 additions and 5 deletions

5
.gitignore vendored
View File

@@ -22,5 +22,8 @@ node_modules/
.env .env
.env.* .env.*
# Ignore generated secrets
dynamic.d/middlewares/crowdsec.yml
# Ignore backup files # Ignore backup files
*.~* *.~*

View File

@@ -28,8 +28,7 @@ Configuration files is customized for Gbanyan personal usage.
## Configuration ## Configuration
- **.env**: Cloudflare E-mail and API Token for SSL DNS Challenge - **.env**: Cloudflare E-mail/API Token plus `CROWDSEC_LAPI_KEY`. Run `scripts/render_dynamic.sh` after editing `.env` so the CrowdSec middleware file is regenerated (it stays ignored by git).
- Also defines `ACME_EMAIL` (Lets Encrypt contact) and `CROWDSEC_LAPI_KEY`
- **Traefik Configuration**: Modify `traefik.yml`, `dynamic.yml` to customize Traefik's behavior. - **Traefik Configuration**: Modify `traefik.yml`, `dynamic.yml` to customize Traefik's behavior.
- **Docker Compose**: Use `docker-compose.yml` to define services and networks. - **Docker Compose**: Use `docker-compose.yml` to define services and networks.

View File

@@ -13,8 +13,6 @@ services:
environment: environment:
- CLOUDFLARE_EMAIL=${CLOUDFLARE_EMAIL} - CLOUDFLARE_EMAIL=${CLOUDFLARE_EMAIL}
- CLOUDFLARE_DNS_API_TOKEN=${CLOUDFLARE_DNS_API_TOKEN} - CLOUDFLARE_DNS_API_TOKEN=${CLOUDFLARE_DNS_API_TOKEN}
- TRAEFIK_CERTIFICATESRESOLVERS_LETSENCRYPT_ACME_EMAIL=${ACME_EMAIL}
- CROWDSEC_LAPI_KEY=${CROWDSEC_LAPI_KEY}
volumes: volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro - /var/run/docker.sock:/var/run/docker.sock:ro
- ./certs:/letsencrypt - ./certs:/letsencrypt

19
scripts/render_dynamic.sh Executable file
View File

@@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT_DIR"
if [[ ! -f .env ]]; then
echo "Missing .env file. Copy .env.example and fill in secrets." >&2
exit 1
fi
set -a
# shellcheck disable=SC1091
source .env
set +a
: "${CROWDSEC_LAPI_KEY:?CROWDSEC_LAPI_KEY must be set in .env}"
if ! command -v envsubst >/dev/null 2>&1; then
echo "envsubst is required to render templates." >&2
exit 1
fi
envsubst < dynamic.d/middlewares/crowdsec.yml.tmpl > dynamic.d/middlewares/crowdsec.yml
echo "Rendered dynamic.d/middlewares/crowdsec.yml"

View File

@@ -112,6 +112,7 @@ providers:
certificatesResolvers: certificatesResolvers:
letsencrypt: letsencrypt:
acme: acme:
email: gbanyan.huang@gmail.com
storage: /letsencrypt/acme.json storage: /letsencrypt/acme.json
dnsChallenge: dnsChallenge:
provider: cloudflare provider: cloudflare