Compare commits
9 Commits
v1.2
..
9ee212fcef
| Author | SHA1 | Date | |
|---|---|---|---|
| 9ee212fcef | |||
| 1ca3b48d0d | |||
| d864231db1 | |||
| 7828ff2125 | |||
| 0fbd3303e4 | |||
| e82fad68ac | |||
| cc10ee2241 | |||
| 9e9abe945f | |||
| f21510cdf7 |
+19
-9
@@ -4,9 +4,6 @@
|
|||||||
# https://www.davidlaing.com/2012/09/19/customise-your-gitattributes-to-become-a-git-ninja/
|
# https://www.davidlaing.com/2012/09/19/customise-your-gitattributes-to-become-a-git-ninja/
|
||||||
* text=auto
|
* text=auto
|
||||||
|
|
||||||
# JetBrains: Do not touch line endings, but show diff
|
|
||||||
.idea/** -text
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# The above will handle all files NOT found below
|
# The above will handle all files NOT found below
|
||||||
#
|
#
|
||||||
@@ -23,7 +20,7 @@
|
|||||||
*.PDF diff=astextplain
|
*.PDF diff=astextplain
|
||||||
*.rtf diff=astextplain
|
*.rtf diff=astextplain
|
||||||
*.RTF diff=astextplain
|
*.RTF diff=astextplain
|
||||||
*.md text
|
*.md text diff=markdown
|
||||||
*.tex text diff=tex
|
*.tex text diff=tex
|
||||||
*.adoc text
|
*.adoc text
|
||||||
*.textile text
|
*.textile text
|
||||||
@@ -33,6 +30,7 @@
|
|||||||
*.tsv text
|
*.tsv text
|
||||||
*.txt text
|
*.txt text
|
||||||
*.sql text
|
*.sql text
|
||||||
|
*.ps1 text eol=crlf
|
||||||
|
|
||||||
# Graphics
|
# Graphics
|
||||||
*.png binary
|
*.png binary
|
||||||
@@ -56,7 +54,22 @@
|
|||||||
# These are explicitly windows files and should use crlf
|
# These are explicitly windows files and should use crlf
|
||||||
*.bat text eol=crlf
|
*.bat text eol=crlf
|
||||||
*.cmd text eol=crlf
|
*.cmd text eol=crlf
|
||||||
*.ps1 text eol=crlf
|
|
||||||
|
# web frontend stack -- force LF so SRI hashes are always correct
|
||||||
|
*.html text eol=lf
|
||||||
|
*.htm text eol=lf
|
||||||
|
*.css text eol=lf
|
||||||
|
*.min.css text eol=lf
|
||||||
|
*.js text eol=lf
|
||||||
|
*.min.js text eol=lf
|
||||||
|
|
||||||
|
# Visual Studio projects (Rider also)
|
||||||
|
*.cs diff=csharp
|
||||||
|
*.sln merge=union
|
||||||
|
*.csproj merge=union
|
||||||
|
*.vbproj merge=union
|
||||||
|
*.fsproj merge=union
|
||||||
|
*.dbproj merge=union
|
||||||
|
|
||||||
# Serialisation
|
# Serialisation
|
||||||
*.json text
|
*.json text
|
||||||
@@ -72,9 +85,6 @@
|
|||||||
*.tgz binary
|
*.tgz binary
|
||||||
*.zip binary
|
*.zip binary
|
||||||
|
|
||||||
# Docker build files
|
|
||||||
Dockerfile text eol=lf
|
|
||||||
|
|
||||||
# Text files where line endings should be preserved
|
# Text files where line endings should be preserved
|
||||||
*.patch -text
|
*.patch -text
|
||||||
|
|
||||||
@@ -85,5 +95,5 @@ Dockerfile text eol=lf
|
|||||||
.gitattributes export-ignore
|
.gitattributes export-ignore
|
||||||
.gitignore export-ignore
|
.gitignore export-ignore
|
||||||
.gitkeep export-ignore
|
.gitkeep export-ignore
|
||||||
.vscode export-ignore
|
|
||||||
.idea export-ignore
|
.idea export-ignore
|
||||||
|
.vscode export-ignore
|
||||||
|
|||||||
+71
-9
@@ -1,10 +1,72 @@
|
|||||||
.vscode/*
|
### JetBrains template
|
||||||
!.vscode/settings.json
|
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||||
!.vscode/tasks.json
|
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||||
!.vscode/launch.json
|
|
||||||
!.vscode/extensions.json
|
|
||||||
!.vscode/numbered-bookmarks.json
|
|
||||||
*.code-workspace
|
|
||||||
|
|
||||||
# Local History for Visual Studio Code
|
# User-specific stuff
|
||||||
.history/
|
.idea/**/workspace.xml
|
||||||
|
.idea/**/tasks.xml
|
||||||
|
.idea/**/usage.statistics.xml
|
||||||
|
.idea/**/dictionaries
|
||||||
|
.idea/**/shelf
|
||||||
|
|
||||||
|
# Generated files
|
||||||
|
.idea/**/contentModel.xml
|
||||||
|
|
||||||
|
# Sensitive or high-churn files
|
||||||
|
.idea/**/dataSources/
|
||||||
|
.idea/**/dataSources.ids
|
||||||
|
.idea/**/dataSources.local.xml
|
||||||
|
.idea/**/sqlDataSources.xml
|
||||||
|
.idea/**/dynamic.xml
|
||||||
|
.idea/**/uiDesigner.xml
|
||||||
|
.idea/**/dbnavigator.xml
|
||||||
|
|
||||||
|
# Gradle
|
||||||
|
.idea/**/gradle.xml
|
||||||
|
.idea/**/libraries
|
||||||
|
|
||||||
|
# Gradle and Maven with auto-import
|
||||||
|
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||||
|
# since they will be recreated, and may cause churn. Uncomment if using
|
||||||
|
# auto-import.
|
||||||
|
# .idea/artifacts
|
||||||
|
# .idea/compiler.xml
|
||||||
|
# .idea/jarRepositories.xml
|
||||||
|
# .idea/modules.xml
|
||||||
|
# .idea/*.iml
|
||||||
|
# .idea/modules
|
||||||
|
# *.iml
|
||||||
|
# *.ipr
|
||||||
|
|
||||||
|
# CMake
|
||||||
|
cmake-build-*/
|
||||||
|
|
||||||
|
# Mongo Explorer plugin
|
||||||
|
.idea/**/mongoSettings.xml
|
||||||
|
|
||||||
|
# File-based project format
|
||||||
|
*.iws
|
||||||
|
|
||||||
|
# IntelliJ
|
||||||
|
out/
|
||||||
|
|
||||||
|
# mpeltonen/sbt-idea plugin
|
||||||
|
.idea_modules/
|
||||||
|
|
||||||
|
# JIRA plugin
|
||||||
|
atlassian-ide-plugin.xml
|
||||||
|
|
||||||
|
# Cursive Clojure plugin
|
||||||
|
.idea/replstate.xml
|
||||||
|
|
||||||
|
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||||
|
com_crashlytics_export_strings.xml
|
||||||
|
crashlytics.properties
|
||||||
|
crashlytics-build.properties
|
||||||
|
fabric.properties
|
||||||
|
|
||||||
|
# Editor-based Rest Client
|
||||||
|
.idea/httpRequests
|
||||||
|
|
||||||
|
# Android studio 3.1+ serialized cache file
|
||||||
|
.idea/caches/build_file_checksums.ser
|
||||||
|
|||||||
-58
@@ -1,58 +0,0 @@
|
|||||||
#
|
|
||||||
# nodejs with livereload
|
|
||||||
#
|
|
||||||
|
|
||||||
# allow dynamic build by specifying base image as build arg
|
|
||||||
ARG NODE_TAG="16.4.2-alpine3.14"
|
|
||||||
FROM node:${NODE_TAG}
|
|
||||||
|
|
||||||
# change user id of node user
|
|
||||||
ARG NODE_UID=9999
|
|
||||||
RUN deluser --remove-home node \
|
|
||||||
&& addgroup -g ${NODE_UID} -S node \
|
|
||||||
&& adduser -G node -S -u ${NODE_UID} node
|
|
||||||
|
|
||||||
# add tini, timezone support
|
|
||||||
RUN apk --update --no-cache add tzdata tini
|
|
||||||
|
|
||||||
# labels
|
|
||||||
LABEL org.opencontainers.image.authors="Asif Bacchus <asif@asifbacchus.dev>"
|
|
||||||
LABEL org.opencontainers.image.title="livereload npm"
|
|
||||||
LABEL org.opencontainers.image.description="Dockerized npm livereload 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"
|
|
||||||
|
|
||||||
# create default volume in case user forgets to map one
|
|
||||||
VOLUME [ "/var/watch" ]
|
|
||||||
|
|
||||||
# expose port
|
|
||||||
EXPOSE 35729
|
|
||||||
|
|
||||||
# default environment variables
|
|
||||||
ENV TZ=Etc/UTC
|
|
||||||
ENV NODE_ENV=production
|
|
||||||
ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
|
|
||||||
ENV PATH=$PATH:/home/node/.npm-global/bin
|
|
||||||
ENV EXT="html,xml,css,js,jsx,ts,tsx,php,py"
|
|
||||||
ENV EXCLUDE=".git/,.svn/"
|
|
||||||
ENV DELAY=500
|
|
||||||
|
|
||||||
# install livereload for node user
|
|
||||||
USER node
|
|
||||||
WORKDIR /home/node
|
|
||||||
RUN mkdir -p .npm-global/bin .npm-global/lib \
|
|
||||||
&& npm install -g livereload
|
|
||||||
|
|
||||||
# run node via tini by default
|
|
||||||
ENTRYPOINT [ "/sbin/tini", "--" ]
|
|
||||||
CMD livereload /var/watch --debug --exts $EXT --exclusions $EXCLUDE -u true --wait $DELAY
|
|
||||||
|
|
||||||
# set build timestamp and version labels
|
|
||||||
ARG BUILD_DATE
|
|
||||||
LABEL org.opencontainers.image.version="16.4.2"
|
|
||||||
LABEL org.opencontainers.image.vendor="nodeJS"
|
|
||||||
LABEL dev.asifbacchus.image.name="livereload npm"
|
|
||||||
LABEL dev.asifbacchus.image.version="1.2"
|
|
||||||
LABEL org.opencontainers.image.created=${BUILD_DATE}
|
|
||||||
#EOF
|
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
# LiveReload-npm server supporting SSL/TLS
|
||||||
|
|
||||||
|
# allow dynamic building by specifying base image elements as build-args
|
||||||
|
ARG NODE_VERSION=16
|
||||||
|
ARG ALPINE_VERSION=3.14
|
||||||
|
FROM node:${NODE_VERSION}-alpine${ALPINE_VERSION}
|
||||||
|
|
||||||
|
# create new node user with set id from build-arg
|
||||||
|
ARG NODE_UID=9999
|
||||||
|
RUN deluser --remove-home node \
|
||||||
|
&& addgroup -g ${NODE_UID} -S node \
|
||||||
|
&& adduser -G node -S -u ${NODE_UID} node
|
||||||
|
|
||||||
|
# create default volumes in-case user forgets, expose default port
|
||||||
|
VOLUME [ "/var/watch", "/var/certs" ]
|
||||||
|
EXPOSE 35729
|
||||||
|
|
||||||
|
# add tini, timezone support and create certificate directories
|
||||||
|
RUN apk --update --no-cache add \
|
||||||
|
tini \
|
||||||
|
tzdata \
|
||||||
|
openssl \
|
||||||
|
&& chown node:node /var/certs \
|
||||||
|
&& chmod 700 /var/certs \
|
||||||
|
&& chmod +r /var/watch
|
||||||
|
|
||||||
|
# labels
|
||||||
|
LABEL org.opencontainers.image.authors="Asif Bacchus <asif@asifbacchus.dev>"
|
||||||
|
LABEL org.opencontainers.image.title="livereload npm"
|
||||||
|
LABEL org.opencontainers.image.description="Dockerized npm 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"
|
||||||
|
|
||||||
|
# default environment variables
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
|
||||||
|
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_DELAY=500
|
||||||
|
|
||||||
|
# copy scripts, cleanup permissions and install livereload npm
|
||||||
|
COPY [ "livereload.js", "/home/node/livereload.js" ]
|
||||||
|
COPY [ "entrypoint.sh", "/usr/local/bin/entrypoint.sh" ]
|
||||||
|
RUN chown node:node /home/node/livereload.js \
|
||||||
|
&& chmod 644 /home/node/livereload.js \
|
||||||
|
&& chmod 755 /usr/local/bin/entrypoint.sh
|
||||||
|
USER node
|
||||||
|
WORKDIR /home/node
|
||||||
|
RUN mkdir -p .npm-global/bin .npm-global/lib \
|
||||||
|
&& npm config set fund false \
|
||||||
|
&& npm config set update-notifier false \
|
||||||
|
&& npm install livereload --save
|
||||||
|
|
||||||
|
# run entrypoint script by default
|
||||||
|
ENTRYPOINT [ "/sbin/tini", "--", "/usr/local/bin/entrypoint.sh" ]
|
||||||
|
|
||||||
|
# set build timestamp and version labels
|
||||||
|
ARG INTERNAL_VERSION
|
||||||
|
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="livereload-tls-npm"
|
||||||
|
LABEL dev.asifbacchus.image.version=${INTERNAL_VERSION}
|
||||||
|
LABEL org.opencontainers.image.created=${BUILD_DATE}
|
||||||
|
|
||||||
|
#EOF
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# entrypoint script for livereload-tls-npm container
|
||||||
|
#
|
||||||
|
|
||||||
|
# functions
|
||||||
|
certificateGenerateNew() {
|
||||||
|
printf "\nGenerating new self-signed certificate:\n"
|
||||||
|
printf "Exporting new certificate:\n"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
certificateShow() {
|
||||||
|
printf "\nCurrently loaded certificate:\n"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
certificateExport() {
|
||||||
|
printf "\nExporting currently loaded certificate:\n"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# default variable values
|
||||||
|
doCertExport=0
|
||||||
|
doCertNew=0
|
||||||
|
doCertShow=0
|
||||||
|
doServer=0
|
||||||
|
doShell=0
|
||||||
|
|
||||||
|
# process action parameter
|
||||||
|
case "$1" in
|
||||||
|
listen | server | run | start)
|
||||||
|
doServer=1
|
||||||
|
;;
|
||||||
|
shell) ;;
|
||||||
|
|
||||||
|
new-cert)
|
||||||
|
doCertNew=1
|
||||||
|
;;
|
||||||
|
show-cert)
|
||||||
|
doCertShow=1
|
||||||
|
;;
|
||||||
|
export-cert)
|
||||||
|
doCertExport=1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# invalid or unknown option
|
||||||
|
printf "\nUnknown action requested: %s\n" "$1"
|
||||||
|
printf "Valid actions: [listen | server | run | start] | shell | new-cert | show-cert | export-cert"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# action: run server
|
||||||
|
if [ "$doServer" -eq 1 ]; then
|
||||||
|
exec "node livereload.js"
|
||||||
|
exit "$?"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# action: drop to shell
|
||||||
|
if [ "$doShell" -eq 1 ]; then
|
||||||
|
exec /bin/sh "$@"
|
||||||
|
exit "$?"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# action: generate new self-signed certificate
|
||||||
|
if [ "$doCertNew" -eq 1 ]; then certificateGenerateNew; fi
|
||||||
|
|
||||||
|
# action: show loaded certificate
|
||||||
|
if [ "$doCertShow" -eq 1 ]; then certificateShow; fi
|
||||||
|
|
||||||
|
# action: export loaded certificate
|
||||||
|
if [ "$doCertExport" -eq 1 ]; then certificateExport; fi
|
||||||
|
|
||||||
|
# failsafe exit - terminate with code 99: this code should never be executed!
|
||||||
|
exit 99
|
||||||
|
|
||||||
|
# exit codes:
|
||||||
|
# 0: normal exit, no errors
|
||||||
|
# 1: invalid or invalid parameter passed to script
|
||||||
|
# 50: certificate errors
|
||||||
|
# 51: unable to read certificate/chain
|
||||||
|
# 52: unable to read private key
|
||||||
|
# 55: unable to generate new certificate
|
||||||
|
# 56: unable to export certificate, likely write error
|
||||||
|
# 99: code error
|
||||||
|
|
||||||
|
#EOF
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
// implement node-livereload over an HTTPS connection
|
||||||
|
|
||||||
|
// load livereload module
|
||||||
|
let livereload = require('livereload');
|
||||||
|
|
||||||
|
// set createServer options
|
||||||
|
const https = require('https');
|
||||||
|
const fs = require('fs');
|
||||||
|
const options = {
|
||||||
|
https: {
|
||||||
|
cert: fs.readFileSync('/certs/fullchain.pem'),
|
||||||
|
key: fs.readFileSync('/certs/privkey.pem')
|
||||||
|
},
|
||||||
|
port: process.env.LR_PORT,
|
||||||
|
exts: process.env.LR_EXTS,
|
||||||
|
exclusions: process.env.LR_EXCLUDE,
|
||||||
|
usePolling: true,
|
||||||
|
delay: process.env.LR_DELAY
|
||||||
|
};
|
||||||
|
|
||||||
|
// start server
|
||||||
|
let server = livereload.createServer(options);
|
||||||
|
server.watch('/var/watch')
|
||||||
|
|
||||||
|
//#EOF
|
||||||
Reference in New Issue
Block a user