2021-01-04 00:49:07 -07:00
|
|
|
#
|
|
|
|
# nodejs with livereload
|
|
|
|
#
|
|
|
|
|
|
|
|
# allow dynamic build by specifying base image as build arg
|
|
|
|
ARG NODE_TAG="15-alpine3.12"
|
|
|
|
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
|
|
|
|
|
2021-01-04 01:06:03 -07:00
|
|
|
# add tini, timezone support
|
|
|
|
RUN apk --update --no-cache add tzdata tini
|
2021-01-04 00:49:07 -07:00
|
|
|
|
2021-01-04 03:22:24 -07:00
|
|
|
# labels
|
|
|
|
LABEL maintainer="Asif Bacchus <asif@bacchus.cloud>"
|
2021-01-05 14:11:17 -07:00
|
|
|
LABEL org.label-schema.cmd="docker run -d --name livereload -v /dir/to/watch:/var/watch -p 35729:35729 [-e ...] docker.asifbacchus.app/livereload/livereload:latest"
|
2021-01-04 03:22:24 -07:00
|
|
|
LABEL org.label-schema.description="Dockerized livereload npm running under (limited) node user. Environment variables allow specifying files to watch/exclude and notification delay."
|
|
|
|
LABEL org.label-schema.name="livereload"
|
|
|
|
LABEL org.label-schema.schema-version="1.0"
|
2021-01-05 14:11:17 -07:00
|
|
|
LABEL org.label-schema.url="https://git.asifbacchus.app/ab-docker/livereload"
|
|
|
|
LABEL org.label-schema.usage="https://git.asifbacchus.app/ab-docker/livereload/raw/branch/master/README.md"
|
|
|
|
LABEL org.label-schema.vcs-url="https://git.asifbacchus.app/ab-docker/livereload.git"
|
2021-01-04 03:22:24 -07:00
|
|
|
|
2021-01-04 00:49:07 -07:00
|
|
|
# create default volume in case user forgets to map one
|
|
|
|
VOLUME [ "/var/watch" ]
|
|
|
|
|
|
|
|
# expose port
|
2021-01-04 03:20:37 -07:00
|
|
|
EXPOSE 35729
|
2021-01-04 00:49:07 -07:00
|
|
|
|
|
|
|
# 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
|
2021-01-05 07:36:47 -07:00
|
|
|
ENV EXT="html,xml,css,js,jsx,ts,tsx,php,py"
|
2021-01-04 00:49:07 -07:00
|
|
|
ENV EXCLUDE=".git/,.svn/"
|
|
|
|
ENV DELAY=500
|
|
|
|
|
2021-01-04 01:06:03 -07:00
|
|
|
# install livereload for node user
|
|
|
|
USER node
|
|
|
|
WORKDIR /home/node
|
2021-01-05 08:20:46 -07:00
|
|
|
RUN mkdir -p .npm-global/bin .npm-global/lib \
|
|
|
|
&& npm install -g livereload
|
2021-01-04 00:49:07 -07:00
|
|
|
|
|
|
|
# run node via tini by default
|
|
|
|
ENTRYPOINT [ "/sbin/tini", "--" ]
|
2021-01-05 07:38:21 -07:00
|
|
|
CMD livereload /var/watch --debug --exts $EXT --exclusions $EXCLUDE -u true --wait $DELAY
|
2021-01-04 00:49:07 -07:00
|
|
|
|
|
|
|
# set build timestamp and version labels
|
|
|
|
ARG BUILD_DATE
|
2021-01-05 07:41:54 -07:00
|
|
|
LABEL org.label-schema.version="1.0"
|
2021-01-04 00:49:07 -07:00
|
|
|
LABEL org.label-schema.build-date=${BUILD_DATE}
|
|
|
|
#EOF
|