Compare commits

..

No commits in common. "dc732efdb7ecabf21a724ee886fc3884ebc39732" and "c6ccca24f7416ff06ac432e55e05239799b445c0" have entirely different histories.

5 changed files with 22 additions and 74 deletions

View File

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GitToolBoxProjectSettings">
<option name="commitMessageIssueKeyValidationOverride">
<BoolValueOverride>
<option name="enabled" value="true" />
</BoolValueOverride>
</option>
<option name="commitMessageValidationConfigOverride">
<CommitMessageValidationOverride>
<option name="enabled" value="true" />
</CommitMessageValidationOverride>
</option>
</component>
</project>

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MarkdownSettings">
<enabledExtensions>
<entry key="MermaidLanguageExtension" value="false" />
<entry key="PlantUMLLanguageExtension" value="false" />
</enabledExtensions>
</component>
</project>

View File

@ -1,28 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="build/Dockerfile" type="docker-deploy" factoryName="dockerfile" server-name="Docker LOCAL">
<deployment type="dockerfile">
<settings>
<option name="imageTag" value="docker.asifbacchus.dev/ab-livereload/ab-livereload:2.7.1" />
<option name="buildArgs">
<list>
<DockerEnvVarImpl>
<option name="name" value="INTERNAL_VERSION" />
<option name="value" value="3.0.0" />
</DockerEnvVarImpl>
<DockerEnvVarImpl>
<option name="name" value="GIT_COMMIT" />
<option name="value" value="" />
</DockerEnvVarImpl>
<DockerEnvVarImpl>
<option name="name" value="BUILD_DATE" />
<option name="value" value="2022-02-26" />
</DockerEnvVarImpl>
</list>
</option>
<option name="buildOnly" value="true" />
<option name="sourceFilePath" value="build/Dockerfile" />
</settings>
</deployment>
<method v="2" />
</configuration>
</component>

View File

@ -2,40 +2,30 @@
# allow dynamic building by specifying base image elements as build-args # allow dynamic building by specifying base image elements as build-args
ARG NODE_VERSION=16 ARG NODE_VERSION=16
ARG ALPINE_VERSION=3.15 ARG ALPINE_VERSION=3.14
FROM node:${NODE_VERSION}-alpine${ALPINE_VERSION} as builder FROM node:${NODE_VERSION}-alpine${ALPINE_VERSION}
ARG NODE_VERSION
ARG ALPINE_VERSION
# install node dependences
WORKDIR /build
COPY [ "package.json", "package-lock.json", "./" ]
RUN npm ci --production
# final container
FROM alpine:${ALPINE_VERSION} as final
ARG NODE_VERSION ARG NODE_VERSION
ARG ALPINE_VERSION ARG ALPINE_VERSION
# create new node user with set UID and GID from build-args and create volume directories # create new node user with set UID and GID from build-args and create volume directories
ARG NODE_UID=9999 ARG NODE_UID=9999
ARG NODE_GID=9999 ARG NODE_GID=9999
RUN addgroup -g ${NODE_GID} -S node \ RUN deluser --remove-home node \
&& addgroup -g ${NODE_GID} -S node \
&& adduser -G node -S -u ${NODE_UID} node \ && adduser -G node -S -u ${NODE_UID} node \
&& mkdir /watch /certs \ && mkdir /watch /certs \
&& chown root:node /certs \ && chown root:node /certs \
&& chmod 770 /certs && chmod 770 /certs
# create default volumes in case user forgets, expose default port # create default volumes in-case user forgets, expose default port
VOLUME [ "/watch", "/certs" ] VOLUME [ "/watch", "/certs" ]
EXPOSE 35729 EXPOSE 35729
# add tini, timezone support, nodejs and create certificate directories # add tini, timezone support and create certificate directories
RUN apk --update --no-cache add \ RUN apk --update --no-cache add \
tini \ tini \
tzdata \ tzdata \
openssl \ openssl \
nodejs~${NODE_VERSION} \
&& apk --update --no-cache upgrade && apk --update --no-cache upgrade
# labels # labels
@ -52,6 +42,8 @@ LABEL org.opencontainers.image.vendor="Asif Bacchus <asif@asifbacchus.dev>"
# default environment variables # default environment variables
ENV NODE_ENV=production 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 TZ="Etc/UTC"
ENV LR_PORT=35729 ENV LR_PORT=35729
ENV LR_EXTS="html,xml,css,js,jsx,ts,tsx,php,py" ENV LR_EXTS="html,xml,css,js,jsx,ts,tsx,php,py"
@ -61,14 +53,22 @@ ENV LR_DEBUG=true
ENV LR_HTTPS=true ENV LR_HTTPS=true
ENV CERT_HOSTNAME="" ENV CERT_HOSTNAME=""
# set-up application and copy dependencies from builder # install node-livereload and express as node user then switch back to root user
USER node
WORKDIR /home/node WORKDIR /home/node
COPY --chown=node:node [ "package.json", "package-lock.json", "/home/node/" ]
RUN mkdir -p .npm-global/bin .npm-global/lib \
&& npm config set fund false \
&& npm config set update-notifier false \
&& npm install --save
COPY --chown=node:node [ "ab-livereload.js", "/home/node/"]
# copy scripts and fix-up all permissions
USER root
COPY [ "selfsigned.cnf", "/etc/selfsigned.cnf" ] COPY [ "selfsigned.cnf", "/etc/selfsigned.cnf" ]
COPY [ "entrypoint.sh", "/usr/local/bin/entrypoint.sh" ] COPY [ "entrypoint.sh", "/usr/local/bin/entrypoint.sh" ]
COPY --chown=node:node [ "ab-livereload.js", "/home/node/"] RUN chown node:node /home/node/* \
COPY --from=builder [ "/build/node_modules", "/home/node/node_modules" ] && chmod 644 /home/node/package* /home/node/ab-livereload.js \
RUN chown -R node:node /home/node/* \
&& chmod 644 /home/node/ab-livereload.js \
&& chmod 755 /usr/local/bin/entrypoint.sh \ && chmod 755 /usr/local/bin/entrypoint.sh \
&& chmod 644 /etc/selfsigned.cnf && chmod 644 /etc/selfsigned.cnf

View File

@ -1,6 +1,6 @@
{ {
"name": "ab-livereload", "name": "ab-livereload",
"version": "3.0.0", "version": "1.0.0",
"dependencies": { "dependencies": {
"express": "^4.17.1", "express": "^4.17.1",
"livereload": "^0.9.3" "livereload": "^0.9.3"