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"]
COPY . /app
RUN ["npm", "run", "compile_production" ]
RUN ["npm", "prune","--production"]
RUN npm run compile_production && \
npm prune --production
FROM bitnami/node:12-prod AS production
FROM node:lts-alpine AS production
ENV NODE_ENV="production"
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
USER web
WORKDIR /app
RUN /bin/mkdir -p /home/web/tmp/public
RUN /bin/cp -r ./public /home/web/tmp/public
RUN /usr/bin/touch /home/web/tmp/.updatePublic
RUN /bin/cp -r ./public /home/web/tmp/public && \
/bin/touch /home/web/tmp/.updatePublic
EXPOSE 8000

View File

@ -1,11 +1,9 @@
#!/bin/bash
cd /app
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 /home/web/tmp/.updatePublic
rm -f /home/web/tmp/.updatePublic
fi
node index.js