Skip to content

Commit 3bea762

Browse files
fix: use ENV defaults instead of shell syntax for env vars
- StrictExpand doesn't support ${VAR:-default} syntax - Set default values via ENV in Dockerfile - Simplify docker.yaml to use plain ${VAR} substitution - Update README to clarify only CROWDSEC_KEY is required
1 parent b0a4e24 commit 3bea762

File tree

3 files changed

+32
-24
lines changed

3 files changed

+32
-24
lines changed

Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@ RUN mkdir -p /run/crowdsec-spoa /var/log/crowdsec-spoa && \
1616
# Final minimal image
1717
FROM scratch
1818

19+
# Default environment variables (can be overridden at runtime)
20+
ENV LOG_MODE=stdout \
21+
LOG_LEVEL=info \
22+
CROWDSEC_URL=http://crowdsec:8080/ \
23+
UPDATE_FREQUENCY=10s \
24+
INSECURE_SKIP_VERIFY=false \
25+
LISTEN_TCP=0.0.0.0:9000 \
26+
PROMETHEUS_ENABLED=true \
27+
PROMETHEUS_ADDR=0.0.0.0 \
28+
PROMETHEUS_PORT=6060
29+
1930
# Copy CA certificates for HTTPS connections to LAPI
2031
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
2132

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,39 @@
11
## Docker-optimized configuration for CrowdSec SPOA Bouncer
2-
## Environment variables can be used for configuration: ${VAR_NAME}
2+
## Environment variables can override settings: ${VAR_NAME}
3+
## If a variable is not set, the default value is used.
34

45
## Log configuration
56
## stdout is recommended for Docker (use `docker logs` to view)
6-
log_mode: ${LOG_MODE:-stdout}
7-
log_level: ${LOG_LEVEL:-info}
7+
log_mode: ${LOG_MODE}
8+
log_level: ${LOG_LEVEL}
89

910
## LAPI configuration
10-
api_url: ${CROWDSEC_URL:-http://crowdsec:8080/}
11+
api_url: ${CROWDSEC_URL}
1112
api_key: ${CROWDSEC_KEY}
12-
update_frequency: ${UPDATE_FREQUENCY:-10s}
13-
insecure_skip_verify: ${INSECURE_SKIP_VERIFY:-false}
13+
update_frequency: ${UPDATE_FREQUENCY}
14+
insecure_skip_verify: ${INSECURE_SKIP_VERIFY}
1415

1516
## SPOA listener configuration
16-
## TCP listener - recommended for Docker networking
17-
listen_tcp: ${LISTEN_TCP:-0.0.0.0:9000}
18-
## Unix socket - uncomment if using shared volume with HAProxy
19-
#listen_unix: ${LISTEN_UNIX:-/run/crowdsec-spoa/spoa.sock}
17+
listen_tcp: ${LISTEN_TCP}
18+
#listen_unix: ${LISTEN_UNIX}
2019

2120
## GeoIP databases (optional, mount as volumes)
22-
#asn_database_path: ${ASN_DB_PATH:-/var/lib/crowdsec/data/GeoLite2-ASN.mmdb}
23-
#city_database_path: ${CITY_DB_PATH:-/var/lib/crowdsec/data/GeoLite2-City.mmdb}
21+
#asn_database_path: /var/lib/crowdsec/data/GeoLite2-ASN.mmdb
22+
#city_database_path: /var/lib/crowdsec/data/GeoLite2-City.mmdb
2423

2524
## Global AppSec configuration (optional)
2625
#appsec_url: ${APPSEC_URL}
27-
#appsec_timeout: ${APPSEC_TIMEOUT:-200ms}
26+
#appsec_timeout: ${APPSEC_TIMEOUT}
2827

2928
## Prometheus metrics endpoint
3029
prometheus:
31-
enabled: ${PROMETHEUS_ENABLED:-true}
32-
listen_addr: ${PROMETHEUS_ADDR:-0.0.0.0}
33-
listen_port: ${PROMETHEUS_PORT:-6060}
30+
enabled: ${PROMETHEUS_ENABLED}
31+
listen_addr: ${PROMETHEUS_ADDR}
32+
listen_port: ${PROMETHEUS_PORT}
3433

3534
## pprof debug endpoint (disabled by default)
3635
## WARNING: Only enable for debugging, exposes internal runtime data
3736
#pprof:
38-
# enabled: ${PPROF_ENABLED:-false}
39-
# listen_addr: ${PPROF_ADDR:-0.0.0.0}
40-
# listen_port: ${PPROF_PORT:-6070}
41-
37+
# enabled: false
38+
# listen_addr: 0.0.0.0
39+
# listen_port: 6070

docker/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,20 @@ The Docker image uses a configuration file optimized for containers with extensi
3232

3333
| Variable | Default | Description |
3434
|----------|---------|-------------|
35-
| `CROWDSEC_KEY` | *(required)* | API key for CrowdSec LAPI |
35+
| `CROWDSEC_KEY` | **required** | API key for CrowdSec LAPI |
3636
| `CROWDSEC_URL` | `http://crowdsec:8080/` | CrowdSec LAPI URL |
3737
| `LOG_MODE` | `stdout` | Log output: `stdout` or `file` |
3838
| `LOG_LEVEL` | `info` | Log level: `trace`, `debug`, `info`, `warn`, `error` |
3939
| `UPDATE_FREQUENCY` | `10s` | How often to poll LAPI for decisions |
4040
| `INSECURE_SKIP_VERIFY` | `false` | Skip TLS verification for LAPI |
4141
| `LISTEN_TCP` | `0.0.0.0:9000` | TCP listener address |
42-
| `LISTEN_UNIX` | *(disabled)* | Unix socket path (uncomment in config) |
4342
| `PROMETHEUS_ENABLED` | `true` | Enable Prometheus metrics |
4443
| `PROMETHEUS_ADDR` | `0.0.0.0` | Prometheus listen address |
4544
| `PROMETHEUS_PORT` | `6060` | Prometheus listen port |
46-
| `APPSEC_URL` | *(disabled)* | AppSec endpoint URL |
47-
| `APPSEC_TIMEOUT` | `200ms` | AppSec request timeout |
4845
| `GOMEMLIMIT` | *(unset)* | Go memory limit (e.g., `200MiB`) |
4946

47+
**Note:** Default values are set in the Docker image. Only `CROWDSEC_KEY` must be provided.
48+
5049
### Custom Configuration
5150

5251
```bash

0 commit comments

Comments
 (0)