Files
CKB/Dockerfile
2025-09-19 22:20:10 +07:00

85 lines
2.0 KiB
Docker
Executable File

FROM php:8.1-fpm
# Set working directory
WORKDIR /var/www/html
# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
curl \
libcurl4-openssl-dev \
pkg-config \
libonig-dev \
libxml2-dev \
libzip-dev \
zip \
unzip \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
libxpm-dev \
libvpx-dev \
supervisor \
nginx \
nodejs \
npm \
&& rm -rf /var/lib/apt/lists/*
# Install PHP extensions
RUN docker-php-ext-configure gd --with-freetype --with-jpeg --with-xpm \
&& docker-php-ext-install -j$(nproc) \
curl \
pdo_mysql \
mbstring \
exif \
pcntl \
bcmath \
gd \
zip \
dom \
xml
# Install Redis extension
RUN pecl install redis \
&& docker-php-ext-enable redis
# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Copy only composer files first for caching
COPY composer.json composer.lock ./
# Install PHP dependencies (cached if lock file unchanged)
RUN composer install --optimize-autoloader --no-dev --no-interaction --no-scripts
# Now copy the full Laravel application code
COPY . .
# Run composer scripts and install Node dependencies
RUN composer run-script post-autoload-dump && \
npm install && \
npm run production && \
php artisan storage:link
# Set proper permissions (for production only do this once)
RUN mkdir -p storage/logs \
&& mkdir -p storage/framework/{cache,sessions,views} \
&& mkdir -p storage/app/public \
&& mkdir -p bootstrap/cache \
&& chown -R www-data:www-data /var/www/html \
&& chmod -R 775 storage \
&& chmod -R 775 bootstrap/cache \
&& chmod -R 755 public \
&& chmod -R 777 storage/app/public
# Nginx config
COPY ./docker/nginx.conf /etc/nginx/sites-available/default
# Supervisor config
COPY ./docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Expose web port
EXPOSE 80
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]