52 lines
1.2 KiB
Docker
52 lines
1.2 KiB
Docker
FROM php:8.2-fpm as base
|
|
|
|
# Install system dependencies
|
|
RUN apt-get update && apt-get install -y \
|
|
git \
|
|
unzip \
|
|
libzip-dev \
|
|
libicu-dev \
|
|
&& docker-php-ext-install \
|
|
zip \
|
|
intl \
|
|
pdo_mysql
|
|
|
|
# Install Composer
|
|
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
|
|
|
# Install Symfony CLI
|
|
RUN curl -sS https://get.symfony.com/cli/installer | bash && \
|
|
mv /root/.symfony5/bin/symfony /usr/local/bin/symfony
|
|
|
|
# Set working directory
|
|
WORKDIR /var/www/html
|
|
|
|
FROM base as dev
|
|
|
|
CMD ["php-fpm"]
|
|
|
|
FROM base as production
|
|
|
|
# Install Nginx
|
|
RUN apt-get update && apt-get install -y nginx
|
|
|
|
# Copy application files
|
|
COPY --chown=www-data:www-data . .
|
|
|
|
# Install dependencies
|
|
RUN composer install --no-interaction --optimize-autoloader --no-dev
|
|
|
|
# Copy Nginx configuration
|
|
COPY docker/nginx/default.conf /etc/nginx/conf.d/default.conf
|
|
# Enable site by creating a symbolic link to sites-enabled
|
|
RUN ln -sf /etc/nginx/conf.d/default.conf /etc/nginx/sites-enabled/default
|
|
|
|
# Remove default Nginx configuration
|
|
RUN rm -f /etc/nginx/sites-enabled/default.conf
|
|
|
|
# Ensure Nginx directories exist
|
|
RUN mkdir -p /var/log/nginx
|
|
|
|
# Start Nginx and PHP-FPM
|
|
CMD ["/bin/bash", "-c", "service nginx start && php-fpm"]
|