Skip to content

Commit 48f65d4

Browse files
authored
PR #2 from psaux-it/prod
Prod
2 parents 244a483 + 05f93bb commit 48f65d4

File tree

8 files changed

+47
-8
lines changed

8 files changed

+47
-8
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export MYSQL_DATABASE=${WORDPRESS_DB_NAME}
1313
export MYSQL_USER=${WORDPRESS_DB_USER}
1414
export MYSQL_PASSWORD=${WORDPRESS_DB_PASSWORD}
1515
export MYSQL_ROOT_PASSWORD=rootpassword123!
16+
export NPP_MYSQL_CONF=./mysql/50-npp-server.cnf
1617

1718
# Nginx Settings
1819
export NGINX_CACHE=nginx_cache

docker-compose.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ services:
2020
- ${NPP_FPM_CONF}:/usr/local/etc/php-fpm.d/www.conf
2121
- ${FPM_DOCKER_CONF}:/usr/local/etc/php-fpm.d/zz-docker.conf
2222
- ${NPP_PHP_CONF}:/usr/local/etc/php/conf.d/npp.ini
23+
- /etc/localtime:/etc/localtime:ro
24+
- /etc/timezone:/etc/timezone:ro
2325
environment:
2426
- WORDPRESS_DB_HOST=${WORDPRESS_DB_HOST}
2527
- WORDPRESS_DB_USER=${WORDPRESS_DB_USER}
@@ -68,8 +70,16 @@ services:
6870
env_file:
6971
- .env
7072
restart: unless-stopped
73+
cap_add:
74+
- SYS_NICE
75+
security_opt:
76+
- apparmor:unconfined
77+
- seccomp:unconfined
7178
volumes:
7279
- ${MYSQL_HOME}:/var/lib/mysql
80+
- ${NPP_MYSQL_CONF}:/etc/mysql/conf.d/50-npp-server.cnf
81+
- /etc/localtime:/etc/localtime:ro
82+
- /etc/timezone:/etc/timezone:ro
7383
environment:
7484
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
7585
- MYSQL_DATABASE=${MYSQL_DATABASE}
@@ -100,6 +110,8 @@ services:
100110
- ${NPP_NGINX_CONF}:/etc/nginx/conf.d/npp.conf
101111
- ${NPP_NGINX_PARAMS_CONF}:/etc/nginx/fastcgi_params
102112
- ${NGINX_SSL_CERTS}:/etc/ssl:ro
113+
- /etc/localtime:/etc/localtime:ro
114+
- /etc/timezone:/etc/timezone:ro
103115
environment:
104116
- NPP_WEB_ROOT=${NPP_WEB_ROOT_}
105117
- NPP_USER=${NPP_USER_}

fpm/www.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ pm.max_spare_servers = 4
1111
pm.max_requests = 750
1212
rlimit_files = 131072
1313
rlimit_core = unlimited
14+
listen.backlog = 65535
1415
php_admin_value[memory_limit] = 512M

mysql/50-npp-server.cnf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[mysqld]
2+
character-set-server = utf8mb4 # UTF-8 character set
3+
skip-external-locking # Skip external locking for speed
4+
skip-log-bin # Disable binary logging
5+
wait_timeout = 1800 # Timeout for inactive connections (30 min)
6+
max_allowed_packet = 128M # Max packet size for queries
7+
innodb_flush_log_at_trx_commit = 2 # InnoDB log flush for performance
8+
innodb_dedicated_server = ON # Enable InnoDB optimizations
9+
innodb_log_buffer_size = 32M # InnoDB log buffer size
10+
max_connections = 100 # Max allowed connections
11+
tmp_table_size = 32M # Max temp table size in memory
12+
max_heap_table_size = 32M # Max in-memory heap table size

mysql/entrypoint-sql.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,10 @@ COLOR_WHITE='\033[0;97m'
3535
COLOR_BLACK='\033[0;30m'
3636
COLOR_LIGHT_CYAN='\033[0;96m'
3737

38+
# Fix permissions for consistency
39+
chown -R root:root /etc/mysql/conf.d &&
40+
echo -e "${COLOR_GREEN}${COLOR_BOLD}NPP-DB:${COLOR_RESET} Permissions fixed successfully!" ||
41+
echo -e "${COLOR_RED}${COLOR_BOLD}NPP-DB:${COLOR_RESET} Failed to fix permissions!"
42+
3843
# Start mysqld
39-
exec /usr/local/bin/docker-entrypoint.sh "$@" >/dev/null 2>&1
44+
exec /usr/local/bin/docker-entrypoint.sh "$@"

