Integrate frontend UI into backend container and update Dockerfile to multi-stage build

This commit is contained in:
Hamza-Ayed
2026-03-30 17:46:55 +03:00
parent 574ff63ff3
commit ba8906ddef
5 changed files with 23 additions and 32 deletions

View File

@@ -1,33 +1,27 @@
# Step 1: Build Phase | مرحلة البناء
FROM node:20-alpine AS builder
WORKDIR /usr/src/app
# Copy package files | نسخ ملفات الحزم
COPY package*.json ./
# Install dependencies | تثبيت الاعتماديات
# Step 1: Build Frontend | مرحلة بناء الواجهة
FROM node:20-alpine AS frontend-builder
WORKDIR /usr/src/app/frontend
COPY frontend/package*.json ./
RUN npm install
# Copy source code | نسخ كود المصدر
COPY . .
# Build the app | بناء التطبيق
COPY frontend/ ./
RUN npm run build
# Step 2: Production Phase | مرحلة الإنتاج
FROM node:20-alpine
# Step 2: Build Backend | مرحلة بناء الخلفية
FROM node:20-alpine AS builder
WORKDIR /usr/src/app
# Copy package files | نسخ ملفات الحزم
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
# Install only production dependencies | تثبيت اعتماديات الإنتاج فقط
# Step 3: Production Phase | مرحلة الإنتاج
FROM node:20-alpine
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install --only=production
# Copy built files from builder | نسخ الملفات المبنية من مرحلة البناء
COPY --from=builder /usr/src/app/dist ./dist
# Copy frontend build to backend public folder | نسخ واجهة المستخدم إلى الملفات العامة
COPY --from=frontend-builder /usr/src/app/frontend/dist ./public
# Expose port | فتح المنفذ
EXPOSE 3660