refactor(dockerfile): change order for faster build
- move file copy to near end since scripts change often
This commit is contained in:
parent
ba7d33943e
commit
2c3bcf27d7
@ -12,17 +12,14 @@ RUN deluser --remove-home node \
|
|||||||
&& adduser -G node -S -u ${NODE_UID} node
|
&& adduser -G node -S -u ${NODE_UID} node
|
||||||
|
|
||||||
# create default volumes in-case user forgets, expose default port
|
# create default volumes in-case user forgets, expose default port
|
||||||
VOLUME [ "/var/watch", "/var/certs" ]
|
VOLUME [ "/watch", "/certs" ]
|
||||||
EXPOSE 35729
|
EXPOSE 35729
|
||||||
|
|
||||||
# add tini, timezone support 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
|
||||||
&& chown node:node /var/certs \
|
|
||||||
&& chmod 700 /var/certs \
|
|
||||||
&& chmod +r /var/watch
|
|
||||||
|
|
||||||
# labels
|
# labels
|
||||||
LABEL org.opencontainers.image.authors="Asif Bacchus <asif@asifbacchus.dev>"
|
LABEL org.opencontainers.image.authors="Asif Bacchus <asif@asifbacchus.dev>"
|
||||||
@ -42,12 +39,7 @@ ENV LR_EXTS="html,xml,css,js,jsx,ts,tsx,php,py"
|
|||||||
ENV LR_EXCLUDE=".git/,.svn/,.vscode/,.idea/"
|
ENV LR_EXCLUDE=".git/,.svn/,.vscode/,.idea/"
|
||||||
ENV LR_DELAY=500
|
ENV LR_DELAY=500
|
||||||
|
|
||||||
# copy scripts, cleanup permissions and install livereload npm
|
# install livereload npm as node user then switch back to root user
|
||||||
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
|
USER node
|
||||||
WORKDIR /home/node
|
WORKDIR /home/node
|
||||||
RUN mkdir -p .npm-global/bin .npm-global/lib \
|
RUN mkdir -p .npm-global/bin .npm-global/lib \
|
||||||
@ -55,7 +47,17 @@ RUN mkdir -p .npm-global/bin .npm-global/lib \
|
|||||||
&& npm config set update-notifier false \
|
&& npm config set update-notifier false \
|
||||||
&& npm install livereload --save
|
&& npm install livereload --save
|
||||||
|
|
||||||
# run entrypoint script by default
|
# copy scripts and fix-up all permissions
|
||||||
|
USER root
|
||||||
|
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
|
||||||
|
|
||||||
|
# switch to node user, run entrypoint script by default
|
||||||
|
USER node
|
||||||
|
WORKDIR /home/node
|
||||||
ENTRYPOINT [ "/sbin/tini", "--", "/usr/local/bin/entrypoint.sh" ]
|
ENTRYPOINT [ "/sbin/tini", "--", "/usr/local/bin/entrypoint.sh" ]
|
||||||
|
|
||||||
# set build timestamp and version labels
|
# set build timestamp and version labels
|
||||||
|
Loading…
Reference in New Issue
Block a user