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

Feature/docker #5

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.git
node_modules
typings
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
node_modules/
typings/
*~
*.swp
/node_modules
/typings
.vscode
config.json
/state
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM node:carbon-alpine

RUN apk update && apk upgrade && \
apk add --no-cache drill git

USER node
RUN mkdir /home/node/app
WORKDIR /home/node/app
COPY --chown=node:node . .
RUN mkdir -p logs && ln -s /dev/null ./logs/server.log && \
npm install -q [email protected].* [email protected].* [email protected].* && \
ln -s ./node_modules/state/ ./state && \
npm install -q && \
npm cache clean --force

EXPOSE 16522 17273
CMD [ "sh", "-c", "REMOTE_IP=$(drill server2.vesync.com. @8.8.8.8 | awk '/^server2.vesync.com/{print $NF;exit}') npm run build:live" ]
# The below requires root to be able to update the hosts file, so if you want to use this then you have to
# remove the "USER node" line above
#CMD echo 34.204.178.244 server2.vesync.com >>/etc/hosts && REMOTE_IP=server2.vesync.com npm run build:live
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,28 @@ You'll then need to make sure your server is still able to resolve server2.vesyn
Once that's done and your proxy is running, you may need to power cycle the outlet to encourage it
to find your server.

### Docker

If you want to use this project with Docker, you only need to arrange your local DNS -- see above.
Then run the Docker image from Docker Hub
[tonyapuzzo/vesync-wsproxy](https://hub.docker.com/r/tonyapuzzo/vesync-wsproxy/)
or build it yourself as follows:

```bash
docker build -t tagToUse .
docker run -d --name vprox -p 16522:16522 -p 17273:17273 tagToUse
```

Use `docker logs vprox` to see the logging. The image looks up the real IP for `server2.vesync.com`
at startup using a direct DNS call to Google's nameserver at `8.8.8.8`. If your network uses
DD-WRTs "Forced DNS Redirection" or similar, then the Docker image won't be able to resolve the
correct IP. In that case, you can instead go figure out the real IP and then run the image with an
override command line, something like the following:

```bash
docker run --name vprox -p 16522:16522 -p 17273:17273 tagToUse ash -c 'REMOTE_IP=34.204.178.244 npm run build:live'
```

### General Goals
- enable the outlet to remain "smart" if the server goes offline (the outlet already remembers configured timers, but it would lose the ability to be turned on/off or configured.)
- watch and validate the network traffic between the outlet and some strange server (block unrecognized traffic over the websocket by default. /upgrade is technically recognized, but still blocked.)
Expand Down
202 changes: 0 additions & 202 deletions dist/server.js

This file was deleted.

Loading