2026-03-16 04:20:00 +07:00
|
|
|
FROM php:8.2-fpm-alpine
|
|
|
|
|
|
2026-03-16 07:22:01 +07:00
|
|
|
# Install system dependencies
|
2026-03-16 04:20:00 +07:00
|
|
|
RUN apk add --no-cache \
|
|
|
|
|
libzip-dev \
|
|
|
|
|
postgresql-dev \
|
2026-03-16 06:45:23 +07:00
|
|
|
libpng-dev \
|
|
|
|
|
libjpeg-turbo-dev \
|
|
|
|
|
freetype-dev \
|
|
|
|
|
oniguruma-dev \
|
2026-03-16 07:22:01 +07:00
|
|
|
git \
|
|
|
|
|
curl \
|
2026-03-16 06:45:23 +07:00
|
|
|
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
|
2026-03-16 04:20:00 +07:00
|
|
|
&& docker-php-ext-install -j$(nproc) \
|
|
|
|
|
pdo_pgsql \
|
|
|
|
|
pgsql \
|
|
|
|
|
opcache \
|
|
|
|
|
zip \
|
2026-03-16 06:45:23 +07:00
|
|
|
bcmath \
|
|
|
|
|
gd \
|
|
|
|
|
exif \
|
2026-03-16 07:22:01 +07:00
|
|
|
pcntl
|
2026-03-16 04:20:00 +07:00
|
|
|
|
2026-03-16 06:41:29 +07:00
|
|
|
# Install Composer
|
|
|
|
|
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
|
|
|
|
|
2026-03-16 04:20:00 +07:00
|
|
|
WORKDIR /var/www/html
|
|
|
|
|
|
2026-03-16 07:22:01 +07:00
|
|
|
# COPY ALL APPLICATION FILES FIRST (including artisan)
|
2026-03-16 04:20:00 +07:00
|
|
|
COPY --chown=www-data:www-data . .
|
|
|
|
|
|
2026-03-16 07:22:01 +07:00
|
|
|
# Create the missing Helper file
|
|
|
|
|
RUN mkdir -p app/Helpers && \
|
|
|
|
|
echo "<?php\n\nnamespace App\Helpers;\n\nclass Helper\n{\n public static function formatCurrency(\$amount, \$currency = 'INR')\n {\n return \$currency . ' ' . number_format(\$amount, 2);\n }\n\n public static function generateRandomString(\$length = 10)\n {\n return substr(str_shuffle('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'), 0, \$length);\n }\n}\n" > app/Helpers/Helper.php
|
|
|
|
|
|
2026-03-16 06:41:29 +07:00
|
|
|
# Create necessary directories
|
2026-03-16 04:20:00 +07:00
|
|
|
RUN mkdir -p storage/framework/{cache,sessions,views} \
|
|
|
|
|
&& mkdir -p storage/logs \
|
|
|
|
|
&& mkdir -p bootstrap/cache \
|
|
|
|
|
&& chown -R www-data:www-data storage bootstrap/cache \
|
2026-03-16 07:22:01 +07:00
|
|
|
&& chmod -R 775 storage bootstrap/cache
|
|
|
|
|
|
|
|
|
|
# NOW run composer install (artisan file exists at this point)
|
|
|
|
|
RUN composer install --no-dev --no-interaction --no-progress --optimize-autoloader
|
2026-03-16 04:20:00 +07:00
|
|
|
|
2026-03-16 06:41:29 +07:00
|
|
|
# Create startup script
|
2026-03-16 04:20:00 +07:00
|
|
|
RUN echo '#!/bin/sh' > /start.sh && \
|
|
|
|
|
echo 'if [ "$MODE" = "dev" ]; then' >> /start.sh && \
|
|
|
|
|
echo ' echo "Starting in DEV mode with PHP built-in server on port 8000..."' >> /start.sh && \
|
|
|
|
|
echo ' php artisan serve --host=0.0.0.0 --port=8000' >> /start.sh && \
|
|
|
|
|
echo 'else' >> /start.sh && \
|
|
|
|
|
echo ' echo "Starting in PROD mode with PHP-FPM on port 9000..."' >> /start.sh && \
|
|
|
|
|
echo ' php-fpm' >> /start.sh && \
|
|
|
|
|
echo 'fi' >> /start.sh && \
|
|
|
|
|
chmod +x /start.sh
|
|
|
|
|
|
|
|
|
|
EXPOSE 8000 9000
|
|
|
|
|
|
|
|
|
|
CMD ["/start.sh"]
|