Files
zemailnator/Dockerfile

59 lines
1.5 KiB
Docker

FROM php:8.4-fpm-alpine
# Install extension installer
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
# Install system dependencies
RUN apk add --no-cache \
git \
curl \
zip \
unzip \
nginx \
supervisor \
nodejs \
npm \
bash
# Install PHP extensions
RUN install-php-extensions pdo_mysql mbstring exif pcntl bcmath gd intl imap redis zip
# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Set working directory
WORKDIR /var/www
# Copy existing application directory contents
COPY . /var/www
# 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
# 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 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
EXPOSE 80
# Configure entrypoint
COPY .docker/entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
# Start Supervisor
CMD ["/usr/local/bin/entrypoint.sh"]