2021-07-22 16:22:40 -06:00
# LiveReload-npm server supporting SSL/TLS
2021-07-22 16:36:36 -06:00
# allow dynamic building by specifying base image elements as build-args
2021-07-22 16:22:40 -06:00
ARG NODE_VERSION = 16
ARG ALPINE_VERSION = 3 .14
FROM node:${NODE_VERSION}-alpine${ALPINE_VERSION}
2021-07-22 16:36:36 -06:00
# 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
2021-07-22 17:15:31 -06:00
# create default volumes in-case user forgets, expose default port
VOLUME [ "/var/watch" , "/var/certs" ]
EXPOSE 35729
2021-07-22 16:36:36 -06:00
# add tini, timezone support and create certificate directories
2021-07-22 16:22:40 -06:00
RUN apk --update --no-cache add \
tini \
2021-07-22 16:36:36 -06:00
tzdata \
2021-07-22 17:16:15 -06:00
openssl \
2021-07-22 16:22:40 -06:00
&& chown node:node /certs \
2021-07-22 17:15:31 -06:00
&& chmod 700 certs \
&& chmod +r /var/watch
2021-07-22 16:22:40 -06:00
2021-07-22 16:36:36 -06:00
# 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
2021-07-22 16:22:40 -06:00
ENV NODE_ENV = production
ENV NPM_CONFIG_PREFIX = /home/node/.npm-global
ENV PATH = /home/node/.npm-global/bin:$PATH
2021-07-22 16:36:36 -06:00
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
2021-07-22 16:22:40 -06:00
2021-07-22 17:21:55 -06:00
# 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
2021-07-22 16:22:40 -06:00
USER node
WORKDIR /home/node
RUN mkdir -p .npm-global/bin .npm-global/lib \
2021-07-22 16:36:36 -06:00
&& npm config set fund false \
2021-07-22 16:22:40 -06:00
&& npm config set update-notifier false \
&& npm install livereload --save
2021-07-22 17:21:55 -06:00
# run entrypoint script by default
2021-07-22 17:15:31 -06:00
ENTRYPOINT [ "/sbin/tini" , "--" , "/usr/local/bin/entrypoint.sh" ]
2021-07-22 16:22:40 -06:00
2021-07-22 16:36:36 -06:00
# set build timestamp and version labels
2021-07-22 17:28:21 -06:00
ARG INTERNAL_VERSION
2021-07-22 16:36:36 -06:00
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"
2021-07-22 17:28:21 -06:00
LABEL dev.asifbacchus.image.version= ${ INTERNAL_VERSION }
2021-07-22 16:36:36 -06:00
LABEL org.opencontainers.image.created= ${ BUILD_DATE }
2021-07-22 16:22:40 -06:00
#EOF