Skip to content

Commit

Permalink
chore(docker): added Dockerfile.contrib for testing purposes (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
larstobi authored Dec 1, 2020
1 parent e1a4642 commit c762a85
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
38 changes: 38 additions & 0 deletions docker/Dockerfile.contrib
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
FROM node:erbium-stretch AS build
USER root
RUN apt-get update && apt-get install -y jq
RUN mkdir -p /usr/local/lib/node_modules && chown node /usr/local/lib/node_modules
RUN yarn global add yalc

COPY --chown=node node-zwave-js /home/node/node-zwave-js
COPY --chown=node zwavejs2mqtt /home/node/zwavejs2mqtt

USER node
WORKDIR /home/node/node-zwave-js
RUN rm -f package-lock.json
RUN yarn install
RUN yarn run build
RUN yarn install --production --frozen-lockfile
RUN for i in $(ls packages|grep -v testing); do yalc publish packages/$i ; done

WORKDIR /home/node/zwavejs2mqtt
RUN rm -f package-lock.json
RUN yalc add zwave-js && \
yalc add @zwave-js/config && \
yalc add @zwave-js/core && \
yalc add @zwave-js/shared && \
yalc add @zwave-js/serial
RUN yarn install
RUN yarn run build
RUN yarn install --production --frozen-lockfile

RUN mkdir my_dist
RUN cp -Lr app.js package.json bin config dist hass lib public store views node_modules my_dist/

FROM node:erbium-stretch-slim
LABEL maintainer="robertsLando"
COPY --from=build /home/node/zwavejs2mqtt/my_dist /usr/src/app
WORKDIR /usr/src/app
EXPOSE 8091
USER root
CMD ["node", "bin/www"]
23 changes: 23 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,26 @@ docker run --rm -p 8091:8091 --device=/dev/ttyACM0 -it --mount source=zwavejs2mq
```bash
docker run --rm -p 8091:8091 --device=/dev/ttyACM0 -it --mount source=zwavejs2mqtt,target=/dist/pkg zwavejs/zwavejs2mqtt_build sh
```

## Building a container using Dockerfile.contrib

This is typically used to build zwavejs2mqtt from git with a version of zwave-js also from git, for instance the latest master or a branch.

### Prerequisites

In order to build it you first need the source code from github.

```bash
mkdir -p testing && cd testing
git clone https://github.com/zwave-js/node-zwave-js
git clone https://github.com/zwave-js/zwavejs2mqtt
## Checkout repos to any branch/commit you need to test
```

### Build

The run the build from outside the two repo folders.

```bash
docker build -f zwavejs2mqtt/docker/Dockerfile.contrib -t zwavejs2mqtt .
```

0 comments on commit c762a85

Please sign in to comment.