-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added docker development environment #26669
Open
captainlettuce
wants to merge
2
commits into
Koenkk:dev
Choose a base branch
from
captainlettuce:master
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+76
−0
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
ARG TARGETPLATFORM | ||
|
||
# Need to use Alpine 3.18.4 which uses Node 18 for arm/v6 and arm/v7, otherwise the build hangs. | ||
# See https://github.com/nodejs/docker-node/issues/2077 | ||
FROM alpine:3.18.4 AS linux-arm-alpine | ||
FROM alpine:3.21 AS linux-arm64-alpine | ||
FROM alpine:3.21 AS linux-amd64-alpine | ||
FROM alpine:3.21 AS linux-riscv64-alpine | ||
FROM alpine:3.21 AS linux-386-alpine | ||
|
||
FROM linux-${TARGETARCH}-alpine AS base | ||
|
||
#ENV NODE_ENV=production | ||
WORKDIR /app | ||
RUN apk add --no-cache tzdata eudev tini nodejs | ||
|
||
# Dependencies and build | ||
|
||
COPY package.json pnpm-lock.yaml ./ | ||
# Make and such are needed to compile serialport for riscv64 | ||
RUN apk add make gcc g++ python3 linux-headers npm git && \ | ||
npm install -g [email protected] && \ | ||
pnpm install --include=dev && \ | ||
# serialport has outdated prebuilds that appear to fail on some archs, force build on target platform | ||
rm -rf `find ./node_modules/.pnpm/ -wholename "*/@serialport/bindings-cpp/prebuilds" -type d` && \ | ||
pnpm rebuild @serialport/bindings-cpp | ||
|
||
COPY docker/docker-entrypoint.sh /usr/local/bin/ | ||
RUN chmod +x /usr/local/bin/docker-entrypoint.sh | ||
|
||
COPY . /app | ||
RUN pnpm build | ||
CMD pnpm start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
services: | ||
zigbee2mqtt: | ||
build: | ||
context: ../ | ||
dockerfile: docker/Dockerfile.dev | ||
volumes: | ||
- ../:/app | ||
# devices: | ||
# - /dev/serial/by-id/<YOUR-DEVICE-ID>:/dev/ttyACM0 | ||
ports: | ||
- 127.0.0.1:8080:8080 | ||
mqtt: | ||
image: eclipse-mosquitto:2.0 | ||
container_name: mqtt | ||
command: 'mosquitto -c /mosquitto-no-auth.conf' |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will require rebuilding the container every time you change the container, which is not handy. I think it would be best to run
npm run build:watch
and an auto restart or something.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the container is ran with the accompanying compose-file the repository root is bind-mounted into
/app
so no rebuild necessary afaict.You can still run
npm run build:watch
in another terminal, or withdocker compose -f docker/compose.dev.yml exec zigbee2mqtt npm run build:watch
for running inside the container.A proper live-reload with the
pnpm start
command would probably be preferable but I'm not that comfortable with node.js unfortunatelyThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if we can just re-use https://github.com/Koenkk/zigbee2mqtt/blob/master/docker/Dockerfile, as this separate
Dockerfile
add some extra maintenance. I think this can be done by specifying thetarget
in thedocker-compose.dev.yaml
. Then the user just has to runpnpm start
to start Z2MThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that seems doable, I'll update when i get some time