revert docker file

This commit is contained in:
2025-06-09 14:05:44 +07:00
parent ea1bd52e0d
commit 9a176a7cd2

View File

@@ -1,5 +1,5 @@
# Use an official Node.js image as the base (using standard instead of alpine for better compatibility)
FROM node:18 AS builder
# Use an official Node.js image as the base
FROM node:18-alpine
# Set the working directory in the container
WORKDIR /app
@@ -7,40 +7,35 @@ WORKDIR /app
# Set environment variable to skip Chromium download
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
# Install git (needed for git dependencies)
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
# 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 src/Managing.WebApp/package*.json ./
# COPY package*.json ./
COPY /src/Managing.WebApp/package.json ./
# 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
# Install dependencies with the --legacy-peer-deps flag to bypass peer dependency conflicts
RUN npm install --legacy-peer-deps
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 (vite build should be sufficient, no need for separate npm run build)
# Build the app
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=builder /app/dist /usr/share/nginx/html
# COPY --from=0 /app/build /usr/share/nginx/html
COPY --from=0 /app/dist /usr/share/nginx/html
# Expose port 80 for the NGINX web server
EXPOSE 80