Skip to content

Docker #1209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 18, 2025
Merged

Docker #1209

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 38 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:8.4-fpm
FROM php:8.2-fpm
LABEL org.opencontainers.image.authors="stephen@stephenneal.net"

# Update OS && install utilities
Expand Down Expand Up @@ -37,4 +37,40 @@ RUN docker-php-ext-configure intl \

# Copy PHP configuration files
COPY local.ini /usr/local/etc/php/conf.d/local.ini
COPY www.conf /usr/local/etc/php-fpm.d/www.conf
COPY www.conf /usr/local/etc/php-fpm.d/www.conf

# Set working directory
WORKDIR /var/www/html

# Install Nginx
RUN apt-get update && apt-get install -y nginx && rm -rf /var/lib/apt/lists/*

# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# Copy application skeleton (respects .dockerignore)
# Ensure .dockerignore is set up to exclude vendor, node_modules, .env etc.
COPY . .

# Install PHP dependencies
RUN composer install --optimize-autoloader --no-dev --no-interaction --no-progress

# Set permissions for Laravel
RUN chown -R www-data:www-data storage bootstrap/cache \
&& chmod -R 775 storage bootstrap/cache

# Copy Nginx site configuration
# This assumes nginx-site.conf is for Nginx and configured for Laravel
COPY nginx-site.conf /etc/nginx/sites-available/default
RUN ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default || true \
&& rm /etc/nginx/sites-enabled/default.conf || true # Remove default Nginx config if it exists with this name

# Copy deploy script (which handles migrations, caching)
COPY deploy.sh /usr/local/bin/deploy.sh
RUN chmod +x /usr/local/bin/deploy.sh

# Expose port 80 for Nginx
EXPOSE 80

# CMD / ENTRYPOINT to start supervisor (which then starts nginx and php-fpm) will be added later.
# Frontend asset compilation (Node.js multi-stage build) will also be added later.
25 changes: 25 additions & 0 deletions local.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
; Custom PHP settings for production

; Error reporting
display_errors = Off
log_errors = On
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT

; Performance and Security
expose_php = Off
max_execution_time = 60 ; Increased for potentially longer scripts
memory_limit = 256M ; Adjust based on your application's needs
post_max_size = 32M ; Max size for POST requests
upload_max_filesize = 32M ; Max upload file size
date.timezone = "UTC" ; Set your preferred timezone

; Opcache (ensure opcache extension is enabled in Dockerfile)
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
opcache.revalidate_freq=0 ; Set to 0 for production (validate on every request if timestamp changed) or a higher value
opcache.validate_timestamps=1 ; Check timestamps in production
opcache.save_comments=1
opcache.fast_shutdown=1
22 changes: 22 additions & 0 deletions www.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[www]
user = www-data
group = www-data
listen = /var/run/php-fpm.sock
;listen = 127.0.0.1:9000
listen.owner = www-data
listen.group = www-data
listen.mode = 0660

pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
pm.max_requests = 500

chdir = /var/www/html

catch_workers_output = yes
php_flag[display_errors] = off
php_admin_value[error_log] = /var/log/fpm-php.www.log
php_admin_flag[log_errors] = on