docker edit
This commit is contained in:
+21
-4
@@ -1,15 +1,32 @@
|
|||||||
|
# ---- Stage 1: Build frontend (Vite/React) ----
|
||||||
|
FROM node:20-alpine AS build
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Install dependencies first (better layer caching)
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
# Copy the rest of the source and build
|
||||||
|
COPY . .
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# ---- Stage 2: PHP + Apache to serve built files + api.php ----
|
||||||
FROM php:8.2-apache
|
FROM php:8.2-apache
|
||||||
|
|
||||||
# Enable Apache mod_rewrite
|
# Enable Apache mod_rewrite (useful for SPA routing)
|
||||||
RUN a2enmod rewrite
|
RUN a2enmod rewrite
|
||||||
|
|
||||||
# Install MySQL PDO extension
|
# Install MySQL PDO extension
|
||||||
RUN docker-php-ext-install pdo pdo_mysql
|
RUN docker-php-ext-install pdo pdo_mysql
|
||||||
|
|
||||||
# Copy project files to Apache web root
|
# Copy built frontend assets from Stage 1
|
||||||
COPY . /var/www/html/
|
COPY --from=build /app/dist/ /var/www/html/
|
||||||
|
|
||||||
|
# Copy api.php (and any other PHP backend files) into web root
|
||||||
|
COPY api.php /var/www/html/api.php
|
||||||
|
|
||||||
# Set permissions
|
# Set permissions
|
||||||
RUN chown -R www-data:www-data /var/www/html
|
RUN chown -R www-data:www-data /var/www/html
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
Reference in New Issue
Block a user