Dockerfile 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # Multi-stage Dockerfile for complete inventory solution
  2. FROM node:18-alpine AS frontend-builder
  3. # Set working directory for frontend build
  4. WORKDIR /app/frontend
  5. # Copy frontend package files
  6. COPY frontend/package*.json ./
  7. # Install frontend dependencies
  8. RUN npm ci --only=production
  9. # Copy frontend source code
  10. COPY frontend/ .
  11. # Build frontend for production
  12. RUN npm run build
  13. # Backend and final stage
  14. FROM php:8.1-apache
  15. # Install system dependencies including Node.js for frontend build tools
  16. RUN apt-get update && apt-get install -y \
  17. libzip-dev \
  18. libpng-dev \
  19. libjpeg-dev \
  20. libfreetype6-dev \
  21. zip \
  22. unzip \
  23. curl \
  24. gnupg \
  25. && curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
  26. && apt-get install -y nodejs \
  27. && docker-php-ext-configure gd --with-freetype --with-jpeg \
  28. && docker-php-ext-install gd zip pdo_mysql \
  29. && a2enmod rewrite \
  30. && a2enmod headers
  31. # Install Composer
  32. COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
  33. # Set working directory
  34. WORKDIR /var/www/html
  35. # Copy backend files
  36. COPY backend/ .
  37. # Install PHP dependencies
  38. RUN composer install --no-dev --optimize-autoloader
  39. # Copy built frontend from builder stage
  40. COPY --from=frontend-builder /app/frontend/dist ./frontend/dist
  41. # Create uploads directory and set permissions
  42. RUN mkdir -p uploads && \
  43. chown -R www-data:www-data /var/www/html/uploads && \
  44. chmod -R 755 /var/www/html/uploads
  45. # Copy Apache configuration
  46. COPY docker/apache.conf /etc/apache2/sites-available/000-default.conf
  47. # Expose port
  48. EXPOSE 80
  49. # Start Apache
  50. CMD ["apache2-foreground"]