From c17d7537ac7377143f85c78af3a776ad3faaa8b0 Mon Sep 17 00:00:00 2001 From: djeck1432 Date: Wed, 2 Oct 2024 21:30:02 +0200 Subject: [PATCH] upgrade fe dockerfile --- frontend/Dockerfile | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/frontend/Dockerfile b/frontend/Dockerfile index a007c2b7..c7fbdb7d 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,27 +1,32 @@ # Stage 1: Build the react app -FROM node:20 AS build +FROM node:20-alpine AS build WORKDIR /usr/src/app # Copy package.json and package-lock.json to install dependencies COPY package*.json ./ -# Install dependencies with legacy peer deps option -RUN npm install --legacy-peer-deps || true +# Install dependencies +# Remove --legacy-peer-deps unless absolutely necessary +RUN npm ci --only=production # Copy the rest of the application source code COPY . . -# Build the app (if there are build commands in the package.json) +# Build the app RUN npm run build # Stage 2: Serve the built app using nginx FROM nginx:alpine +# Copy custom nginx configuration +COPY ../spotnet.conf /etc/nginx/conf.d/default.conf + # Copy the built files from the previous stage to the nginx container COPY --from=build /usr/src/app/build /usr/share/nginx/html # Expose the port Nginx will listen to EXPOSE 80 +# Use CMD instead of ENTRYPOINT for more flexibility CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file