Update Dockerfile

This commit is contained in:
Matt Low 2021-02-25 00:38:11 -07:00
parent 24d8ab6763
commit 18e468b17f

View File

@ -1,7 +1,6 @@
# dev stage # dev stage
FROM node:14-alpine as dev FROM node:14-alpine as dev
WORKDIR /app WORKDIR /app
RUN apk update && apk add --no-cache python3 make gcc g++
COPY package*.json ./ COPY package*.json ./
RUN npm ci RUN npm ci
COPY . . COPY . .
@ -14,21 +13,13 @@ RUN npx tsc && npm prune --production
FROM node:14-alpine FROM node:14-alpine
WORKDIR /app WORKDIR /app
RUN printf "%b" '#!'"/bin/sh\n\ RUN apk add --update --no-cache util-linux
set -e\n\
if [ ! -z \"\$RUN_MIGRATIONS\" ]; then\n\
echo \"Running migrations.\"\n\
npm run knex:migrate:latest\n\
fi\n\
exec \"\$@\"\n" > docker-entrypoint.sh && chmod +x docker-entrypoint.sh
# Copy over production modules and dist folder # Copy over production modules and dist folder
COPY --from=build /app/package*.json ./ COPY --from=build /app/package*.json ./
COPY --from=build /app/node_modules ./node_modules COPY --from=build /app/node_modules ./node_modules
COPY --from=build /app/dist ./dist COPY --from=build /app/dist ./dist
COPY --from=build /app/db ./db
EXPOSE 4000 EXPOSE 4000
ENTRYPOINT [ "./docker-entrypoint.sh" ]
CMD [ "node", "dist/main.js" ] CMD [ "node", "dist/main.js" ]