Skip to content
Merged
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
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ my-project/ // Main Project Directory
├── docker/ // Docker Related
│ ├── containers/ // Service Containers
│ │ ├── nginx/
│ │ │ ├── conf.d/
│ │ │ │ └── default.conf // nginx config
│ │ │ ├── conf.d/ // NginX Configurations
│ │ │ │ └── default.conf // default configuration file
│ │ │ └── Dockerfile
│ │ ├── php/
│ │ │ ├── config/ // PHP Configurations
Expand All @@ -21,10 +21,12 @@ my-project/ // Main Project Directory
│ │ │ │ └── php-prod.ini // production specific configuration
│ │ │ └── Dockerfile
│ │ ├── mysql/
│ │ │ ├── conf.d/ // MySql Configurations
│ │ │ │ └── my.cnf // default configuration file
│ │ │ └── Dockerfile
│ │ └── composer/
│ │ └── Dockerfile
│ ├── enviroments/ // Environment variables
│ ├── environments/ // Environment variables
│ │ ├── config.env // Main config file
│ │ ├── local.env // Local development
│ │ ├── test.env
Expand Down
8 changes: 5 additions & 3 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ my-project/ // Main Project Directory
├── docker/ // Docker Related
│ ├── containers/ // Service Containers
│ │ ├── nginx/
│ │ │ ├── conf.d/
│ │ │ │ └── default.conf // nginx config
│ │ │ ├── conf.d/ // NginX Configurations
│ │ │ │ └── default.conf // default configuration file
│ │ │ └── Dockerfile
│ │ ├── php/
│ │ │ ├── config/ // PHP Configurations
Expand All @@ -19,10 +19,12 @@ my-project/ // Main Project Directory
│ │ │ │ └── php-prod.ini // production specific configuration
│ │ │ └── Dockerfile
│ │ ├── mysql/
│ │ │ ├── conf.d/ // MySql Configurations
│ │ │ │ └── my.cnf // default configuration file
│ │ │ └── Dockerfile
│ │ └── composer/
│ │ └── Dockerfile
│ ├── enviroments/ // Environment variables
│ ├── environments/ // Environment variables
│ │ ├── config.env // Main config file
│ │ ├── local.env // Environment config file
│ │ ├── test.env
Expand Down
6 changes: 4 additions & 2 deletions docker/containers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ my-project/ // Main Project Directory
├── docker/ // Docker Related
│ ├── containers/ // Service Containers
│ │ ├── nginx/
│ │ │ ├── conf.d/
│ │ │ │ └── default.conf // nginx config
│ │ │ ├── conf.d/ // NginX Configurations
│ │ │ │ └── default.conf // default configuration file
│ │ │ └── Dockerfile
│ │ ├── php/
│ │ │ ├── config/ // PHP Configurations
Expand All @@ -19,6 +19,8 @@ my-project/ // Main Project Directory
│ │ │ │ └── php-prod.ini // production specific configuration
│ │ │ └── Dockerfile
│ │ ├── mysql/
│ │ │ ├── conf.d/ // MySql Configurations
│ │ │ │ └── my.cnf // default configuration file
│ │ │ └── Dockerfile
│ │ └── composer/
│ │ └── Dockerfile
Expand Down
18 changes: 12 additions & 6 deletions docker/containers/composer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# CRITICAL FIX:
# The FROM instruction now uses the alias 'base'.
# This alias is defined in docker-compose.yml's 'additional_contexts'
# and explicitly tells Docker to use the result of the 'php' service build
# as the base image, fixing the build order dependency.
FROM base
# =====================================================================
# Composer Dockerfile
# ---------------------------------------------------------------------
# docker/containers/composer/Dockerfile
# =====================================================================

# Create composer image from the 'base' image alias defined in the docker-compose.yml
# 'additional_contexts' to point to the result of the PHP service build.
FROM base as composer_base

# Install Composer
# This curl command fetches the installer and pipes it to PHP, installing the
Expand All @@ -13,3 +16,6 @@ RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local
# Since the executable is in /usr/local/bin, it is automatically available in the container's PATH.
# Add composer bin path to environment variable
RUN export PATH=$PATH":/usr/bin"

# Set working directory
WORKDIR /var/www/html
13 changes: 12 additions & 1 deletion docker/containers/mysql/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
#=====================================================================
# MySQL Dockerfile
#---------------------------------------------------------------------
# docker/containers/mysql/Dockerfile
#=====================================================================

