Files
patchmon.net/docker/frontend.Dockerfile
Muhammad Ibrahim 3df2057f7e fix: Remove --omit=dev to install Vite and other build tools
Vite is in devDependencies and is required to build the frontend.
Using --omit=dev skipped it, causing 'vite: not found' error.

Build dependencies are needed during the builder stage, they won't be
included in the final production image since we copy only the built
artifacts (dist/) to the nginx image.
2025-10-28 16:53:52 +00:00

44 lines
887 B
Docker

# Development target
FROM node:lts-alpine AS development
WORKDIR /app
COPY package*.json ./
COPY frontend/ ./frontend/
RUN npm ci --ignore-scripts
WORKDIR /app/frontend
EXPOSE 3000
CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0", "--port", "3000"]
# Builder stage for production
FROM node:lts-alpine AS builder
WORKDIR /app/frontend
COPY frontend/package*.json ./
RUN npm cache clean --force &&\
rm -rf node_modules ~/.npm /root/.npm &&\
npm install --ignore-scripts --legacy-peer-deps --no-audit --prefer-online --fetch-retries=0
COPY frontend/ ./
RUN npm run build
# Production stage
FROM nginxinc/nginx-unprivileged:alpine
ENV BACKEND_HOST=backend \
BACKEND_PORT=3001
COPY --from=builder /app/frontend/dist /usr/share/nginx/html
COPY docker/nginx.conf.template /etc/nginx/templates/default.conf.template
EXPOSE 3000
CMD ["nginx", "-g", "daemon off;"]