From 14a97b4879245251c31465ffd0f36616375ee02b Mon Sep 17 00:00:00 2001 From: Michael C Date: Tue, 29 Jun 2021 18:18:42 -0400 Subject: [PATCH] multi-stage dockerfile with node:14-alpine --- Dockerfile | 19 ++++++++++--------- entrypoint.sh | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index b9702cd..c39d92e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,14 @@ -FROM node:14 -WORKDIR /usr/src/app -COPY package.json . -COPY package-lock.json . -COPY tsconfig.json . +FROM node:14-alpine as builder +RUN apk add --no-cache --virtual .build-deps python make g++ +COPY package.json package-lock.json tsconfig.json entrypoint.sh ./ COPY src src -RUN npm ci -RUN npm run tsc -RUN mkdir databases -COPY databases/*.sql databases/ +RUN npm ci && npm run tsc + +FROM node:14-alpine as app +WORKDIR /usr/src/app +COPY --from=builder node_modules . +COPY --from=builder dist ./dist COPY entrypoint.sh . +COPY databases/*.sql databases/ EXPOSE 8080 CMD ./entrypoint.sh diff --git a/entrypoint.sh b/entrypoint.sh index b684468..9055d2c 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh set -e echo 'Entrypoint script' cd /usr/src/app