Skip to content

Commit e5a3e1f

Browse files
authored
PR #4 from psaux-it/minor
minor
2 parents 8d22726 + a81e745 commit e5a3e1f

File tree

5 files changed

+77
-13
lines changed

5 files changed

+77
-13
lines changed

.env

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ export NGINX_CONF=./nginx/nginx.conf
2121
export NPP_NGINX_CONF=./nginx/npp.conf
2222
export NPP_NGINX_PARAMS_CONF=./nginx/fastcgi_params
2323
export NGINX_LOGS=./logs/nginx
24+
export NPP_NGINX_IP=172.19.0.3
2425

2526
# WP-CLI Settings
26-
export WORDPRESS_SITE_URL_=https://172.19.0.3
27+
export WORDPRESS_SITE_URL_="https://${NPP_NGINX_IP}"
2728
export WORDPRESS_SITE_TITLE_="NPP Dockerized"
2829
export WORDPRESS_ADMIN_USER_=npp
2930
export WORDPRESS_ADMIN_PASSWORD_=npp

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,24 @@ Explore the **[NPP Main GitHub Repository](https://github.com/psaux-it/nginx-fas
1414
- ✅ Isolated and secure **PHP process owner** for enhanced security and performance
1515
- ✅ Built with **bindfs** (1.17.7) + **fuse3** (1.16.2) for FUSE-based mounting of **Nginx Cache Path**
1616
- ✅ Supports a wide range of **PHP extensions**
17+
- ✅ Easily switch between the **stable** release and the **bleeding-edge dev** version of the **NPP**
1718
- ✅ All containers powered by **Debian 12** for a stable, consistent environment
1819

1920
## 🔑 Environment Variables
2021

2122
Please check the **.env** file for the environment variables used by the project.
2223

23-
Some variables can be directly modified by the user to customize the setup, while others are integral to the project's core configuration. Changing these core variables may require some work to adjust other parts of the project to maintain proper integration and workflow.
24+
Some variables can be directly modified by the user to customize the setup easily, while others are hard depend to the project's core configuration. Modifying these core variables for a production environment may require adjustments in other parts of the project to ensure proper integration and workflow. Feel free to customize it to meet your full-stack WordPress **production** needs!
2425

25-
Enjoy customizing it to suit your needs!
26+
#### Use the Bleeding-Edge Version of NPP or Contribute to Development
27+
28+
If you want to use the **latest bleeding-edge version** of the NPP plugin or set up a **development/test environment**, simply set the following environment variable:
29+
30+
```bash
31+
NPP_DEV_ENABLED=1
32+
```
33+
34+
🔄 This will sync the plugin with the latest development branch commit from GitHub, ensuring you always have access to the newest features and improvements.
2635

2736
## ⚙️️ Setup Instructions
2837

docker-compose.yml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ services:
3030
- WORDPRESS_CONFIG_EXTRA=
3131
define('FORCE_SSL_ADMIN', true);
3232
define('FORCE_SSL_LOGIN', true);
33-
if (defined('WP_CLI') && WP_CLI && !isset($$_SERVER['HTTP_HOST'])) $$_SERVER['HTTP_HOST'] = "172.19.0.3";
33+
if (defined('WP_CLI') && WP_CLI && !isset($$_SERVER['HTTP_HOST'])) $$_SERVER['HTTP_HOST'] = "${NPP_NGINX_IP}";
3434
- NPP_WEB_ROOT=${NPP_WEB_ROOT_}
3535
- NPP_NGINX_CACHE_PATH=${NPP_NGINX_CACHE_PATH_}
3636
- NPP_USER=${NPP_USER_}
@@ -66,6 +66,17 @@ services:
6666
- command: /scripts/wp-cli.sh
6767
working_dir: ${NPP_WEB_ROOT_}
6868
user: root
69+
mem_limit: "2GB"
70+
mem_reservation: "1GB"
71+
cpus: "1.0"
72+
deploy:
73+
resources:
74+
limits:
75+
cpus: "1.0"
76+
memory: "2GB"
77+
reservations:
78+
cpus: "1.0"
79+
memory: "1GB"
6980

7081
db:
7182
build:
@@ -94,6 +105,17 @@ services:
94105
networks:
95106
npp_network:
96107
ipv4_address: 172.19.0.2
108+
mem_limit: "2GB"
109+
mem_reservation: "1GB"
110+
cpus: "1.0"
111+
deploy:
112+
resources:
113+
limits:
114+
cpus: "1.0"
115+
memory: "2GB"
116+
reservations:
117+
cpus: "0.5"
118+
memory: "1GB"
97119

98120
nginx:
99121
build:
@@ -124,10 +146,22 @@ services:
124146
- NPP_UID=${NPP_UID_}
125147
- NPP_GID=${NPP_GID_}
126148
- NGINX_WEB_USER=${NGINX_WEB_USER_}
149+
- NPP_NGINX_IP=${NPP_NGINX_IP}
127150
- MOUNT_DIR=${MOUNT_DIR_}
128151
networks:
129152
npp_network:
130153
ipv4_address: 172.19.0.3
154+
mem_limit: "1.5GB"
155+
mem_reservation: "1GB"
156+
cpus: "1.0"
157+
deploy:
158+
resources:
159+
limits:
160+
cpus: "1"
161+
memory: "1.5GB"
162+
reservations:
163+
cpus: "0.5"
164+
memory: "1GB"
131165

132166
volumes:
133167
wordpress-db:

nginx/entrypoint-nginx.sh

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ wait_for_service "wordpress" 9001
6565
wait_for_service "wordpress" 9999
6666

6767
# Check if required environment variables are set
68-
for var in NPP_UID NPP_GID NPP_USER NPP_WEB_ROOT NGINX_WEB_USER MOUNT_DIR; do
68+
for var in NPP_UID NPP_GID NPP_USER NPP_WEB_ROOT NGINX_WEB_USER MOUNT_DIR NPP_NGINX_IP; do
6969
if [[ -z "${!var:-}" ]]; then
7070
echo -e "${COLOR_RED}${COLOR_BOLD}NPP-NGINX-FATAL:${COLOR_RESET} Missing required environment variable: ${COLOR_LIGHT_CYAN}${var}${COLOR_RESET} - ${COLOR_RED}Exiting...${COLOR_RESET}"
7171
exit 1
@@ -99,14 +99,14 @@ sleep 3
9999

100100
# Congratulatory Header
101101
echo -e "\n${COLOR_YELLOW}${COLOR_BOLD}🎉 CONGRATULATIONS! 🎉${COLOR_RESET}"
102-
echo -e "${COLOR_GREEN}${COLOR_BOLD}Your docker stack is ready, Unlocked Ultra-Performance with NPP Plugin${COLOR_RESET}"
102+
echo -e "${COLOR_GREEN}${COLOR_BOLD}Unlocked Ultra-Performance with NPP${COLOR_RESET}"
103103

104104
# Clean separator
105105
echo -e "\n${COLOR_YELLOW}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${COLOR_RESET}"
106106

107107
# URL Access Information
108-
echo -e "\n${COLOR_GREEN}${COLOR_BOLD}🔑 Access your WordPress admin page at:${COLOR_RESET}"
109-
echo -e "${COLOR_LIGHT_CYAN}URL: ${COLOR_RESET}${COLOR_BOLD}https://172.19.0.3/wp-admin${COLOR_RESET}"
108+
echo -e "\n${COLOR_GREEN}${COLOR_BOLD}🔑 Access WordPress:${COLOR_RESET}"
109+
echo -e "${COLOR_LIGHT_CYAN}URL: ${COLOR_RESET}${COLOR_BOLD}https://${NPP_NGINX_IP}/wp-admin${COLOR_RESET}"
110110

111111
# Separator for credentials
112112
echo -e "\n${COLOR_YELLOW}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${COLOR_RESET}"
@@ -123,11 +123,15 @@ echo -e "\n${COLOR_YELLOW}━━━━━━━━━━━━━━━━━━
123123
echo -e "\n${COLOR_GREEN}${COLOR_BOLD}💾 Nginx Cache Path:${COLOR_RESET}"
124124
echo -e "${COLOR_LIGHT_CYAN}Path: ${COLOR_RESET}${COLOR_BOLD}${MOUNT_DIR}${COLOR_RESET}"
125125

126-
# Final separator
126+
# Separator for author message
127127
echo -e "\n${COLOR_YELLOW}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${COLOR_RESET}"
128128

129-
# Author message
130-
echo -e "\n${COLOR_RED}${COLOR_BOLD}☪︎${COLOR_RESET} ${COLOR_GREEN}${COLOR_BOLD}NE MUTLU TÜRK'ÜM DİYENE!${COLOR_RESET}"
129+
# Universal Author messaege
130+
echo -e "\n${COLOR_RED}${COLOR_BOLD}☪︎${COLOR_RESET} ${COLOR_GREEN}${COLOR_BOLD}Author Message:${COLOR_RESET}"
131+
echo -e "${COLOR_LIGHT_CYAN}Message: ${COLOR_RESET}${COLOR_BOLD}1.f3 e5 2.g4 Qh4# ~checkmate${COLOR_RESET}"
132+
133+
# Final separator
134+
echo -e "\n${COLOR_YELLOW}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${COLOR_RESET}"
131135

132136
# Start nginx
133137
exec /docker-entrypoint.sh "$@"

wordpress/wp-cli.sh

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ if [[ "${#NPP_PLUGINS[@]}" -gt 0 ]]; then
165165
echo -e "${COLOR_RED}${COLOR_BOLD}NPP-WP-CLI:${COLOR_RESET} Plugin ${COLOR_CYAN}${plugin}${COLOR_RESET} installation failed. Please check the logs for more details."
166166
fi
167167
else
168-
echo -e "${COLOR_GREEN}${COLOR_BOLD}NPP-WP-CLI:${COLOR_RESET} Plugin ${COLOR_CYAN}${plugin}${COLOR_RESET} is already installed."
168+
echo -e "${COLOR_GREEN}${COLOR_BOLD}NPP-WP-CLI:${COLOR_RESET} Plugin ${COLOR_CYAN}${plugin}${COLOR_RESET} is already installed. Skipping..."
169169
fi
170170
done
171171
else
@@ -182,13 +182,26 @@ if [[ "${#NPP_THEMES[@]}" -gt 0 ]]; then
182182
echo -e "${COLOR_RED}${COLOR_BOLD}NPP-WP-CLI:${COLOR_RESET} Theme ${COLOR_CYAN}${theme}${COLOR_RESET} installation failed. Please check the logs for more details."
183183
fi
184184
else
185-
echo -e "${COLOR_GREEN}${COLOR_BOLD}NPP-WP-CLI:${COLOR_RESET} Theme ${COLOR_CYAN}${theme}${COLOR_RESET} is already installed."
185+
echo -e "${COLOR_GREEN}${COLOR_BOLD}NPP-WP-CLI:${COLOR_RESET} Theme ${COLOR_CYAN}${theme}${COLOR_RESET} is already installed. Skipping..."
186186
fi
187187
done
188188
else
189189
echo -e "${COLOR_YELLOW}${COLOR_BOLD}NPP-WP-CLI:${COLOR_RESET} ${COLOR_CYAN}No themes${COLOR_RESET} to install."
190190
fi
191191

192+
# Check if the current permalink structure is already set
193+
CURRENT_PERMALINK=$(su -m -c "wp option get permalink_structure" "${NPP_USER}")
194+
if [[ -z "$CURRENT_PERMALINK" || "$CURRENT_PERMALINK" == "/index.php/%pagename%/" ]]; then
195+
# Apply the new permalink structure
196+
if su -m -c "wp rewrite structure '/%postname%/' --hard" "${NPP_USER}" >/dev/null 2>&1; then
197+
echo -e "${COLOR_GREEN}${COLOR_BOLD}NPP-WP-CLI:${COLOR_RESET} ${COLOR_CYAN}Permalink structure${COLOR_RESET} has been successfully updated."
198+
else
199+
echo -e "${COLOR_RED}${COLOR_BOLD}NPP-WP-CLI:${COLOR_RESET} ${COLOR_CYAN}Failed to update${COLOR_RESET} permalink structure. Please check logs for more details."
200+
fi
201+
else
202+
echo -e "${COLOR_GREEN}${COLOR_BOLD}NPP-WP-CLI:${COLOR_RESET} ${COLOR_CYAN}Permalink structure${COLOR_RESET} is already properly set. Skipping..."
203+
fi
204+
192205
# Check development deploy wanted
193206
if [[ "${NPP_DEV_ENABLED}" -eq 1 ]]; then
194207
# Set variables
@@ -213,6 +226,7 @@ if [[ "${NPP_DEV_ENABLED}" -eq 1 ]]; then
213226
REMOTE_COMMIT_HASH=$(git ls-remote --heads "${GITHUB_REPO}" "refs/heads/${TARGET_BRANCH}" \
214227
| awk '{print substr($1,1,7)}' | awk '{$1=$1;print}')
215228

229+
echo -e "${COLOR_GREEN}${COLOR_BOLD}NPP-DEV:${COLOR_RESET} ${COLOR_LIGHT_CYAN}######################${COLOR_RESET}"
216230
echo -e "${COLOR_GREEN}${COLOR_BOLD}NPP-DEV:${COLOR_RESET} Latest branch: ${COLOR_CYAN}${TARGET_BRANCH}${COLOR_RESET}"
217231
echo -e "${COLOR_GREEN}${COLOR_BOLD}NPP-DEV:${COLOR_RESET} Latest dev version: ${COLOR_CYAN}${LATEST_VERSION}${COLOR_RESET}"
218232
echo -e "${COLOR_GREEN}${COLOR_BOLD}NPP-DEV:${COLOR_RESET} Remote commit: ${COLOR_CYAN}${REMOTE_COMMIT_HASH}${COLOR_RESET}"
@@ -299,8 +313,10 @@ if [[ "${NPP_DEV_ENABLED}" -eq 1 ]]; then
299313
# Adjust ownership (ensure NPP_USER is set in the environment)
300314
chown -R "${NPP_USER}":"${NPP_USER}" "${PLUGIN_DIR}"
301315
echo -e "${COLOR_GREEN}${COLOR_BOLD}NPP-DEV:${COLOR_RESET} Deployed build ${COLOR_CYAN}${TARGET_BRANCH}${COLOR_RESET} with (commit ${COLOR_CYAN}${CLONED_COMMIT_HASH}${COLOR_RESET})."
316+
echo -e "${COLOR_GREEN}${COLOR_BOLD}NPP-DEV:${COLOR_RESET} ${COLOR_LIGHT_CYAN}######################${COLOR_RESET}"
302317
else
303318
echo -e "${COLOR_GREEN}${COLOR_BOLD}NPP-DEV:${COLOR_RESET} Plugin is up-to-date with commit ${COLOR_CYAN}${REMOTE_COMMIT_HASH}${COLOR_RESET}."
319+
echo -e "${COLOR_GREEN}${COLOR_BOLD}NPP-DEV:${COLOR_RESET} ${COLOR_LIGHT_CYAN}######################${COLOR_RESET}"
304320
fi
305321
fi
306322

0 commit comments

Comments
 (0)