From 2751ccf846bb18883345dace571c56757354c670 Mon Sep 17 00:00:00 2001 From: Dessa Simpson Date: Sun, 29 Nov 2020 12:37:30 -0700 Subject: [PATCH] Update Dockerfile.prod and .dockerignore --- .dockerignore | 3 +++ Dockerfile.prod | 27 +++++++++++++++++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/.dockerignore b/.dockerignore index d95cec9..fe9214f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,7 @@ Dockerfile +Dockerfile.prod +docker-compose.yml .dockerignore .git .gitignore +node_modules diff --git a/Dockerfile.prod b/Dockerfile.prod index d0f3257..49539fd 100644 --- a/Dockerfile.prod +++ b/Dockerfile.prod @@ -1,9 +1,24 @@ -FROM node:latest +FROM node:14 AS builder -COPY . /home/app -WORKDIR /home/app USER node -ENV PORT 3000 -EXPOSE 3000 -CMD ["ts-node", "./src/app.ts"] +ENV PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/app/node_modules/.bin" + +COPY --chown=node . /app +WORKDIR /app +RUN ["npm", "install"] +RUN ["tsc", "--outDir", "build"] + +FROM node:14-alpine + +EXPOSE 3000 +ENV PORT 3000 +ENV PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/app/node_modules/.bin" NODE_ENV="production" + +USER node +WORKDIR /app +COPY --from=builder /app/build build +COPY --from=builder /app/node_modules node_modules +COPY --from=builder /app/public public +COPY --from=builder /app/views views +CMD ["node", "./build/app.js"]