nginx/entrypoint-nginx.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ else
9090
echo -e "${COLOR_GREEN}${COLOR_BOLD}NPP-NGINX:${COLOR_RESET} User ${COLOR_LIGHT_CYAN}${NGINX_WEB_USER}${COLOR_RESET} is already in group ${COLOR_LIGHT_CYAN}${NPP_USER}${COLOR_RESET} Skipping.."
9191
fi
9292

93+
# Fix permissions for consistency
94+
chown -R root:root /etc/nginx &&
95+
echo -e "${COLOR_GREEN}${COLOR_BOLD}NPP-NGINX:${COLOR_RESET} Permissions fixed successfully!" ||
96+
echo -e "${COLOR_RED}${COLOR_BOLD}NPP-NGINX:${COLOR_RESET} Failed to fix permissions!"
97+
9398
sleep 3
9499

95100
# Congratulatory Header
@@ -118,4 +123,4 @@ echo -e "\n${COLOR_YELLOW}━━━━━━━━━━━━━━━━━━
118123
echo -e "\n${COLOR_RED}${COLOR_BOLD}☪︎${COLOR_RESET} ${COLOR_GREEN}${COLOR_BOLD}NE MUTLU TÜRK'ÜM DİYENE!${COLOR_RESET}"
119124

120125
# Start nginx
121-
exec /docker-entrypoint.sh "$@" >/dev/null 2>&1
126+
exec /docker-entrypoint.sh "$@"

nginx/npp.conf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ server {
2323
root /var/www/html;
2424
index index.php index.html index.htm;
2525

26-
# Logging
27-
##########
28-
access_log /var/log/nginx/npp.com.access.log;
29-
error_log /var/log/nginx/npp.com.error.log;
30-
3126
# Cache Settings
3227
#################
3328
set $skip_cache 0;

wordpress/entrypoint-wp.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ fi
8484
# Log that the bindfs mount was successful
8585
echo -e "${COLOR_GREEN}${COLOR_BOLD}NPP-WP:${COLOR_RESET} The Nginx Cache Path: ${COLOR_LIGHT_CYAN}${NPP_NGINX_CACHE_PATH}${COLOR_RESET} has been successfully mounted to ${COLOR_LIGHT_CYAN}${MOUNT_DIR}${COLOR_RESET} with ${COLOR_CYAN}UID:${NPP_UID}${COLOR_RESET} and ${COLOR_CYAN}GID:${NPP_GID}${COLOR_RESET}."
8686

87+
# Fix permissions for consistency
88+
chown -R root:root \
89+
/etc/nginx \
90+
/usr/local/etc/php-fpm.d \
91+
/usr/local/etc/php/conf.d &&
92+
echo -e "${COLOR_GREEN}${COLOR_BOLD}NPP-WP:${COLOR_RESET} Permissions fixed successfully!" ||
93+
echo -e "${COLOR_RED}${COLOR_BOLD}NPP-WP:${COLOR_RESET} Failed to fix permissions!"
94+
8795
# Wait for the 'wordpress-db' to be ready
8896
until mysql -h wordpress-db -u"${WORDPRESS_DB_USER}" -p"${WORDPRESS_DB_PASSWORD}" "${WORDPRESS_DB_NAME}" -e "SELECT 1" > /dev/null 2>&1; do
8997
echo -e "${COLOR_YELLOW}${COLOR_BOLD}NPP-WP:${COLOR_RESET} The ${COLOR_LIGHT_CYAN}MySQL database${COLOR_RESET} is not available yet. Retrying..."
@@ -92,4 +100,4 @@ done
92100
echo -e "${COLOR_GREEN}${COLOR_BOLD}NPP-WP:${COLOR_RESET} The ${COLOR_LIGHT_CYAN}MySQL database${COLOR_RESET} is ready! Proceeding..."
93101

94102
# Start php-fpm
95-
exec /usr/local/bin/docker-entrypoint.sh "$@" >/dev/null 2>&1
103+
exec /usr/local/bin/docker-entrypoint.sh "$@"

0 commit comments

Comments
 (0)