diff --git a/src/Managing.WebApp/Dockerfile b/src/Managing.WebApp/Dockerfile index 16e5667..4573eff 100644 --- a/src/Managing.WebApp/Dockerfile +++ b/src/Managing.WebApp/Dockerfile @@ -1,39 +1,38 @@ -# Use an official Node.js runtime as a parent image -FROM node:18 +# Use an official Node.js image as the base +FROM node:18-alpine -# Set the working directory inside the container +# Set the working directory in the container WORKDIR /app +# Set environment variable to skip Chromium download +ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true -# Install xsel for clipboard access (useful for some applications) -RUN apt-get update && apt-get install -y xsel +# Install git and Python +RUN apk update && apk add --no-cache git python3 make g++ -# Copy only package.json and package-lock.json (or yarn.lock) initially -# This takes advantage of cached Docker layers +# Create a symlink for python3 as python +RUN ln -sf /usr/bin/python3 /usr/bin/python + +# Copy package.json and package-lock.json to the container COPY package*.json ./ -# Install dependencies -# npm ci is used instead of npm install when you want a clean, exact installation -#RUN npm ci --verbose -# Try to install dependencies with a retry mechanism -#RUN for i in 1 2 3; do npm ci --verbose && break || sleep 15; done +# Install dependencies with the --legacy-peer-deps flag to bypass peer dependency conflicts +RUN npm install --legacy-peer-deps -# Copy the rest of your application code +# Copy the rest of the app's source code to the container COPY . . -# Set necessary environment variables (if they are not secrets) -ENV NODE_ENV=development -ENV VITE_API_URL_LOCAL=https://localhost:5001 -ENV VITE_API_URL_SERVER=https://localhost +# Build the app +RUN npm run build -# Expose port 3000 for the application -EXPOSE 3000 +# Use NGINX as the web server +FROM nginx:alpine -# Install global dependencies if absolutely necessary (generally not recommended to do globally) -RUN npm install -g serve vite +# Copy the built app to the NGINX web server directory +COPY --from=0 /app/build /usr/share/nginx/html -# Build the application -RUN node --max-old-space-size=4096 node_modules/.bin/vite build +# Expose port 80 for the NGINX web server +EXPOSE 80 -# Command to run the application -CMD ["npm", "run", "serve"] +# Start the NGINX web server +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/src/Managing.WebApp/Dockerfile-web-ui-dev b/src/Managing.WebApp/Dockerfile-web-ui-dev index 2bebada..4573eff 100644 --- a/src/Managing.WebApp/Dockerfile-web-ui-dev +++ b/src/Managing.WebApp/Dockerfile-web-ui-dev @@ -1,14 +1,38 @@ -FROM node:18-alpine3.17 as build +# Use an official Node.js image as the base +FROM node:18-alpine +# Set the working directory in the container WORKDIR /app -COPY . /app -RUN npm install +# Set environment variable to skip Chromium download +ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true + +# Install git and Python +RUN apk update && apk add --no-cache git python3 make g++ + +# Create a symlink for python3 as python +RUN ln -sf /usr/bin/python3 /usr/bin/python + +# Copy package.json and package-lock.json to the container +COPY package*.json ./ + +# Install dependencies with the --legacy-peer-deps flag to bypass peer dependency conflicts +RUN npm install --legacy-peer-deps + +# Copy the rest of the app's source code to the container +COPY . . + +# Build the app RUN npm run build -FROM ubuntu -RUN apt-get update -RUN apt-get install nginx -y -COPY --from=build /app/dist /var/www/html/ +# Use NGINX as the web server +FROM nginx:alpine + +# Copy the built app to the NGINX web server directory +COPY --from=0 /app/build /usr/share/nginx/html + +# Expose port 80 for the NGINX web server EXPOSE 80 -CMD ["nginx","-g","daemon off;"] \ No newline at end of file + +# Start the NGINX web server +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file