Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
106 lines (104 loc) · 4.54 KB
/
Copy pathdocker-compose.yml
File metadata and controls
106 lines (104 loc) · 4.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# OCPP CP simulator daemon in Docker.
#
# Quick start:
# docker compose up --build
#
# Override via environment variables — see the README under "Docker" for
# the full flag list. Anything not covered here can be appended to the
# `command:` block (those args are passed straight to ocpp-cp-sim).
services:
ocpp-cp-sim:
build:
context: .
dockerfile: Dockerfile
args:
# HEALTH_PATH is baked into the UI bundle at build time and
# re-applied at runtime as the daemon's --health-path. Override
# both here (build) and in `environment` below when deploying
# behind a proxy that reserves the default path — e.g. Google
# Front End in front of Cloud Run.
HEALTH_PATH: "${HEALTH_PATH:-/v1/healthz}"
# Optional: the commit being built, so the UI and daemon report
# `<sha7>-dev` instead of `local-dev`, e.g.
# `APP_COMMIT=$(git rev-parse HEAD) docker compose build`.
APP_COMMIT: "${APP_COMMIT:-}"
# No BUN_VERSION here on purpose: compose cannot read .tool-versions,
# and an empty value would override the Dockerfile default, which
# is pinned to it (and guarded by a test).
# @open-ocpp-trace/* comes from GitHub Packages, which asks for a token
# even for a public package: export GITHUB_TOKEN (any token with
# `read:packages`, e.g.
# `GITHUB_TOKEN=${GITHUB_TOKEN:-$(gh auth token)}`) before building.
secrets:
- github_token
image: ocpp-cp-sim
container_name: ocpp-cp-sim
restart: unless-stopped
ports:
- "${HTTP_PORT:-9700}:9700"
environment:
HTTP_PORT: "9700"
# The image's ENTRYPOINT passes --state-db $STATE_DB to ocpp-cp-sim.
# Default is a file under the /data volume; set to ":memory:" to
# run fully ephemeral (state wiped on container exit).
STATE_DB: "/data/state.db"
# The image's ENTRYPOINT passes --health-path $HEALTH_PATH to
# ocpp-cp-sim. Must match the build-time arg above so the static UI
# bundle's auto-detect probe lines up with the daemon endpoint.
HEALTH_PATH: "${HEALTH_PATH:-/v1/healthz}"
volumes:
# Mount the example scenarios read-only so you can point
# --scenario-template-file at one from the command override.
- ./docs/examples/scenarios:/scenarios:ro
# Persistent SQLite state. Use a host bind mount for easy inspection
# (`sqlite3 ./.state/state.db ".tables"`) or swap for a named volume
# like `ocpp-state:/data` for cross-machine portability. Comment out
# both this AND `STATE_DB` above (set to `:memory:`) for ephemeral.
- ./.state:/data
# Args appended to the image's ENTRYPOINT. Tweak to your CSMS / cpId.
# The Dockerfile already sets --http-host 0.0.0.0 --unsafe-remote,
# --http-port (from $HTTP_PORT) and --state-db (from $STATE_DB).
command:
- --cp-id
- "${CP_ID:-cp1}"
- --connectors
- "${CONNECTORS:-1}"
- --ws-url
- "${WS_URL:-wss://example.invalid/chargepoint/}"
# Labels (#472): repeat to group the bootstrapped charge points for
# `cp.list { labels }`. A charge point already in the state DB keeps
# the labels stored there.
# - --label
# - "site=lab"
# CORS: the image binds 0.0.0.0, so with no flag the daemon applies
# the safe `same-origin` policy (not open CORS). When the web console
# is reached from a different origin — a separate UI host, or this
# container behind a reverse proxy at a public URL — name that origin:
# - --cors-origin
# - "${CORS_ORIGIN}"
# ...or, behind a trusted reverse proxy that sets X-Forwarded-*,
# let the daemon derive the public origin instead (see docs/concepts/access-control.md):
# - --trust-forwarded-headers
# Pass `--cors-origin "*"` to deliberately opt into open CORS.
# Scenario template (optional) — uncomment + adjust:
# - --scenario-template-file
# - /scenarios/demo-charging.json
# - --scenario-connector
# - "all"
# Switch to structured JSON logs (uncomment to enable):
# - --log-format
# - json
healthcheck:
# CMD-SHELL so the $$HEALTH_PATH (escaped from compose-time) expands
# at container runtime against the image's env, matching whatever
# the daemon was told to serve.
test:
- CMD-SHELL
- 'wget -qO- "http://127.0.0.1:9700$$HEALTH_PATH" >/dev/null 2>&1 || exit 1'
interval: 30s
timeout: 3s
start_period: 5s
retries: 3
secrets:
github_token:
environment: GITHUB_TOKEN