From 09cb4efd556dd9c2c3c3a56a075437402e87031c Mon Sep 17 00:00:00 2001 From: ChrQR Date: Thu, 30 May 2024 00:10:06 +0200 Subject: [PATCH] svelte dockerfile --- client/Dockerfile | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/client/Dockerfile b/client/Dockerfile index e7e0705..de0057e 100644 --- a/client/Dockerfile +++ b/client/Dockerfile @@ -1,21 +1,22 @@ -# Use an official node runtime as a parent image -FROM node:20 +FROM node:18-alpine AS builder +RUN mkdir /app +WORKDIR /app -# Set the working directory to /client -WORKDIR /client +COPY . /app -# Copy package.json and package-lock.json to /client -COPY package*.json ./ +RUN cd /app && npm install && npm build -# Install any needed packages specified in package.json -RUN npm install +FROM node:18-alpine -# Copy the current directory contents into the container at /client -COPY . . +RUN mkdir /app -# Build the app -RUN npm run build +COPY --from=builder /app/build /app/build +COPY --from=builder /app/package.json /app/npm.lock /app/ -# Serve the app -RUN npm install -g serve -CMD ["serve", "-s", "public", "-l", "3000"] +RUN cd /app && \ + npm install --production &&\ + npm cache clean + +WORKDIR /app + +CMD ["node", "build/index.js"] \ No newline at end of file