diff --git a/src/Managing.WebApp/.dockerignore b/src/Managing.WebApp/.dockerignore new file mode 100644 index 0000000..c55d76c --- /dev/null +++ b/src/Managing.WebApp/.dockerignore @@ -0,0 +1,16 @@ +node_modules +npm-debug.log* +yarn-debug.log* +yarn-error.log* +.git +.gitignore +.dockerignore +Dockerfile* +README.md +.env +.nyc_output +coverage +.DS_Store +*.log +dist +build \ 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 a3199ec..4d434c9 100644 --- a/src/Managing.WebApp/Dockerfile-web-ui-dev +++ b/src/Managing.WebApp/Dockerfile-web-ui-dev @@ -1,5 +1,5 @@ -# Use an official Node.js image as the base -FROM node:18-alpine +# Use an official Node.js image as the base (using standard instead of alpine for better compatibility) +FROM node:18 AS builder # Set the working directory in the container WORKDIR /app @@ -7,35 +7,40 @@ WORKDIR /app # 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 +# Install git (needed for git dependencies) +RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/* # Copy package.json and package-lock.json to the container -# COPY package*.json ./ -COPY /src/Managing.WebApp/package.json ./ +COPY src/Managing.WebApp/package*.json ./ -# Install dependencies with the --legacy-peer-deps flag to bypass peer dependency conflicts -RUN npm install --legacy-peer-deps +# Clean npm cache and install dependencies with verbose logging +RUN npm cache clean --force + +# Set npm timeout and try installing with increased verbosity and timeout +RUN npm config set fetch-timeout 300000 +RUN npm config set fetch-retry-mintimeout 20000 +RUN npm config set fetch-retry-maxtimeout 120000 + +# Install dependencies with error handling +RUN npm install --legacy-peer-deps --verbose --no-optional || \ + (echo "First attempt failed, trying without cache..." && \ + rm -rf node_modules package-lock.json && \ + npm install --legacy-peer-deps --no-cache) + +# Install global dependencies RUN npm install -g tailwindcss postcss autoprefixer @tailwindcss/typography # Copy the rest of the app's source code to the container -# COPY . . -RUN ls -la COPY src/Managing.WebApp/ . -RUN node --max-old-space-size=8192 ./node_modules/.bin/vite build -# Build the app +# Build the app (vite build should be sufficient, no need for separate npm run build) RUN npm run build # 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 -COPY --from=0 /app/dist /usr/share/nginx/html +COPY --from=builder /app/dist /usr/share/nginx/html # Expose port 80 for the NGINX web server EXPOSE 80