Skip to content
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

Docker? Anyone? #26

Open
arthurd2 opened this issue Jan 31, 2021 · 5 comments
Open

Docker? Anyone? #26

arthurd2 opened this issue Jan 31, 2021 · 5 comments

Comments

@arthurd2
Copy link

Hey guys, first of all: THANK YOU!
Amazing job you did there.

Second: did you guys try to pack everything inside a Docker image?
I've try with the node7 image but I had some problems with libusb...
I'm still trying though....

@arthurd2
Copy link
Author

arthurd2 commented Feb 1, 2021

Oops, just did!
It's not an optimal solution, but it works:

FROM node:12.20.1-stretch
ENV MAC=XXXXX
ENTRYPOINT  ./am43ctrl $MAC -l 3000
EXPOSE 3000

WORKDIR /app
RUN npm  install https://github.com/binsentsu/am43-ctrl
WORKDIR /app/node_modules/.bin/

Running commandi would be:
docker run -ti --net=host --privileged -p 3000 -e MAC=YYYY am43

@bjoernwolter
Copy link

Here is my solution with docker
You have to provide the different "ENV" via -e params

FROM node:12-alpine
ENV LANG C.UTF-8
ENV NODE_ENV production`

RUN apk add --no-cache git npm python3 linux-headers eudev-dev make libusb-dev gcc g++ bash
RUN npm install https://github.com/binsentsu/am43-ctrl
RUN apk del make libusb-dev python3 gcc g++ git linux-headers eudev-dev
RUN rm -r /root/.npm

WORKDIR node_modules/.bin/

ENV URL=""
ENV MAC1=""
ENV MQTTUSER=""
ENV MQTTPWD=""
ENTRYPOINT ./am43ctrl ${MAC1} --url ${URL} -u ${MQTTUSER} -p ${MQTTPWD}´´´

@arthurd2
Copy link
Author

arthurd2 commented Mar 8, 2021

Great one, the image shrank from 900MB to 440MB.
I took your example and added a PORT ENV, changed the ENTRYPOINT and merged the RUN commands.
After merging the RUNs the image shrank to 150MB.
=D

FROM node:12-alpine
ENV LANG C.UTF-8
ENV NODE_ENV production`
ENV URL="mqtt://192.168.0.2"
ENV MAC1="XXXXXXXXXX"
ENV MQTTUSER="mqtt"
ENV PORT="3000"
ENV MQTTPWD="mqttpass"

ENTRYPOINT ./am43ctrl ${MAC1} --url ${URL} -l ${PORT} -u ${MQTTUSER} -p ${MQTTPWD}

RUN apk add --no-cache git npm python3 linux-headers eudev-dev make libusb-dev gcc g++ bash ;\
    npm install https://github.com/binsentsu/am43-ctrl ;\
    apk del make libusb-dev python3 gcc g++ git linux-headers eudev-dev ;\
    rm -r /root/.npm

WORKDIR node_modules/.bin/

@JochenKlenk
Copy link

If I set up a docke rwith above command I just get

/node_modules/@abandonware/noble/lib/hci-socket/hci.js:80
this._socket = new BluetoothHciSocket();
^
Error: EAFNOSUPPORT, Address family not supported by protocol
at new Hci (/node_modules/@abandonware/noble/lib/hci-socket/hci.js:80:18)
at new NobleBindings (/node_modules/@abandonware/noble/lib/hci-socket/bindings.js:25:15)
at module.exports (/node_modules/@abandonware/noble/lib/resolve-bindings.js:13:12)
at Object. (/node_modules/@abandonware/noble/index.js:2:51)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18) {

errno: 97,
code: 'EAFNOSUPPORT',
syscall: 'socket'
}

Can Someone help here.

Thanks

@arthurd2
Copy link
Author

I had the same problem.
But I don't remember if I fixed it by enabling the bluetooth (it was down, in airplane mode) or I've installed the bluez package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants