Skip to content

Commit

Permalink
update docker
Browse files Browse the repository at this point in the history
  • Loading branch information
fbacker committed Nov 11, 2020
1 parent 4dfb71f commit cabd581
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 6 deletions.
6 changes: 5 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ tmp-*
github
installers
test
*.md
*.md
.Dockerfile
.git
.gitignore
docker-compose.yml
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@ WORKDIR /app
RUN apk --update add git less openssh && \
rm -rf /var/lib/apt/lists/* && \
rm /var/cache/apk/*
COPY package.json package.json
RUN npm install --production
COPY . .
RUN rm config/default.json
RUN mv config/docker.json config/default.json
RUN npm install --production
RUN rm package-lock.json

# create runtime
FROM node:alpine as runtime
WORKDIR /app
VOLUME [ "/config", "/commands" ]
EXPOSE 3000 3001

ENV NODE_CONFIG_DIR=/app/config:/config

COPY --from=build /app .
Expand Down
11 changes: 8 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"express": "^4.17.1",
"flatted": "^3.1.0",
"frontail": "^4.9.1",
"is-docker": "^2.1.1",
"lodash": "^4.17.20",
"md5": "^2.3.0",
"md5-file": "^5.0.0",
Expand Down
10 changes: 9 additions & 1 deletion src/web.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { prepareAction, addToQueue } from './actions/base';
import { fileDelete, fileListStructure, fileSave } from './actions/files';
import { playCommand, queryTemperatureCommand } from './actions/play';

const isDocker = require('is-docker');

let recordAction;
// -------------------------------------
// Webserver
Expand All @@ -23,12 +25,18 @@ let recordAction;

class WebserverClass {
constructor() {
this.host = isDocker() ? '0.0.0.0' : '127.0.0.1';
logger.info(`Listen on ip ${this.host}`);
if (isDocker() && (config.settings.gui.port !== 3000 || config.settings.gui.logs !== 3001)) {
logger.error('Cant change gui or log ports on docker container');
}
const app = express();

app.use(express.static('html'));
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
this.server = http.createServer(app);

this.io = socket.listen(this.server);
this.configureSocket(this.io);
this.configureBroadlink();
Expand Down Expand Up @@ -291,7 +299,7 @@ class WebserverClass {

// server is live
startServer() {
this.server.listen(config.settings.gui.port, () => {
this.server.listen(config.settings.gui.port, this.host, () => {
logger.debug(`GUI Web listen on port ${config.settings.gui.port}`);
// Start to find devices
const isRunning = broadlink.discoverDevices();
Expand Down

0 comments on commit cabd581

Please sign in to comment.