Skip to content

Commit e1a9cf7

Browse files
committed
chore: add basic Docker dev setup for utils usage
1 parent 9d01ce4 commit e1a9cf7

File tree

4 files changed

+84
-8
lines changed

4 files changed

+84
-8
lines changed

README.md

+40-7
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@ Some quick guidelines to keep the codebase maintainable:
6666

6767
And likely more, and of course a bunch of `TODO`s in the code!
6868

69-
### Testing
69+
## Testing
7070

7171
Use the appropriate OpenThread RCP firmware:
7272
- Silicon Labs adapters: https://github.com/Nerivec/silabs-firmware-builder/releases
7373
- Texas Instruments adapters: https://github.com/Koenkk/OpenThread-TexasInstruments-firmware/releases
7474
- Nordic Semiconductor adapters: https://github.com/Nerivec/zigbee-on-host/discussions/18
7575

76-
#### Zigbee2MQTT
76+
### Zigbee2MQTT
7777

7878
Zigbee2MQTT 2.1.3-dev (after [PR #26742](https://github.com/Koenkk/zigbee2mqtt/pull/26742)) and later versions should allow the use of the `zoh` adapter.
7979
Make sure you followed the above steps to get the proper firmware, then configure your `configuration.yaml`, including:
@@ -98,12 +98,13 @@ serial:
9898
> [!TIP]
9999
> The EUI64 (IEEE address) in the firmware of the coordinator is ignored in this mode. A static one is used instead (set by Zigbee2MQTT), allowing you to change coordinators at will on the same network (although you may encounter device-related troubles when radio specs vary wildly).
100100

101-
#### CLI & Utils
101+
### CLI & Utils
102102

103103
Clone the repository.
104104

105105
```bash
106106
git clone https://github.com/Nerivec/zigbee-on-host
107+
cd zigbee-on-host
107108
```
108109

109110
Install dev dependencies and build:
@@ -119,7 +120,7 @@ npm run build
119120
> [!TIP]
120121
> If having issues with building, try removing the `*.tsbuildinfo` incremental compilation files (or run `npm run clean` first).
121122

122-
##### Minimal adapter
123+
#### Minimal adapter
123124

124125
> This is intended for developers to quickly test specific features, like joining. Currently, the CLI is output-only.
125126

@@ -129,9 +130,9 @@ Configure parameters in `dist/dev/conf.json` then start CLI (next start will use
129130
npm run dev:cli
130131
```
131132

132-
##### Utils
133+
#### Utils
133134

134-
###### Create a 'zoh.save' from the content of a Zigbee2MQTT data folder
135+
##### Create a 'zoh.save' from the content of a Zigbee2MQTT data folder
135136

136137
```bash
137138
npm run dev:z2z ./path/to/data/
@@ -140,8 +141,40 @@ npm run dev:z2z ./path/to/data/
140141
> [!TIP]
141142
> This allows you to quickly take over a network created with `zstack` or `ember`. You then just need to change the `configuration.yaml` to `adapter: zoh` and `baudrate: 460800` (and `port` as appropriate).
142143

143-
###### Print and save the content of the 'zoh.save' in the given directory in human-readable format (as JSON, in same directory)
144+
##### Print and save the content of the 'zoh.save' in the given directory in human-readable format (as JSON, in same directory)
144145

145146
```bash
146147
npm run dev:z2r ./path/to/data/
147148
```
149+
150+
##### Using 'Docker.dev' and 'compose.dev.yaml'
151+
152+
###### Pre-requisites
153+
154+
```bash
155+
git clone https://github.com/Nerivec/zigbee-on-host
156+
cd zigbee-on-host
157+
docker compose -f docker/compose.dev.yaml up -d --pull never
158+
docker compose -f docker/compose.dev.yaml exec zigbee-on-host npm ci
159+
docker compose -f docker/compose.dev.yaml exec zigbee-on-host npm run build
160+
```
161+
162+
###### Running util commands
163+
164+
Create 'zoh.save' (details above):
165+
166+
```bash
167+
docker compose -f docker/compose.dev.yaml exec zigbee-on-host npm run dev:z2z ./path/to/data
168+
```
169+
170+
Print readable 'zoh.save' content (details above):
171+
172+
```bash
173+
docker compose -f docker/compose.dev.yaml exec zigbee-on-host npm run dev:z2r ./path/to/data
174+
```
175+
176+
###### Stopping & removing the container
177+
178+
```bash
179+
docker compose -f docker/compose.dev.yaml down
180+
```

docker/Dockerfile.dev

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
ARG TARGETPLATFORM
2+
3+
# Need to use Alpine 3.18.4 which uses Node 18 for arm/v6 and arm/v7, otherwise the build hangs.
4+
# See https://github.com/nodejs/docker-node/issues/2077
5+
FROM alpine:3.18.4 AS linux-arm-alpine
6+
FROM alpine:3.21 AS linux-arm64-alpine
7+
FROM alpine:3.21 AS linux-amd64-alpine
8+
FROM alpine:3.21 AS linux-riscv64-alpine
9+
FROM alpine:3.21 AS linux-386-alpine
10+
11+
FROM linux-${TARGETARCH}-alpine AS base
12+
13+
ENV NODE_ENV=development
14+
WORKDIR /app
15+
16+
RUN apk add --no-cache tzdata eudev nodejs npm git
17+
18+
COPY . ./
19+
20+
ARG DATE
21+
ARG VERSION
22+
LABEL org.opencontainers.image.authors="Nerivec"
23+
LABEL org.opencontainers.image.title="ZigBee on Host - Dev"
24+
LABEL org.opencontainers.image.description="Open Source ZigBee stack designed to run on a host and communicate with a radio co-processor (RCP)"
25+
LABEL org.opencontainers.image.url="https://github.com/Nerivec/zigbee-on-host"
26+
LABEL org.opencontainers.image.documentation="https://github.com/Nerivec/zigbee-on-host"
27+
LABEL org.opencontainers.image.source="https://github.com/Nerivec/zigbee-on-host"
28+
LABEL org.opencontainers.image.licenses="GPL-3.0-or-later"
29+
LABEL org.opencontainers.image.created=${DATE}
30+
LABEL org.opencontainers.image.version=${VERSION}
31+
32+
ENTRYPOINT ["tail", "-f", "/dev/null"]

docker/compose.dev.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
services:
2+
zigbee-on-host:
3+
container_name: zigbee-on-host
4+
image: nerivec/zigbee-on-host:dev
5+
build:
6+
context: ../
7+
dockerfile: docker/Dockerfile.dev
8+
volumes:
9+
- ../:/app
10+
# devices:
11+
# - /dev/serial/by-id/<serial-id>:/dev/ttyACM0

src/dev/conf.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"adapter": {
3-
"path": "COM4",
3+
"path": "/dev/ttyACM0",
44
"baudRate": 460800,
55
"rtscts": true
66
},

0 commit comments

Comments
 (0)