「🏗️」 wip: wordpress nearly working need to fix title set and admin name and pass
This commit is contained in:
5
Makefile
5
Makefile
@ -33,10 +33,11 @@ stop:
|
|||||||
docker compose -f $(DOCKER_CONTEXT)docker-compose.yml stop
|
docker compose -f $(DOCKER_CONTEXT)docker-compose.yml stop
|
||||||
|
|
||||||
clean: stop
|
clean: stop
|
||||||
docker system prune
|
docker system prune -f
|
||||||
|
|
||||||
fclean: clean
|
fclean: clean
|
||||||
docker system prune -a
|
docker system prune -af
|
||||||
|
docker volume prune -af
|
||||||
|
|
||||||
clean-db:
|
clean-db:
|
||||||
docker stop inception-db
|
docker stop inception-db
|
||||||
|
@ -123,7 +123,7 @@ func configureMariaDB(rootPassword, user, password, database string) {
|
|||||||
CREATE DATABASE IF NOT EXISTS %s;
|
CREATE DATABASE IF NOT EXISTS %s;
|
||||||
CREATE USER IF NOT EXISTS '%s'@'%%';
|
CREATE USER IF NOT EXISTS '%s'@'%%';
|
||||||
GRANT ALL PRIVILEGES ON %s.* TO '%s'@'localhost' IDENTIFIED BY '%s';
|
GRANT ALL PRIVILEGES ON %s.* TO '%s'@'localhost' IDENTIFIED BY '%s';
|
||||||
GRANT ALL PRIVILEGES ON %s.* TO '%s'@'%%';
|
GRANT ALL PRIVILEGES ON %s.* TO '%s'@'%%' IDENTIFIED BY '%s';
|
||||||
FLUSH PRIVILEGES;
|
FLUSH PRIVILEGES;
|
||||||
`,
|
`,
|
||||||
env.EscapeEnv(rootPassword),
|
env.EscapeEnv(rootPassword),
|
||||||
@ -134,6 +134,7 @@ func configureMariaDB(rootPassword, user, password, database string) {
|
|||||||
env.EscapeEnv(password),
|
env.EscapeEnv(password),
|
||||||
env.EscapeEnv(database),
|
env.EscapeEnv(database),
|
||||||
env.EscapeEnv(user),
|
env.EscapeEnv(user),
|
||||||
|
env.EscapeEnv(password),
|
||||||
))
|
))
|
||||||
|
|
||||||
// Capture standard output and error
|
// Capture standard output and error
|
||||||
|
@ -49,25 +49,24 @@ func main() {
|
|||||||
|
|
||||||
makeFpmConf()
|
makeFpmConf()
|
||||||
|
|
||||||
_, err := os.ReadFile("/usr/src/wordpress/wp-config.php")
|
_, err := os.ReadFile("/var/www/wordpress/wp-config.php")
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_log.Log("note", "Configuring wordpress...")
|
_log.Log("note", "Configuring wordpress...")
|
||||||
content, err := os.ReadFile("/usr/src/wordpress/wp-config-docker.php")
|
content, err := os.ReadFile("/var/www/wordpress/wp-config-docker.php")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
res := bytes.Replace([]byte(content), []byte("put your unique phrase here"), []byte(pass.GenStrPass(32)), -1)
|
res := bytes.Replace([]byte(content), []byte("put your unique phrase here"), []byte(pass.GenStrPass(32)), -1)
|
||||||
if err := os.WriteFile("/usr/src/wordpress/wp-config.php", res, 0660); err != nil {
|
if err := os.WriteFile("/var/www/wordpress/wp-config.php", res, 0660); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
cmd := exec.Command("chown", "www-data:www-data", "/usr/src/wordpress/wp-config.php")
|
cmd := exec.Command("chown", "www-data:www-data", "/var/www/wordpress/wp-config.php")
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
if err := cmd.Run(); err != nil {
|
if err := cmd.Run(); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
_log.Log("note", "wp configured")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,6 +74,7 @@ func main() {
|
|||||||
cmd := exec.Command(args[1], args[2:]...)
|
cmd := exec.Command(args[1], args[2:]...)
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
|
cmd.Env = os.Environ()
|
||||||
cmd.Stdin = os.Stdin
|
cmd.Stdin = os.Stdin
|
||||||
if err := cmd.Run(); err != nil {
|
if err := cmd.Run(); err != nil {
|
||||||
fmt.Printf("Error running MariaDB: %v\n", err)
|
fmt.Printf("Error running MariaDB: %v\n", err)
|
||||||
|
26
srcs/configs/nginx/templates/testing.conf.template
Normal file
26
srcs/configs/nginx/templates/testing.conf.template
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
server {
|
||||||
|
listen 8443 ssl;
|
||||||
|
|
||||||
|
server_name _;
|
||||||
|
|
||||||
|
root /var/www/wordpress;
|
||||||
|
index index.php;
|
||||||
|
|
||||||
|
ssl_certificate $NGINX_SSL_CERT_FILE;
|
||||||
|
ssl_certificate_key $NGINX_SSL_KEY_FILE;
|
||||||
|
ssl_protocols TLSv1.2 TLSv1.3;
|
||||||
|
ssl_session_timeout 10m;
|
||||||
|
|
||||||
|
keepalive_timeout 60;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $${q}uri $${q}uri/ =404;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ \.php$ {
|
||||||
|
fastcgi_pass $NGINX_PHP_HOST:9000;
|
||||||
|
fastcgi_index index.php;
|
||||||
|
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||||
|
include fastcgi.conf;
|
||||||
|
}
|
||||||
|
}
|
@ -3,7 +3,7 @@ server {
|
|||||||
|
|
||||||
server_name adjoly.42.fr www.adjoly.42.fr;
|
server_name adjoly.42.fr www.adjoly.42.fr;
|
||||||
|
|
||||||
root /var/www/html;
|
root /var/www/wordpress;
|
||||||
index index.php;
|
index index.php;
|
||||||
|
|
||||||
ssl_certificate $NGINX_SSL_CERT_FILE;
|
ssl_certificate $NGINX_SSL_CERT_FILE;
|
||||||
|
@ -23,15 +23,15 @@ services:
|
|||||||
- NGINX_SSL_CERT_FILE=/etc/nginx/ssl/adjoly-wp.crt
|
- NGINX_SSL_CERT_FILE=/etc/nginx/ssl/adjoly-wp.crt
|
||||||
depends_on:
|
depends_on:
|
||||||
wordpress-php:
|
wordpress-php:
|
||||||
condition: service_started
|
condition: service_healthy
|
||||||
db:
|
db:
|
||||||
condition: service_started
|
condition: service_healthy
|
||||||
volumes:
|
volumes:
|
||||||
- wp-site:/var/www/html
|
- wp-site:/var/www/wordpress
|
||||||
- ./configs/nginx/templates:/etc/nginx/templates
|
- ./configs/nginx/templates:/etc/nginx/templates
|
||||||
- ./configs/nginx/entry:/docker-entrypoint.d
|
- ./configs/nginx/entry:/docker-entrypoint.d
|
||||||
ports:
|
ports:
|
||||||
- "443:443"
|
- "8443:8443"
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
wordpress-php:
|
wordpress-php:
|
||||||
@ -43,14 +43,23 @@ services:
|
|||||||
- inception
|
- inception
|
||||||
depends_on:
|
depends_on:
|
||||||
db:
|
db:
|
||||||
condition: service_started
|
condition: service_healthy
|
||||||
environment:
|
environment:
|
||||||
|
- WORDPRESS_DB_NAME=knl
|
||||||
|
- WORDPRESS_DB_USER=kanel
|
||||||
|
- WORDPRESS_DB_PASSWORD=alpine
|
||||||
|
- WORDPRESS_DB_HOST=db
|
||||||
|
- WORDPRESS_ADMIN_EMAIL=contact@kanel.ovh
|
||||||
|
- WORDPRESS_ADMIN_USER=kanel
|
||||||
|
- WORDPRESS_ADMIN_PASS=alpine
|
||||||
|
- WORDPRESS_SITE_TITLE='Kanel supremacy'
|
||||||
|
- WORDPRESS_SEARCH_ENGINE_VISIBILITY=false
|
||||||
- PHP_MEMORY_LIMIT="512M"
|
- PHP_MEMORY_LIMIT="512M"
|
||||||
- PHP_MAX_UPLOAD="50M"
|
- PHP_MAX_UPLOAD="50M"
|
||||||
- PHP_PORT=9000
|
- PHP_PORT=9000
|
||||||
- TZ=Europe/Paris
|
- TZ=Europe/Paris
|
||||||
volumes:
|
volumes:
|
||||||
- wp-site:/var/www/html
|
- wp-site:/var/www/wordpress
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
db:
|
db:
|
||||||
|
@ -11,7 +11,7 @@ COPY go.mod /build/go.mod
|
|||||||
COPY cmd /build/cmd
|
COPY cmd /build/cmd
|
||||||
COPY internal /build/internal
|
COPY internal /build/internal
|
||||||
COPY docker/wordpress/www-docker.conf /www-docker.conf
|
COPY docker/wordpress/www-docker.conf /www-docker.conf
|
||||||
COPY docker/wordpress/wp-config-docker.php /usr/src/wordpress/wp-config-docker.php
|
COPY docker/wordpress/wp-config-docker.php /var/www/wordpress/wp-config-docker.php
|
||||||
|
|
||||||
RUN apk add --no-cache go curl php84-mysqli php84-fpm tzdata fcgi \
|
RUN apk add --no-cache go curl php84-mysqli php84-fpm tzdata fcgi \
|
||||||
&& cd /build \
|
&& cd /build \
|
||||||
@ -22,9 +22,9 @@ RUN apk add --no-cache go curl php84-mysqli php84-fpm tzdata fcgi \
|
|||||||
&& rm -Rf /build \
|
&& rm -Rf /build \
|
||||||
&& mkdir -p /usr/src/wordpress
|
&& mkdir -p /usr/src/wordpress
|
||||||
|
|
||||||
VOLUME /usr/src/wordpress
|
VOLUME /var/www/wordpress
|
||||||
|
|
||||||
WORKDIR /usr/src
|
WORKDIR /var/www
|
||||||
|
|
||||||
RUN version='6.7.1' \
|
RUN version='6.7.1' \
|
||||||
&& curl -o wordpress.tar.gz -fL "https://wordpress.org/wordpress-$version.tar.gz" \
|
&& curl -o wordpress.tar.gz -fL "https://wordpress.org/wordpress-$version.tar.gz" \
|
||||||
@ -32,17 +32,17 @@ RUN version='6.7.1' \
|
|||||||
&& rm -rf /var/cache/apk/* \
|
&& rm -rf /var/cache/apk/* \
|
||||||
&& tar -xzvf wordpress.tar.gz \
|
&& tar -xzvf wordpress.tar.gz \
|
||||||
&& rm wordpress.tar.gz \
|
&& rm wordpress.tar.gz \
|
||||||
&& chown -R www-data:www-data /usr/src/wordpress \
|
&& chown -R www-data:www-data /var/www/wordpress \
|
||||||
&& mkdir wp-content \
|
&& mkdir wp-content \
|
||||||
&& for dir in /usr/src/wordpress/wp-content/*/ cache; do \
|
&& for dir in /var/www/wp-content/*/ cache; do \
|
||||||
dir="$(basename "${dir%/}")"; \
|
dir="$(basename "${dir%/}")"; \
|
||||||
mkdir "wp-content/$dir"; \
|
mkdir "wp-content/$dir"; \
|
||||||
done \
|
done \
|
||||||
&& chown -R www-data:www-data wp-content \
|
&& chown -R www-data:www-data /var/www/wordpress/wp-content \
|
||||||
&& chmod -R 1777 wp-content
|
&& chmod -R 1777 /var/www/wordpress/wp-content
|
||||||
|
|
||||||
ENTRYPOINT [ "/docker-entrypoint" ]
|
ENTRYPOINT [ "/docker-entrypoint" ]
|
||||||
WORKDIR /usr/src/wordpress
|
WORKDIR /var/www/wordpress
|
||||||
STOPSIGNAL SIGQUIT
|
STOPSIGNAL SIGQUIT
|
||||||
|
|
||||||
EXPOSE 9000
|
EXPOSE 9000
|
||||||
|
@ -64,6 +64,13 @@ define( 'DB_CHARSET', getenv_docker('WORDPRESS_DB_CHARSET', 'utf8') );
|
|||||||
/** The database collate type. Don't change this if in doubt. */
|
/** The database collate type. Don't change this if in doubt. */
|
||||||
define( 'DB_COLLATE', getenv_docker('WORDPRESS_DB_COLLATE', '') );
|
define( 'DB_COLLATE', getenv_docker('WORDPRESS_DB_COLLATE', '') );
|
||||||
|
|
||||||
|
/** Site url, user and pass */
|
||||||
|
define( 'WP_ADMIN_USER', getenv_docker('WORDPRESS_ADMIN_USER', 'admin'));
|
||||||
|
define( 'WP_ADMIN_PASS', getenv_docker('WORDPRESS_ADMIN_PASS', 'password123'));
|
||||||
|
define( 'WP_ADMIN_EMAIL', getenv_docker('WORDPRESS_ADMIN_EMAIL', 'admin@example.com'));
|
||||||
|
define( 'WP_SITE_TITLE', getenv_docker('WORDPRESS_SITE_TITLE', 'My WordPress Site'));
|
||||||
|
define( 'WP_SEARCH_ENGINE_VISIBILITY', getenv_docker('WORDPRESS_SEARCH_ENGINE_VISIBILITY', false));
|
||||||
|
|
||||||
/**#@+
|
/**#@+
|
||||||
* Authentication unique keys and salts.
|
* Authentication unique keys and salts.
|
||||||
*
|
*
|
||||||
@ -137,3 +144,31 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||||||
|
|
||||||
/** Sets up WordPress vars and included files. */
|
/** Sets up WordPress vars and included files. */
|
||||||
require_once ABSPATH . 'wp-settings.php';
|
require_once ABSPATH . 'wp-settings.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom script to set up admin user
|
||||||
|
*/
|
||||||
|
function setup_admin_user() {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
$user = WP_ADMIN_USER;
|
||||||
|
$pass = WP_ADMIN_PASS;
|
||||||
|
$email = WP_ADMIN_EMAIL;
|
||||||
|
|
||||||
|
if ( ! username_exists( $user ) && ! email_exists( $email ) ) {
|
||||||
|
$user_id = wp_create_user( $user, $pass, $email );
|
||||||
|
$user = new WP_User( $user_id );
|
||||||
|
$user->set_role( 'administrator' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
add_action( 'init', 'setup_admin_user' );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom script to set up search engine visibility
|
||||||
|
*/
|
||||||
|
function setup_search_engine_visibility() {
|
||||||
|
if ( get_option( 'blog_public' ) === '1' ) {
|
||||||
|
update_option( 'blog_public', !WP_SEARCH_ENGINE_VISIBILITY );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
add_action( 'init', 'setup_search_engine_visibility' );
|
||||||
|
Reference in New Issue
Block a user