From 95216371d312508cbc16ea39b6b64153998f7340 Mon Sep 17 00:00:00 2001 From: Gal Date: Thu, 21 Nov 2024 19:07:56 +0100 Subject: [PATCH] Add Dockerfile --- Dockerfile | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8e3a60a..3a07169 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,21 @@ +# Build Stage FROM node:20-slim as builder WORKDIR /usr/src/app -COPY package.json . -RUN npm ci -RUN npm install +# Copy dependency files first for caching +COPY package.json package-lock.json ./ +RUN npm ci + +# Copy the rest of the source files +COPY . . + +# Final Stage FROM node:20-slim WORKDIR /usr/src/app + +# Copy only the built application and production dependencies COPY --from=builder /usr/src/app/ /usr/src/app/ -COPY . . -CMD ["npx", "@11ty/eleventy", "--serve", "--port", "3000"] +RUN npm prune --production + +# Default command to run Eleventy in serve mode +CMD ["npx", "@11ty/eleventy", "--serve", "--port", "4000"]