Skip to content

Commit 3c00892

Browse files
committed
Docker
1 parent ec2f5f1 commit 3c00892

File tree

3 files changed

+85
-2
lines changed

3 files changed

+85
-2
lines changed

Dockerfile

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM php:8.4-fpm
1+
FROM php:8.2-fpm
22
LABEL org.opencontainers.image.authors="stephen@stephenneal.net"
33

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

3838
# Copy PHP configuration files
3939
COPY local.ini /usr/local/etc/php/conf.d/local.ini
40-
COPY www.conf /usr/local/etc/php-fpm.d/www.conf
40+
COPY www.conf /usr/local/etc/php-fpm.d/www.conf
41+
42+
# Set working directory
43+
WORKDIR /var/www/html
44+
45+
# Install Nginx
46+
RUN apt-get update && apt-get install -y nginx && rm -rf /var/lib/apt/lists/*
47+
48+
# Install Composer
49+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
50+
51+
# Copy application skeleton (respects .dockerignore)
52+
# Ensure .dockerignore is set up to exclude vendor, node_modules, .env etc.
53+
COPY . .
54+
55+
# Install PHP dependencies
56+
RUN composer install --optimize-autoloader --no-dev --no-interaction --no-progress
57+
58+
# Set permissions for Laravel
59+
RUN chown -R www-data:www-data storage bootstrap/cache \
60+
&& chmod -R 775 storage bootstrap/cache
61+
62+
# Copy Nginx site configuration
63+
# This assumes nginx-site.conf is for Nginx and configured for Laravel
64+
COPY nginx-site.conf /etc/nginx/sites-available/default
65+
RUN ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default || true \
66+
&& rm /etc/nginx/sites-enabled/default.conf || true # Remove default Nginx config if it exists with this name
67+
68+
# Copy deploy script (which handles migrations, caching)
69+
COPY deploy.sh /usr/local/bin/deploy.sh
70+
RUN chmod +x /usr/local/bin/deploy.sh
71+
72+
# Expose port 80 for Nginx
73+
EXPOSE 80
74+
75+
# CMD / ENTRYPOINT to start supervisor (which then starts nginx and php-fpm) will be added later.
76+
# Frontend asset compilation (Node.js multi-stage build) will also be added later.

local.ini

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
; Custom PHP settings for production
2+
3+
; Error reporting
4+
display_errors = Off
5+
log_errors = On
6+
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
7+
8+
; Performance and Security
9+
expose_php = Off
10+
max_execution_time = 60 ; Increased for potentially longer scripts
11+
memory_limit = 256M ; Adjust based on your application's needs
12+
post_max_size = 32M ; Max size for POST requests
13+
upload_max_filesize = 32M ; Max upload file size
14+
date.timezone = "UTC" ; Set your preferred timezone
15+
16+
; Opcache (ensure opcache extension is enabled in Dockerfile)
17+
opcache.enable=1
18+
opcache.enable_cli=1
19+
opcache.memory_consumption=128
20+
opcache.interned_strings_buffer=8
21+
opcache.max_accelerated_files=10000
22+
opcache.revalidate_freq=0 ; Set to 0 for production (validate on every request if timestamp changed) or a higher value
23+
opcache.validate_timestamps=1 ; Check timestamps in production
24+
opcache.save_comments=1
25+
opcache.fast_shutdown=1

www.conf

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[www]
2+
user = www-data
3+
group = www-data
4+
listen = /var/run/php-fpm.sock
5+
;listen = 127.0.0.1:9000
6+
listen.owner = www-data
7+
listen.group = www-data
8+
listen.mode = 0660
9+
10+
pm = dynamic
11+
pm.max_children = 5
12+
pm.start_servers = 2
13+
pm.min_spare_servers = 1
14+
pm.max_spare_servers = 3
15+
pm.max_requests = 500
16+
17+
chdir = /var/www/html
18+
19+
catch_workers_output = yes
20+
php_flag[display_errors] = off
21+
php_admin_value[error_log] = /var/log/fpm-php.www.log
22+
php_admin_flag[log_errors] = on

0 commit comments

Comments
 (0)