From c63f36fb59d3de68fd7726d5c75463dffd8348e4 Mon Sep 17 00:00:00 2001 From: philipcheung Date: Mon, 3 Nov 2025 09:29:55 +0800 Subject: [PATCH] updated docker file --- Dockerfile | 26 +++++++++++--------------- docker-compose.yml | 2 -- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/Dockerfile b/Dockerfile index 78d5a6c..c1e17a4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,26 +1,22 @@ -# Use an official Node.js runtime as a parent image -FROM node:18-alpine +FROM node:20 AS build-stage -# Set the working directory WORKDIR /app -# Copy package.json and package-lock.json -COPY package*.json ./ +COPY package*.json /app/ -# Install dependencies RUN npm install -# Copy the rest of the application code -COPY . . +COPY ./ /app/ + +ARG VITE_API_URL=${VITE_API_URL} -# Build the application RUN npm run build -# Install a lightweight web server -RUN npm install -g serve -# Set the command to run the web server -CMD ["serve", "-s", "dist"] +# Stage 1, based on Nginx, to have only the compiled app, ready for production with Nginx +FROM nginx:1 -# Expose the port the app runs on -EXPOSE 3000 \ No newline at end of file +COPY --from=build-stage /app/dist/ /usr/share/nginx/html + +COPY ./nginx.conf /etc/nginx/conf.d/default.conf +COPY ./nginx-backend-not-found.conf /etc/nginx/extra-conf.d/backend-not-found.conf diff --git a/docker-compose.yml b/docker-compose.yml index 287a67e..cd8c9b0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,8 +5,6 @@ services: dockerfile: Dockerfile container_name: healthy-oil - ports: - - "3010:3000" volumes: - .:/app - /app/node_modules