7 Commits

Author SHA1 Message Date
asif c0a4fc1c6c fix(env): update env file to match new exclusion defaults 2021-07-29 22:53:51 -06:00
asif cad203a7c0 fix(dockerfile): reorganize and add new labels
- add deprecated maintainer tag and label
- fix internal label names
- add git commit label
- reorganize labels
2021-07-28 04:41:28 -06:00
asif 8cafe6e164 fix readme formatting error 2021-07-28 04:24:42 -06:00
asif 99cc14532c docs(readme): update readme to reflect fixed exclusions 2021-07-28 04:20:50 -06:00
asif 13ec1a72e9 style(livereload): format code 2021-07-28 04:12:19 -06:00
asif 1194fc63c6 fix(livereload): fix exclusions bug
- read environment var as array
- convert array elements to regex objects
- update environment variable defaults
2021-07-28 03:51:56 -06:00
asif 574b6e1e07 refactor(dockerfile): update existing packages to latest versions 2021-07-28 03:50:03 -06:00
5 changed files with 47 additions and 23 deletions
+4 -4
View File
@@ -81,12 +81,12 @@ TLS13_ONLY=TRUE
LR_EXTS="html,xml,css,js,jsx,ts,tsx,php,py"
# LR_EXCLUDE:
# Comma-delimited set of /regular-expressions/ defining what to exclude from monitoring in addition to the defaults.
# Upstream node-livereload lists the following as defaults: "/\.git\//,/\.svn\//,/\.hg\//"
# Comma-delimited set of regular-expressions defining what to exclude from monitoring in addition to the defaults.
# Upstream node-livereload already ignores: ".git/,.svn/,.hg/"
# REQUIRED: NO
# DEFAULT: "/\.vscode\//,/\.idea\//,/\.tmp/,/\.swp/"
# DEFAULT: ".vscode/,.idea/,.tmp$,.swp$"
# VALID OPTIONS: Any valid RegEx that matches files or directories
LR_EXCLUDE="/\.vscode\//,/\.idea\//,/\.tmp/,/\.swp/"
LR_EXCLUDE=".vscode/,.idea/,.tmp$,.swp$"
# LR_DELAY:
# Amount of time in milliseconds before detecting a change and sending a trigger for a browser reload. Useful if you need to allow time for background recompilation, etc.
+10
View File
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GitToolBoxProjectSettings">
<option name="commitMessageValidationOverride">
<BoolValueOverride>
<option name="value" value="true" />
</BoolValueOverride>
</option>
</component>
</project>
+3 -1
View File
@@ -53,7 +53,7 @@ All environment variables have sensible defaults and, thus, are *not* required t
| TZ | Set the container's time zone. NO impact on runtime, included for convenience. | Etc/UTC |
| LR_PORT | Port over which Livereload will communicate. All clients presently expect port 35729, so I suggest leaving this alone. | 35729 |
| LR_EXTS | Defines monitored extensions. | html,xml,css,js,jsx,ts,tsx,php,py |
| LR_EXCLUDE | Array of JavaScript regular-expressions (Regex) that define paths or files to ignore. These are *appended* to the node-livereload upstream defaults which ignore everything in the `.git/`, `.svn/` and `.hg/` directories.<br />JavaScript regex format is: `/your-regex/`<br />**N.B.** At present, exclusions do not seem to be working properly. Ive filed an issue upstream and will update the container when its resolved. | /\\.vscode//,/\\.idea//,/\\.tmp/,/\\.swp/ |
| LR_EXCLUDE | Comma-delimited regular-expressions (Regex) that define paths or files to ignore. These are *appended* to the node-livereload upstream defaults which ignore everything in the `.git/`, `.svn/` and `.hg/` directories.<br />**N.B.** You do *not* have to use JavaScript format. The script will automatically convert things to JS-RegEx. You do, however, need to escape any special characters. | .vscode/,.idea/,.tmp$,.swp$/ |
| LR_DELAY | Time (ms) between polling for changed files. | 500 |
| LR_DEBUG | Print informational messages to the console. Allows you to see Livereload working. | true |
| LR_HTTPS | Use HTTPS and WSS. In other words, use a certificate for SSL/TLS operation. | true |
@@ -103,6 +103,8 @@ docker run -d --rm -v /var/www:/watch:ro -e LR_HTTPS=false -p 35729:35729 asifba
- `-p 35729:35729`: map on all interfaces port 35729 on the host --> port 35729 in container
- `listen`: start the Livereload server
> Depending on your environment, you may *not* want to expose your Livereload server on all interfaces! You may want to map your port to something like `127.0.0.1:35729:35729` and then establishing an SSH-tunnel from your client. This is completely dependent on your environment and beyond the scope of this readme, sorry.
### Run in HTTPS mode with supplied certificate
```bash
+15 -8
View File
@@ -4,6 +4,8 @@
ARG NODE_VERSION=16
ARG ALPINE_VERSION=3.14
FROM node:${NODE_VERSION}-alpine${ALPINE_VERSION}
ARG NODE_VERSION
ARG ALPINE_VERSION
# create new node user with set UID and GID from build-args and create volume directories
ARG NODE_UID=9999
@@ -23,15 +25,20 @@ EXPOSE 35729
RUN apk --update --no-cache add \
tini \
tzdata \
openssl
openssl \
&& apk --update --no-cache upgrade
# labels
MAINTAINER Asif Bacchus <asif@asifbacchus.dev>
LABEL maintainer="Asif Bacchus <asif@asifbacchus.dev>"
LABEL dev.asifbacchus.docker.internalName="node-livereload-tls"
LABEL org.opencontainers.image.authors="Asif Bacchus <asif@asifbacchus.dev>"
LABEL org.opencontainers.image.title="node-livereload-tls"
LABEL org.opencontainers.image.description="Dockerized node-livereload supporting TLS and running under limited user account. Environment variables allow specifying files to watch/exclude and notification delay."
LABEL org.opencontainers.image.url="https://git.asifbacchus.dev/ab-docker/livereload"
LABEL org.opencontainers.image.documentation="https://git.asifbacchus.dev/ab-docker/livereload/raw/branch/master/README.md"
LABEL org.opencontainers.image.source="https://git.asifbacchus.dev/ab-docker/livereload.git"
LABEL org.opencontainers.image.title="node-livereload-tls"
LABEL org.opencontainers.image.url="https://git.asifbacchus.dev/ab-docker/livereload"
LABEL org.opencontainers.image.vendor="NODE.js, node-livereload"
# default environment variables
ENV NODE_ENV=production
@@ -40,7 +47,7 @@ ENV PATH=/home/node/.npm-global/bin:$PATH
ENV TZ="Etc/UTC"
ENV LR_PORT=35729
ENV LR_EXTS="html,xml,css,js,jsx,ts,tsx,php,py"
ENV LR_EXCLUDE=".git/,.svn/,.vscode/,.idea/"
ENV LR_EXCLUDE=".vscode/,.idea/,.tmp$,.swp$"
ENV LR_DELAY=500
ENV LR_DEBUG=true
ENV LR_HTTPS=true
@@ -78,11 +85,11 @@ ENTRYPOINT [ "/sbin/tini", "--", "/usr/local/bin/entrypoint.sh" ]
# set build timestamp and version labels
ARG INTERNAL_VERSION
ARG GIT_COMMIT
ARG BUILD_DATE
LABEL org.opencontainers.image.version="16.5.0, 0.9.3"
LABEL org.opencontainers.image.vendor="NODE.js, node-livereload"
LABEL dev.asifbacchus.image.name="node-livereload-tls"
LABEL dev.asifbacchus.image.version=${INTERNAL_VERSION}
LABEL org.opencontainers.image.version="NODE=${NODE_VERSION}, node-livereload=0.9.3"
LABEL dev.asifbacchus.docker.internalVersion=${INTERNAL_VERSION}
LABEL org.opencontainers.image.revision=${GIT_COMMIT}
LABEL org.opencontainers.image.created=${BUILD_DATE}
#EOF
+13 -8
View File
@@ -1,6 +1,5 @@
// implement node-livereload over an HTTPS connection
// implement node-livereload over an HTTP or HTTPS connection
// healthcheck function
function healthcheck() {
const express = require('express');
const http = require('http');
@@ -8,12 +7,12 @@ function healthcheck() {
const app = express();
const router = express.Router();
router.use((req, res, next) =>{
router.use((req, res, next) => {
res.header('Access-Control-Allow-Methods', 'GET');
next();
});
router.get('/health', (req, res) =>{
router.get('/health', (req, res) => {
res.status(200).send('Ok');
});
@@ -23,17 +22,23 @@ function healthcheck() {
hServer.listen(3000);
}
// load livereload module
// load modules
const livereload = require('livereload');
const fs = require('fs');
// process from environment variable as array and convert elements to RegEx objects
const extraExclusions = process.env.LR_EXCLUDE.split(",");
extraExclusions.forEach((exclusion, idx) => {
extraExclusions[idx] = new RegExp(exclusion);
});
// set createServer options
const fs = require('fs');
const options = {
port: process.env.LR_PORT,
exts: process.env.LR_EXTS,
exclusions: process.env.LR_EXCLUDE,
exclusions: extraExclusions,
usePolling: true,
delay: process.env.LR_DELAY,
delay: process.env.LR_DELAY
};
// set debugging output as per LR_DEBUG