diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ef38697 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +# Use NodeJS server for the app. +FROM node:14 + +# Copy files as a non-root user. The `node` user is built in the Node image. +WORKDIR /usr/src/app +RUN chown node:node ./ +USER node + +# Defaults to production, docker-compose overrides this to development on build and run. +ARG NODE_ENV=production +ENV NODE_ENV $NODE_ENV + +# Install dependencies first, as they change less often than code. +COPY .npmrc package.json package-lock.json* ./ +RUN npm ci && npm cache clean --force +COPY ./dist ./dist + +# Execute NodeJS (not NPM script) to handle SIGTERM and SIGINT signals. +CMD ["node", "./dist/index.js"] diff --git a/README.md b/README.md index 4fcc855..3602c06 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,19 @@ # knx-monitor +# Build + +Build and run locally: + +```bash +npm ci +npm run monitor # to run the monitoring program +``` + +Docker: + +```bash +docker login -u laur -p 10.0.0.30:15001 +docker build -t laur-knx-monitor:0.0.1 . +docker push 10.0.0.30:15001/laur-knx-monitor:0.0.1 +``` + diff --git a/package.json b/package.json index d7d65bb..55d731e 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,10 @@ "description": "KNX event monitor an logger", "main": "lib/index.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "build": "tsc --build", + "clean": "tsc --build --clean", + "lint": "eslint --fix \"**/*.ts\"", + "monitor": "npx ./dist/index.js" }, "repository": { "type": "git",