mirror of
https://github.com/ViViDboarder/docker-rpi-homebridge.git
synced 2024-12-21 16:47:38 +00:00
Switch back to cross-build (#10)
If you do not wish to cross build on your local, you can comment out the cross-build lines and run. Hacky way of making it easy to run on ARM Just prefix any make command with 'arm'. Eg. `make arm shell'. Don't commit the modified Makefile. Update Readme
This commit is contained in:
parent
aa7d331fac
commit
6b9606f24b
@ -1,7 +1,7 @@
|
||||
FROM hypriot/rpi-node:8
|
||||
MAINTAINER ViViDboarder <vividboarder@gmail.com>
|
||||
|
||||
RUN cross-build-start || true
|
||||
RUN [ "cross-build-start" ]
|
||||
|
||||
ENV LANG en_US.UTF-8
|
||||
ENV LC_ALL en_US.UTF-8
|
||||
@ -34,7 +34,7 @@ RUN [ -s npm-shrinkwrap.json ] || rm npm-shrinkwrap.json
|
||||
|
||||
RUN npm install
|
||||
|
||||
RUN cross-build-end || true
|
||||
RUN [ "cross-build-end" ]
|
||||
|
||||
EXPOSE 5353 51826
|
||||
|
||||
|
16
Makefile
16
Makefile
@ -3,13 +3,16 @@ DOCKER_TAG ?= rpi-homebridge
|
||||
DOCKER_TAG_DEV ?= $(DOCKER_TAG)-dev
|
||||
HOMEBRIDGE_USER ?= root
|
||||
|
||||
.PHONY: default
|
||||
default: build
|
||||
|
||||
# Default target to build the image
|
||||
.PHONY: build
|
||||
build:
|
||||
docker build -t $(DOCKER_TAG_DEV) .
|
||||
|
||||
# Target to build and run and subsequently remove image
|
||||
.PHONY: run
|
||||
run: build
|
||||
docker run --net=host --rm \
|
||||
-p "51826:51826" \
|
||||
@ -18,31 +21,44 @@ run: build
|
||||
$(DOCKER_TAG_DEV)
|
||||
|
||||
# Target to drop into an interractive shell
|
||||
.PHONY: shell
|
||||
shell: build
|
||||
docker run --net=host --rm \
|
||||
-p "51826:51826" \
|
||||
-v "$(shell pwd)/config.json:/$(HOMEBRIDGE_USER)/.homebridge/config.json" \
|
||||
-v "$(shell pwd)/plugins.txt:/$(HOMEBRIDGE_USER)/.homebridge/plugins.txt" \
|
||||
$(shell grep -q '^RUN.*cross-build-start' Dockerfile && echo '-v "/usr/bin/qemu-arm-static:/usr/bin/qemu-arm-static"') \
|
||||
-it $(DOCKER_TAG_DEV) \
|
||||
bash
|
||||
|
||||
# Tags dev image so it can be pushed
|
||||
.PHONY: tag
|
||||
tag: build
|
||||
docker tag $(DOCKER_TAG_DEV) $(DOCKER_REPO)/$(DOCKER_TAG)
|
||||
|
||||
# Pushes tagged image to docker hub
|
||||
.PHONY: push
|
||||
push: tag
|
||||
docker push $(DOCKER_REPO)/$(DOCKER_TAG)
|
||||
|
||||
|
||||
# Clears shrinkwrap so next build will install latest version of everything
|
||||
.PHONY: unshrinkwrap
|
||||
unshrinkwrap:
|
||||
rm ./npm-shrinkwrap.json
|
||||
touch ./npm-shrinkwrap.json
|
||||
|
||||
# Generates a new shrinkwrap from installed node modules
|
||||
.PHONY: shrinkwrap
|
||||
shrinkwrap: build
|
||||
docker run --rm \
|
||||
-v "$(shell pwd)/npm-shrinkwrap.json:/homebridge/npm-shrinkwrap-volume.json" \
|
||||
$(shell grep -q '^RUN.*cross-build-start' Dockerfile && echo '-v "/usr/bin/qemu-arm-static:/usr/bin/qemu-arm-static"') \
|
||||
$(DOCKER_TAG_DEV) \
|
||||
bash -c "npm shrinkwrap && cat npm-shrinkwrap.json > npm-shrinkwrap-volume.json"
|
||||
|
||||
# Converts Dockerfile so that it can compile on ARM
|
||||
.PHONY: arm
|
||||
arm:
|
||||
cat Dockerfile | sed '/^RUN.*cross-build-/s/^/# /' > Dockerfile.arm
|
||||
mv Dockerfile.arm Dockerfile
|
||||
|
33
README.md
33
README.md
@ -29,12 +29,35 @@ docker-compose up
|
||||
If you want a little more control, you can use any of the make targets:
|
||||
|
||||
```
|
||||
make build # builds a new image
|
||||
make run # builds and runs container using same parameters as compose
|
||||
make shell # builds and runs an interractive container
|
||||
make tag # tags image to be pushed to docker hub
|
||||
make push # pushes image to docker hub
|
||||
make build # builds a new image
|
||||
make run # builds and runs container using same parameters as compose
|
||||
make shell # builds and runs an interractive container
|
||||
make tag # tags image to be pushed to docker hub
|
||||
make push # pushes image to docker hub
|
||||
make unshrinkwrap # clears npm-shrinkwrap.json so the next build will use latest
|
||||
make shrinkwrap # generates npm-shrinkwrap.json to pin versions
|
||||
make arm # modifies Dockerfile for building against arm
|
||||
```
|
||||
|
||||
## Multi-arch
|
||||
This project is capable of being compiled on arm or cross-built on an x86 machine. There is some trickiness involved in this, so here's the description broken down by platform. High level, the `cross-build-start` cannot be present when building on arm. When running the built image, a non-arm system needs to have `qemu-arm-static` mounted as a volume. The `Makefile` tries to automate this a bit.
|
||||
|
||||
### arm (Raspberry Pi)
|
||||
The default is to support building on Docker Hub and not a Raspberry Pi. Unfortunately, `cross-build-start` will fail to run on an arm machine.
|
||||
|
||||
To build or shrinkwrap, just add `arm` to your make command. Eg. `make arm build shrinkwrap`. This will modify the `Dockerfile` to comment out the cross-build commands. If contributing changes back upstream, do not commit this change!
|
||||
|
||||
### Linux x86
|
||||
Building can be done by directly running `make build`. If you want to run image, you need to install `qemu qemu-user qemu-user-static`. After that you should be able to run `make shrinkwrap or make shell`.
|
||||
|
||||
### macOS
|
||||
Docker for Mac actually supports running arm binaries. So that's cool! To make things simple, you should follow the arm instructions.
|
||||
|
||||
## Development
|
||||
Follow the instructions above for how to run on your architechture. Also, be sure to not commit commented out `cross-build-*` lines as those are necessary for Docker Hub to build.
|
||||
|
||||
### Bumping version numbers
|
||||
This is most easily done by updating `package.json` and then running `make unshrinkwrap shrinkwrap`. That should force a reinstallation of all node packages and then provide you with an updated `npm-shrinkwrap.json` file to commit.
|
||||
|
||||
## Issues?
|
||||
Feel free to report any issues you're having getting this to run on [Github](https://github.com/ViViDboarder/docker-rpi-homebridge/issues)
|
||||
|
Loading…
Reference in New Issue
Block a user