Skip to content

Commit f64a1a6

Browse files
authored
feat: update Docker environment variables for database configuration (#158)
* feat: update Docker environment variables for database configuration * fix: add check for password key in user login action to prevent undefined index error * feat: add maintenance service configuration to Docker Compose * feat: add maintenance mode HTML page and update Docker Compose configuration for nginx * fix: rename maintenance service to acore-cms-maintenance in Docker Compose * feat: configure maintenance mode in nginx and update Docker Compose for acore-cms-maintenance service * feat: add maintenance mode configuration and HTML page for nginx
1 parent fb40ae0 commit f64a1a6

File tree

5 files changed

+107
-8
lines changed

5 files changed

+107
-8
lines changed

.env.docker

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
# DOCKER_WORDPRESS_ADMIN_PASSWORD=admin
1818
1919

20+
# DOCKER_WORDPRESS_DB_ROOT_PASSWORD=flkdsjalfh
21+
# DOCKER_WORDPRESS_DB_NAME=wordpress
22+
# DOCKER_WORDPRESS_DB_USER=wordpress
23+
# DOCKER_WORDPRESS_DB_PASSWORD=wordpress
24+
2025
# DOCKER_AC_NETWORK_EXTERNAL=true
2126

2227
# DOCKER_WORDPRESS_MULTISITE=true
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
server {
2+
listen 80;
3+
server_name _;
4+
5+
return 301 https://$host$request_uri;
6+
}
7+
8+
server {
9+
listen 443 ssl;
10+
server_name _;
11+
12+
ssl_certificate /etc/nginx/certs/cert.crt;
13+
ssl_certificate_key /etc/nginx/certs/cert.key;
14+
15+
root /var/www/html;
16+
index index.html;
17+
18+
location / {
19+
try_files /index.html =503;
20+
}
21+
22+
error_page 503 @maintenance;
23+
location @maintenance {
24+
root /var/www/html;
25+
rewrite ^ /index.html break;
26+
}
27+
28+
# Optional: Disable access logs for less noise
29+
access_log off;
30+
error_log /var/log/nginx/maintenance_error.log warn;
31+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Maintenance - AzerothCore CMS</title>
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
<style>
8+
body {
9+
background: #181c23;
10+
color: #f5f5f5;
11+
font-family: 'Segoe UI', Arial, sans-serif;
12+
display: flex;
13+
flex-direction: column;
14+
align-items: center;
15+
justify-content: center;
16+
height: 100vh;
17+
margin: 0;
18+
}
19+
.container {
20+
background: #23272f;
21+
padding: 2rem 3rem;
22+
border-radius: 12px;
23+
box-shadow: 0 4px 24px rgba(0,0,0,0.3);
24+
text-align: center;
25+
}
26+
.logo {
27+
width: 80px;
28+
margin-bottom: 1rem;
29+
}
30+
h1 {
31+
margin: 0.5rem 0;
32+
font-size: 2rem;
33+
color: #ffd700;
34+
}
35+
p {
36+
color: #b0b8c1;
37+
margin-bottom: 0;
38+
}
39+
</style>
40+
</head>
41+
<body>
42+
<div class="container">
43+
<img class="logo" src="https://azerothcore.org/images/logo.png" alt="AzerothCore Logo">
44+
<h1>Maintenance Mode</h1>
45+
<p>The AzerothCore CMS is currently undergoing scheduled maintenance.<br>
46+
Please check back soon. Thank you for your patience!</p>
47+
</div>
48+
</body>
49+
</html>

docker-compose.yml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ services:
1515
- .env.docker
1616
environment:
1717
DOCKER_CONTAINER: 1
18-
MYSQL_ROOT_PASSWORD: flkdsjalfh
19-
MYSQL_DATABASE: wordpress
20-
MYSQL_USER: wordpress
21-
MYSQL_PASSWORD: wordpress
18+
MYSQL_ROOT_PASSWORD: ${DOCKER_WORDPRESS_DB_ROOT_PASSWORD:-flkdsjalfh}
19+
MYSQL_DATABASE: ${DOCKER_WORDPRESS_DB_NAME:-wordpress}
20+
MYSQL_USER: ${DOCKER_WORDPRESS_DB_USER:-wordpress}
21+
MYSQL_PASSWORD: ${DOCKER_WORDPRESS_DB_PASSWORD:-wordpress}
2222
networks:
2323
- local-private-net
2424
- ac-network
@@ -66,8 +66,8 @@ services:
6666
WORDPRESS_ADMIN_PASSWORD: ${DOCKER_WORDPRESS_ADMIN_PASSWORD:-admin}
6767
WORDPRESS_ADMIN_EMAIL: ${DOCKER_WORDPRESS_ADMIN_EMAIL:[email protected]}
6868
WORDPRESS_DB_HOST: wp-db:3306
69-
WORDPRESS_DB_USER: wordpress
70-
WORDPRESS_DB_PASSWORD: wordpress
69+
WORDPRESS_DB_USER: ${DOCKER_WORDPRESS_DB_USER:-wordpress}
70+
WORDPRESS_DB_PASSWORD: ${DOCKER_WORDPRESS_DB_PASSWORD:-wordpress}
7171
PHP_OPCACHE_VALIDATE_TIMESTAMPS: 1
7272
_OPCACHE_MAX_ACCELERATED_FILES: 100000
7373
PHP_OPCACHE_MEMORY_CONSUMPTION: 64
@@ -123,6 +123,19 @@ services:
123123
- local-private-net
124124
expose:
125125
- "6379"
126+
acore-cms-maintenance:
127+
image: nginx
128+
environment:
129+
DOCKER_CONTAINER: 1
130+
MAINTENANCE_MODE: "true"
131+
volumes:
132+
- ${DOCKER_CONF_CERTS_PATH:-./conf/dist/certs/}:/etc/nginx/certs/
133+
- ${DOCKER_CONF_NGINX_MAINTENANCE_CONF:-./conf/dist/maintenance/conf}:/etc/nginx/conf.d/
134+
- ${DOCKER_CONF_NGINX_MAINTENANCE_HTML:-./conf/dist/maintenance/html}:/var/www/html
135+
ports:
136+
- ${DOCKER_HTTP_PORTS:-80:80}
137+
- ${DOCKER_HTTPS_PORTS:-443:443}
138+
profiles: [maintenance]
126139

127140
networks:
128141
local-shared-net:

src/acore-wp-plugin/src/Hooks/User/User.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,11 @@ function create_account_if_not_exists($user, $password): void
203203
// If login but game account doesn't exist
204204
// then create it
205205
add_action('wp_login', function ($user_login, $user) {
206-
create_account_if_not_exists($user, $_POST['pwd']);
206+
if (key_exists('pwd', $_POST)) {
207+
create_account_if_not_exists($user, $_POST['pwd']);
208+
}
207209
}, 10, 2);
208210

209-
210211
// if login, but exist only game account, then create wordpress account
211212
add_action('wp_authenticate', function ($username, $password) {
212213
if (!empty($username) && !empty($password)) {

0 commit comments

Comments
 (0)