「🏗️」 wip: mandatory finished need testing on real condition
This commit is contained in:
2
Makefile
2
Makefile
@ -56,6 +56,6 @@ clean-nginx:
|
||||
docker container rm inception-nginx
|
||||
docker image rm inception-nginx
|
||||
|
||||
re: clean all
|
||||
re: fclean all
|
||||
|
||||
.PHONY: cms-build db-build websrv-build clean-db clean-nginx
|
||||
|
@ -9,7 +9,6 @@ import (
|
||||
"os/exec"
|
||||
|
||||
"git.keyzox.me/42_adjoly/inception/internal/log"
|
||||
"git.keyzox.me/42_adjoly/inception/internal/pass"
|
||||
)
|
||||
|
||||
func makeFpmConf() {
|
||||
@ -49,25 +48,24 @@ func main() {
|
||||
|
||||
makeFpmConf()
|
||||
|
||||
_, err := os.ReadFile("/var/www/wordpress/wp-config.php")
|
||||
|
||||
dir, err := os.ReadDir("/docker-entrypoint.d")
|
||||
if err != nil {
|
||||
_log.Log("note", "Configuring wordpress...")
|
||||
content, err := os.ReadFile("/var/www/wordpress/wp-config-docker.php")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
res := bytes.Replace([]byte(content), []byte("put your unique phrase here"), []byte(pass.GenStrPass(32)), -1)
|
||||
if err := os.WriteFile("/var/www/wordpress/wp-config.php", res, 0660); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
cmd := exec.Command("chown", "www-data:www-data", "/var/www/wordpress/wp-config.php")
|
||||
log.Fatal(err)
|
||||
}
|
||||
_log.Log("note", "Running entrypoint scripts...")
|
||||
for _, v := range dir {
|
||||
os.Chmod("/docker-entrypoint.d/" + v.Name(), 0755)
|
||||
cmd := exec.Command("/docker-entrypoint.d/" + v.Name())
|
||||
cmd.Env = os.Environ()
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
cmd.Stdin = os.Stdin
|
||||
if err := cmd.Run(); err != nil {
|
||||
log.Fatal(err)
|
||||
fmt.Printf("Error running script(%s): %v\n", v.Name(), err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
_log.Log("note", "Starting container")
|
||||
|
1
srcs/configs/wordpress/entry/configure-redis.sh
Executable file
1
srcs/configs/wordpress/entry/configure-redis.sh
Executable file
@ -0,0 +1 @@
|
||||
#!/bin/sh
|
14
srcs/configs/wordpress/entry/configure-wp.sh
Executable file
14
srcs/configs/wordpress/entry/configure-wp.sh
Executable file
@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
WP_DIR="/var/www/wordpress"
|
||||
|
||||
if [ -f "${WP_DIR}/wp-config.php" ]; then
|
||||
echo "Wordpress already configured, skipping installation"
|
||||
else
|
||||
echo "Confiruring wordpress..."
|
||||
sleep 1
|
||||
echo $TZ
|
||||
wp --allow-root core config --dbname=${WP_DB_NAME} --dbuser=${WP_DB_USER} --dbpass=${WP_DB_PASS} --dbhost=${WP_DB_HOST} --dbprefix=wp_ --path=${WP_DIR}
|
||||
wp --allow-root core install --url=https://${WP_URL} --title="${WP_TITLE}" --admin_user=${WP_ADMIN_USER} --admin_password=${WP_ADMIN_PASS} --admin_email=${WP_ADMIN_EMAIL} --path=${WP_DIR}
|
||||
wp option update blog_public ${WP_SEARCH_ENGINE_VISIBILITY} --allow-root
|
||||
fi
|
@ -45,21 +45,23 @@ services:
|
||||
db:
|
||||
condition: service_healthy
|
||||
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
|
||||
- WP_DB_NAME=knl
|
||||
- WP_DB_USER=kanel
|
||||
- WP_DB_PASS=alpine
|
||||
- WP_DB_HOST=db
|
||||
- WP_ADMIN_EMAIL=contact@kanel.ovh
|
||||
- WP_ADMIN_USER=kanel
|
||||
- WP_ADMIN_PASS=alpine
|
||||
- WP_URL=localhost:8443
|
||||
- WP_TITLE=Kanel Supremacy
|
||||
- WP_SEARCH_ENGINE_VISIBILITY=false
|
||||
- PHP_MEMORY_LIMIT="512M"
|
||||
- PHP_MAX_UPLOAD="50M"
|
||||
- PHP_PORT=9000
|
||||
- TZ=Europe/Paris
|
||||
volumes:
|
||||
- wp-site:/var/www/wordpress
|
||||
- ./configs/wordpress/entry:/docker-entrypoint.d
|
||||
restart: unless-stopped
|
||||
|
||||
db:
|
||||
|
@ -11,22 +11,33 @@ COPY go.mod /build/go.mod
|
||||
COPY cmd /build/cmd
|
||||
COPY internal /build/internal
|
||||
COPY docker/wordpress/www-docker.conf /www-docker.conf
|
||||
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 tzdata fcgi \
|
||||
php84-phar php84-xml php84-curl php84-zip \
|
||||
php84-intl php84-mbstring php84-iconv \
|
||||
php84 php84-mysqli php84-fpm php84-json \
|
||||
php84-zlib php84-session php84-dom \
|
||||
php84-xmlreader php84-pdo php84-gd \
|
||||
php84-opcache php84-ctype \
|
||||
&& cd /build \
|
||||
&& curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar \
|
||||
&& chmod +x wp-cli.phar \
|
||||
&& mv wp-cli.phar /usr/local/bin/wp \
|
||||
&& go build git.keyzox.me/42_adjoly/inception/cmd/wordpress/entrypoint \
|
||||
&& cp /build/entrypoint /docker-entrypoint \
|
||||
&& chmod +x /docker-entrypoint \
|
||||
&& apk del go \
|
||||
&& rm -Rf /build \
|
||||
&& mkdir -p /usr/src/wordpress
|
||||
&& mkdir /docker-entrypoint.d
|
||||
|
||||
RUN cp /usr/bin/php84 /usr/bin/php
|
||||
|
||||
VOLUME /var/www/wordpress
|
||||
VOLUME /docker-entrypoint.d
|
||||
|
||||
WORKDIR /var/www
|
||||
|
||||
RUN version='6.7.1' \
|
||||
RUN version='6.7.2' \
|
||||
&& curl -o wordpress.tar.gz -fL "https://wordpress.org/wordpress-$version.tar.gz" \
|
||||
&& apk del curl \
|
||||
&& rm -rf /var/cache/apk/* \
|
||||
|
@ -1,174 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* The base configuration for WordPress
|
||||
*
|
||||
* The wp-config.php creation script uses this file during the installation.
|
||||
* You don't have to use the website, you can copy this file to "wp-config.php"
|
||||
* and fill in the values.
|
||||
*
|
||||
* This file contains the following configurations:
|
||||
*
|
||||
* * Database settings
|
||||
* * Secret keys
|
||||
* * Database table prefix
|
||||
* * ABSPATH
|
||||
*
|
||||
* This has been slightly modified (to read environment variables) for use in Docker.
|
||||
*
|
||||
* @link https://developer.wordpress.org/advanced-administration/wordpress/wp-config/
|
||||
*
|
||||
* @package WordPress
|
||||
*/
|
||||
|
||||
// IMPORTANT: this file needs to stay in-sync with https://github.com/WordPress/WordPress/blob/master/wp-config-sample.php
|
||||
// (it gets parsed by the upstream wizard in https://github.com/WordPress/WordPress/blob/f27cb65e1ef25d11b535695a660e7282b98eb742/wp-admin/setup-config.php#L356-L392)
|
||||
|
||||
// a helper function to lookup "env_FILE", "env", then fallback
|
||||
if (!function_exists('getenv_docker')) {
|
||||
// https://github.com/docker-library/wordpress/issues/588 (WP-CLI will load this file 2x)
|
||||
function getenv_docker($env, $default) {
|
||||
if ($fileEnv = getenv($env . '_FILE')) {
|
||||
return rtrim(file_get_contents($fileEnv), "\r\n");
|
||||
}
|
||||
else if (($val = getenv($env)) !== false) {
|
||||
return $val;
|
||||
}
|
||||
else {
|
||||
return $default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ** Database settings - You can get this info from your web host ** //
|
||||
/** The name of the database for WordPress */
|
||||
define( 'DB_NAME', getenv_docker('WORDPRESS_DB_NAME', 'wordpress') );
|
||||
|
||||
/** Database username */
|
||||
define( 'DB_USER', getenv_docker('WORDPRESS_DB_USER', 'example username') );
|
||||
|
||||
/** Database password */
|
||||
define( 'DB_PASSWORD', getenv_docker('WORDPRESS_DB_PASSWORD', 'example password') );
|
||||
|
||||
/**
|
||||
* Docker image fallback values above are sourced from the official WordPress installation wizard:
|
||||
* https://github.com/WordPress/WordPress/blob/1356f6537220ffdc32b9dad2a6cdbe2d010b7a88/wp-admin/setup-config.php#L224-L238
|
||||
* (However, using "example username" and "example password" in your database is strongly discouraged. Please use strong, random credentials!)
|
||||
*/
|
||||
|
||||
/** Database hostname */
|
||||
define( 'DB_HOST', getenv_docker('WORDPRESS_DB_HOST', 'mysql') );
|
||||
|
||||
/** Database charset to use in creating database tables. */
|
||||
define( 'DB_CHARSET', getenv_docker('WORDPRESS_DB_CHARSET', 'utf8') );
|
||||
|
||||
/** The database collate type. Don't change this if in doubt. */
|
||||
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.
|
||||
*
|
||||
* Change these to different unique phrases! You can generate these using
|
||||
* the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}.
|
||||
*
|
||||
* You can change these at any point in time to invalidate all existing cookies.
|
||||
* This will force all users to have to log in again.
|
||||
*
|
||||
* @since 2.6.0
|
||||
*/
|
||||
define( 'AUTH_KEY', getenv_docker('WORDPRESS_AUTH_KEY', 'put your unique phrase here') );
|
||||
define( 'SECURE_AUTH_KEY', getenv_docker('WORDPRESS_SECURE_AUTH_KEY', 'put your unique phrase here') );
|
||||
define( 'LOGGED_IN_KEY', getenv_docker('WORDPRESS_LOGGED_IN_KEY', 'put your unique phrase here') );
|
||||
define( 'NONCE_KEY', getenv_docker('WORDPRESS_NONCE_KEY', 'put your unique phrase here') );
|
||||
define( 'AUTH_SALT', getenv_docker('WORDPRESS_AUTH_SALT', 'put your unique phrase here') );
|
||||
define( 'SECURE_AUTH_SALT', getenv_docker('WORDPRESS_SECURE_AUTH_SALT', 'put your unique phrase here') );
|
||||
define( 'LOGGED_IN_SALT', getenv_docker('WORDPRESS_LOGGED_IN_SALT', 'put your unique phrase here') );
|
||||
define( 'NONCE_SALT', getenv_docker('WORDPRESS_NONCE_SALT', 'put your unique phrase here') );
|
||||
// (See also https://wordpress.stackexchange.com/a/152905/199287)
|
||||
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* WordPress database table prefix.
|
||||
*
|
||||
* You can have multiple installations in one database if you give each
|
||||
* a unique prefix. Only numbers, letters, and underscores please!
|
||||
*
|
||||
* At the installation time, database tables are created with the specified prefix.
|
||||
* Changing this value after WordPress is installed will make your site think
|
||||
* it has not been installed.
|
||||
*
|
||||
* @link https://developer.wordpress.org/advanced-administration/wordpress/wp-config/#table-prefix
|
||||
*/
|
||||
$table_prefix = getenv_docker('WORDPRESS_TABLE_PREFIX', 'wp_');
|
||||
|
||||
/**
|
||||
* For developers: WordPress debugging mode.
|
||||
*
|
||||
* Change this to true to enable the display of notices during development.
|
||||
* It is strongly recommended that plugin and theme developers use WP_DEBUG
|
||||
* in their development environments.
|
||||
*
|
||||
* For information on other constants that can be used for debugging,
|
||||
* visit the documentation.
|
||||
*
|
||||
* @link https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/
|
||||
*/
|
||||
define( 'WP_DEBUG', !!getenv_docker('WORDPRESS_DEBUG', '') );
|
||||
|
||||
/* Add any custom values between this line and the "stop editing" line. */
|
||||
|
||||
// If we're behind a proxy server and using HTTPS, we need to alert WordPress of that fact
|
||||
// see also https://wordpress.org/support/article/administration-over-ssl/#using-a-reverse-proxy
|
||||
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false) {
|
||||
$_SERVER['HTTPS'] = 'on';
|
||||
}
|
||||
// (we include this by default because reverse proxying is extremely common in container environments)
|
||||
|
||||
if ($configExtra = getenv_docker('WORDPRESS_CONFIG_EXTRA', '')) {
|
||||
eval($configExtra);
|
||||
}
|
||||
|
||||
/* That's all, stop editing! Happy publishing. */
|
||||
|
||||
/** Absolute path to the WordPress directory. */
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
define( 'ABSPATH', __DIR__ . '/' );
|
||||
}
|
||||
|
||||
/** Sets up WordPress vars and included files. */
|
||||
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