diff --git a/.gitignore b/.gitignore index 4e259ca..2fe4feb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ .idea/ -./node_modules/ -./package-lock.json +./redis_conf/ +./redis_data/ +./node_logs/ +./node_app./ +node_modules/ +./node_app/package-lock.json diff --git a/README.md b/README.md index 4303c72..94cc9d2 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,10 @@ This is a simple application to setup your own smarthome with some ESP8266. The server is based on Nodejs and can be run on a Raspberry Pi. -You can change the public ports `8080` (web UI) and `8081` (websocket). -To run the server simply execute `server.js`. +You can change the public ports `8080` (web UI) and `8081` (websocket) in `docker-compose.yml`. +To run the server simply execute `docker-compose`. ``` -screen -A -m -d -S short_url nodejs server.js +docker-compose -p surl up -d ``` It's recommended to use a reverse proxy like nginx. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..f7fe148 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,31 @@ +version: '3' + +services: + node: + image: node + container_name: esp-smarthome_node + restart: always + ports: + - "8080:8080" + - "8081:8081" + volumes: + - ./node_app/:/home/node/app/ + # - ./node_modules/:/home/node/app/node_modules/ + - ./node_logs/:/var/log/ + working_dir: /home/node/app/ + environment: + - NODE_ENV=production + command: sh -c 'npm i && nodejs server.js' + links: + - redis + redis: + image: redis + container_name: esp-smarthome_redis + expose: + - 6379 + restart: always + volumes: + - ./redis_data/:/var/lib/redis/ + - ./redis_conf/:/usr/local/etc/redis/ + environment: + - REDIS_REPLICATION_MODE=master diff --git a/node_app/package.json b/node_app/package.json new file mode 100644 index 0000000..7858ae6 --- /dev/null +++ b/node_app/package.json @@ -0,0 +1,10 @@ +{ + "name": "esp-smarthome_server", + "version": "1.1.0", + "dependencies": { + "mime": "^2.4.6", + "redis": "^3.0.2", + "ws": "^7.3.1", + "xmlhttprequest": "^1.8.0" + } +} diff --git a/public/index.html b/node_app/public/index.html similarity index 95% rename from public/index.html rename to node_app/public/index.html index 223129d..019479e 100644 --- a/public/index.html +++ b/node_app/public/index.html @@ -1,7 +1,7 @@ - + esp-iot @@ -12,7 +12,7 @@