Improving Dockerfile

This commit is contained in:
Absurdon 2020-10-26 19:58:38 +01:00
parent 269a1de5d7
commit bcf48fd01c
2 changed files with 10 additions and 13 deletions

View file

@ -5,23 +5,22 @@ WORKDIR /app
RUN ["npm", "install"] RUN ["npm", "install"]
COPY . /app COPY . /app
RUN ["npm", "run", "compile_production" ] RUN npm run compile_production && \
RUN ["npm", "prune","--production"] npm prune --production
FROM node:lts-alpine AS production
FROM bitnami/node:12-prod AS production
ENV NODE_ENV="production" ENV NODE_ENV="production"
ENV PORT=8000 ENV PORT=8000
RUN ["adduser", "web", "--disabled-password"] RUN adduser web --disabled-password
USER web
RUN /bin/mkdir -p /home/web/tmp/public
COPY --chown=web:web --from=builder /app /app COPY --chown=web:web --from=builder /app /app
USER web
WORKDIR /app WORKDIR /app
RUN /bin/mkdir -p /home/web/tmp/public RUN /bin/cp -r ./public /home/web/tmp/public && \
RUN /bin/cp -r ./public /home/web/tmp/public /bin/touch /home/web/tmp/.updatePublic
RUN /usr/bin/touch /home/web/tmp/.updatePublic
EXPOSE 8000 EXPOSE 8000

View file

@ -1,11 +1,9 @@
#!/bin/bash
cd /app cd /app
if [ -f "/home/web/tmp/.updatePublic" ]; then if [ -f "/home/web/tmp/.updatePublic" ]; then
cp -r /home/web/tmp/public /app/public /bin/cp -rf /home/web/tmp/public /app
rm -rf /home/web/tmp/public rm -rf /home/web/tmp/public
rm /home/web/tmp/.updatePublic rm -f /home/web/tmp/.updatePublic
fi fi
node index.js node index.js