add docker

This commit is contained in:
arifal
2025-06-24 15:09:21 +07:00
parent 2c7c99bcf1
commit c33193d5f0
5 changed files with 294 additions and 149 deletions

View File

@@ -9,6 +9,51 @@ COPY . .
EXPOSE 5173
CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0"]
# Local development stage for PHP
FROM php:8.2-fpm AS local
WORKDIR /var/www
# Install PHP extensions
RUN apt-get update && apt-get install -y \
git curl zip unzip libpng-dev libonig-dev libxml2-dev libzip-dev \
&& docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd zip
# Install Node.js
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
&& apt-get install -y nodejs
# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Create www-data user with same UID/GID as host user (1000:1000 is common for first user)
RUN usermod -u 1000 www-data && groupmod -g 1000 www-data
# Copy application files
COPY . .
# Install dependencies
RUN composer install
# Create storage directories and set proper permissions
RUN mkdir -p storage/framework/{sessions,views,cache} \
&& mkdir -p storage/logs \
&& mkdir -p bootstrap/cache \
&& chown -R www-data:www-data /var/www \
&& chmod -R 775 /var/www/storage \
&& chmod -R 775 /var/www/bootstrap/cache
# Create entrypoint script to fix permissions on startup
RUN echo '#!/bin/bash\n\
chown -R www-data:www-data /var/www/storage /var/www/bootstrap/cache\n\
chmod -R 775 /var/www/storage /var/www/bootstrap/cache\n\
exec "$@"' > /entrypoint.sh && chmod +x /entrypoint.sh
USER www-data
EXPOSE 9000
ENTRYPOINT ["/entrypoint.sh"]
CMD ["php-fpm"]
# Production stage
FROM php:8.2-fpm AS production
WORKDIR /var/www