diff --git a/Dockerfile b/Dockerfile index e5c900f..d42e7e4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,25 +1,31 @@ -FROM php:8.4-fpm +FROM php:8.4-fpm-alpine # Install system dependencies -RUN apt-get update && apt-get install -y \ +RUN apk add --no-cache \ git \ curl \ libpng-dev \ - libonig-dev \ + oniguruma-dev \ libxml2-dev \ zip \ unzip \ nginx \ supervisor \ - libc-client-dev \ - libkrb5-dev \ - && rm -rf /var/lib/apt/lists/* + imap-dev \ + krb5-dev \ + linux-headers \ + nodejs \ + npm \ + bash \ + icu-dev \ + $PHPIZE_DEPS # Configure and install PHP extensions RUN docker-php-ext-configure imap --with-kerberos --with-imap-ssl \ && docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd intl imap \ && pecl install redis \ - && docker-php-ext-enable redis + && docker-php-ext-enable redis \ + && apk del $PHPIZE_DEPS # Install Composer COPY --from=composer:latest /usr/bin/composer /usr/bin/composer @@ -30,28 +36,27 @@ WORKDIR /var/www # Copy existing application directory contents COPY . /var/www -# Install PHP dependencies -RUN composer install --no-interaction --no-dev --optimize-autoloader +# Install PHP/Node dependencies and build frontend +RUN composer install --no-interaction --no-dev --optimize-autoloader \ + && npm install \ + && npm run build \ + && npm cache clean --force # Nginx config -COPY .docker/nginx.conf /etc/nginx/sites-available/default -RUN rm -rf /etc/nginx/sites-enabled/default && ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default +# Alpine uses http.d instead of sites-available +COPY .docker/nginx.conf /etc/nginx/http.d/default.conf # Supervisor config +RUN mkdir -p /etc/supervisor/conf.d /var/log/supervisor COPY .docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf # Set directory permissions -RUN chown -R www-data:www-data /var/www/storage /var/www/bootstrap/cache \ +RUN mkdir -p /run/nginx /var/lib/nginx \ + && chown -R www-data:www-data /var/www \ + && chown -R www-data:www-data /var/lib/nginx \ + && chown -R www-data:www-data /run/nginx \ && chmod -R 775 /var/www/storage /var/www/bootstrap/cache -# Build frontend assets -RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \ - && apt-get install -y nodejs \ - && npm install \ - && npm run build \ - && apt-get remove -y nodejs \ - && apt-get autoremove -y - EXPOSE 80 # Configure entrypoint