# Install MySQL
FROM library/mysql:5.7.22
FROM mysql:5.7.22

# Copy MySQL configuration
COPY ./containers/mysql/conf.d/my.cnf /etc/mysql/conf.d/my.cnf

EXPOSE 3306
28 changes: 28 additions & 0 deletions docker/containers/mysql/conf.d/my.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Default MySQL Configuration (my.cnf)

[mysqld]
# =========================================================
# 1. CHARACTER SETTINGS
# Ensure full compatibility for modern web apps (supports emojis, etc.)
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci

# =========================================================
# 2. INNODB OPTIMIZATION
# Tuned for a typical development machine.
innodb_buffer_pool_size = 512M
innodb_log_file_size = 128M

# =========================================================
# 3. RESOURCE LIMITS
max_allowed_packet = 64M
max_connections = 500

# =========================================================
# 4. STRICT MODE
# Enforce stricter SQL rules (highly recommended for development)
sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION"

[client]
# Settings for MySQL client programs
default-character-set = utf8mb4
15 changes: 12 additions & 3 deletions docker/containers/nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
#=====================================================================
# NginX Dockerfile
#---------------------------------------------------------------------
# docker/containers/nginx/Dockerfile
#=====================================================================

# Install NginX
FROM library/nginx:stable-alpine
FROM nginx:stable-alpine

#WORKDIR ./var/www/html
# Set the working directory
WORKDIR /var/www/html

# Copy NginX configuration
#COPY ./containers/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf
# This is crucial for making the built image self-contained and ready for production,
# even though the volume mount in docker-compose.yml will override it for local development.
COPY ./containers/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf
19 changes: 15 additions & 4 deletions docker/containers/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# Start from the official base image
#=====================================================================
# PHP Dockerfile
#---------------------------------------------------------------------
# docker/containers/php/Dockerfile
#=====================================================================

# Install PHP
FROM php:8.2-fpm-alpine

# 1. Define the build argument for the environment
ARG SYS_ENV

# Set the working directory to the standard web root
WORKDIR /var/www/html

Expand All @@ -9,11 +18,13 @@ WORKDIR /var/www/html
# 2. Configure and install required PHP extensions (opcache for speed)
RUN apk add --no-cache git zip libzip-dev \
&& docker-php-ext-configure zip \
&& docker-php-ext-install mysqli pdo pdo_mysql opcache zip \
&& docker-php-ext-install pdo pdo_mysql opcache zip \
&& rm -rf /var/cache/apk/* # Clean up cache to minimize image size

# Copy PHP configuration
# COPY ./containers/php/config/php-$SYS_ENV.ini /usr/local/etc/php/php.ini
# This uses the build arg to select the correct INI file (e.g., php-development.ini)
# and places it in the conf.d directory as 99-custom.ini to ensure it overrides defaults.
COPY ./containers/php/config/php-${SYS_ENV}.ini /usr/local/etc/php/conf.d/99-custom.ini

# Default command to start PHP-FPM
CMD ["php-fpm"]
CMD ["php-fpm"]
50 changes: 42 additions & 8 deletions docker/containers/php/config/php-local.ini
Original file line number Diff line number Diff line change
@@ -1,21 +1,55 @@
;
; Custom PHP Settings
; Custom PHP Settings for Local Development

; =========================================================
; 1. RESOURCE MANAGEMENT
; =========================================================

; Maximum amount of memory a script may consume
memory_limit = 4096M
memory_limit = 512M

; Maximum execution time of each script, in seconds
max_execution_time = 0


; =========================================================
; 2. ERROR & LOGGING
; =========================================================

; Errors and Logs
error_reporting = E_ALL
display_errors = On
log_errors = On
display_errors = On ; IMPORTANT: Show errors directly on the screen (Dev only)
log_errors = On ; Log errors to the specified file
error_log = /var/log/php_errors.log

; Files & Uploads

; =========================================================
; 3. UPLOADS & FILES
; =========================================================

post_max_size = 16M
upload_max_filesize = 16M
max_file_uploads = 20

; Security

; =========================================================
; 4. SECURITY & SESSIONS
; =========================================================

; Ensures cookies are only sent over HTTPS
session.cookie_secure = 0 ; For Development, set to 0 and MUST be 1 in production.
session.use_strict_mode = 1
session.use_only_cookies = 1
session.cookie_secure = 1


; =========================================================
; 5. OPCACHE (PERFORMANCE)
; =========================================================

opcache.enable = 0 ; For Development, Opcache MUST be disabled
opcache.enable_cli = 0 ; Also disable for CLI commands like Composer
; The amount of memory to use for the opcode cache. 256MB is a good starting point.
; opcache.memory_consumption = 256
; How often to check the timestamp of the PHP files for updates (0 = never check, ideal for immutable containers)
; opcache.validate_timestamps = 0
; Cache the compiled PHP files even after the PHP-FPM process restarts.
; opcache.interned_strings_buffer = 16
52 changes: 43 additions & 9 deletions docker/containers/php/config/php-prod.ini
Original file line number Diff line number Diff line change
@@ -1,21 +1,55 @@
;
; Custom PHP Settings
; Custom PHP Settings for Production

; Maximum amount of memory a script may consume
memory_limit = 4096M
; =========================================================
; 1. RESOURCE MANAGEMENT
; =========================================================

; Maximum amount of memory a script may consume.
memory_limit = 256M

; Maximum execution time of each script, in seconds
max_execution_time = 60


; =========================================================
; 2. ERROR & LOGGING
; =========================================================

; Errors and Logs
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
display_errors = Off
log_errors = On
display_errors = Off ; CRITICAL: Never show errors to the public
log_errors = On ; CRITICAL: Always log errors to the specified path
error_log = /var/log/php_errors.log

; Files & Uploads

; =========================================================
; 3. UPLOADS & FILES
; =========================================================

post_max_size = 16M
upload_max_filesize = 16M
max_file_uploads = 20

; Security

; =========================================================
; 4. SECURITY & SESSIONS
; =========================================================

; Ensures cookies are only sent over HTTPS
session.cookie_secure = 1
session.use_strict_mode = 1
session.use_only_cookies = 1
session.cookie_secure = 1


; =========================================================
; 5. OPCACHE (PERFORMANCE)
; =========================================================

opcache.enable = 1
opcache.enable_cli = 1
; The amount of memory to use for the opcode cache. 256MB is a good starting point.
opcache.memory_consumption = 256
; How often to check the timestamp of the PHP files for updates (0 = never check, ideal for immutable containers)
opcache.validate_timestamps = 0
; Cache the compiled PHP files even after the PHP-FPM process restarts.
opcache.interned_strings_buffer = 16
53 changes: 44 additions & 9 deletions docker/containers/php/config/php-test.ini
Original file line number Diff line number Diff line change
@@ -1,21 +1,56 @@
;
; Custom PHP Settings
; Custom PHP Settings for Staging

; Maximum amount of memory a script may consume
memory_limit = 4096M
; =========================================================
; 1. RESOURCE MANAGEMENT
; =========================================================

; Maximum amount of memory a script may consume.
memory_limit = 256M

; Maximum execution time of each script, in seconds
max_execution_time = 60


; =========================================================
; 2. ERROR & LOGGING
; =========================================================

; Errors and Logs
error_reporting = E_ALL
display_errors = On
log_errors = On
display_errors = Off ; CRITICAL: Never show errors to the public
log_errors = On ; CRITICAL: Always log errors to the specified path
error_log = /var/log/php_errors.log

; Files & Uploads

; =========================================================
; 3. UPLOADS & FILES
; =========================================================

post_max_size = 16M
upload_max_filesize = 16M
max_file_uploads = 20

; Security

; =========================================================
; 4. SECURITY & SESSIONS
; =========================================================

; Ensures cookies are only sent over HTTPS
session.cookie_secure = 1
session.use_strict_mode = 1
session.use_only_cookies = 1
session.cookie_secure = 1


; =========================================================
; 5. OPCACHE (PERFORMANCE)
; =========================================================

; Opcache is the single most important performance setting for PHP
opcache.enable = 1
opcache.enable_cli = 1
; The amount of memory to use for the opcode cache. 256MB is a good starting point.
opcache.memory_consumption = 256
; How often to check the timestamp of the PHP files for updates (0 = never check, ideal for immutable containers)
opcache.validate_timestamps = 0
; Cache the compiled PHP files even after the PHP-FPM process restarts.
opcache.interned_strings_buffer = 16
Loading