Skip to content

Commit

Permalink
Merge pull request #1 from afup/config_clever_cloud
Browse files Browse the repository at this point in the history
configuration pour déploiement sur clever cloud
  • Loading branch information
agallou authored Dec 29, 2021
2 parents 7907f39 + 3f5e378 commit eb45ffe
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 25 deletions.
18 changes: 18 additions & 0 deletions clevercloud/scripts/create_htpasswd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

if [[ -v HTPASSWD_USER && -v HTPASSWD_PASSWORD && -v HTACCESS_PATH ]]; then
HTPASSWD_PATH=${APP_HOME}/.htpasswd
cat <<EOT >> ${APP_HOME}/${HTACCESS_PATH}
<IfFile ${HTPASSWD_PATH}>
AuthType Basic
AuthName "internal"
AuthUserFile ${HTPASSWD_PATH}
Require valid-user
</IfFile>
EOT

htpasswd -s -b -c ${HTPASSWD_PATH} ${HTPASSWD_USER} ${HTPASSWD_PASSWORD}

fi


27 changes: 27 additions & 0 deletions clevercloud/scripts/reload_from_prod.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash -ex

if ! [[ -v FSBUCKET_PROD_HOST && -v FSBUCKET_PROD_USER && -v FSBUCKET_PROD_PASSWORD ]]; then
echo "Missing FSBUCKET env vars"
exit 2
fi

if ! [[ -v DB_PROD_HOST && -v DB_PROD_NAME && -v DB_PROD_USER && -v DB_PROD_PASSWORD && -v DB_PROD_PASSWORD ]]; then
echo "Missing DB env vars"
exit 2
fi


# On charge la base depuis celle de prod
mysqldump --column-statistics=0 --no-tablespaces --single-transaction -h $DB_PROD_HOST -P $DB_PROD_PORT -u $DB_PROD_USER -p$DB_PROD_PASSWORD $DB_PROD_NAME | mysql -h $MYSQL_ADDON_HOST -P $MYSQL_ADDON_PORT -u $MYSQL_ADDON_USER -p$MYSQL_ADDON_PASSWORD $MYSQL_ADDON_DB

# On modifie les urls pour les adapter à la préprod
mysql -h $MYSQL_ADDON_HOST -P $MYSQL_ADDON_PORT -u $MYSQL_ADDON_USER -p$MYSQL_ADDON_PASSWORD $MYSQL_ADDON_DB -e "UPDATE wp_2021_options SET option_value = replace(option_value, 'https://event.afup.org', 'https://event-preprod.afup.org') WHERE option_name = 'home' OR option_name = 'siteurl';"

mysql -h $MYSQL_ADDON_HOST -P $MYSQL_ADDON_PORT -u $MYSQL_ADDON_USER -p$MYSQL_ADDON_PASSWORD $MYSQL_ADDON_DB -e "UPDATE wp_2021_posts SET guid = REPLACE (guid, 'https://event.afup.org', 'https://event-preprod.afup.org');"
mysql -h $MYSQL_ADDON_HOST -P $MYSQL_ADDON_PORT -u $MYSQL_ADDON_USER -p$MYSQL_ADDON_PASSWORD $MYSQL_ADDON_DB -e "UPDATE wp_2021_posts SET guid = REPLACE (guid, 'http://event.afup.org', 'https://event-preprod.afup.org');"

mysql -h $MYSQL_ADDON_HOST -P $MYSQL_ADDON_PORT -u $MYSQL_ADDON_USER -p$MYSQL_ADDON_PASSWORD $MYSQL_ADDON_DB -e "UPDATE wp_2021_postmeta SET meta_value = REPLACE (meta_value, 'https://event.afup.org', 'https://event-preprod.afup.org') WHERE meta_key = '_menu_item_url' ;"

# On copie le bucket de prod vers le dossier de prod
lftp ftp://$FSBUCKET_PROD_USER:$FSBUCKET_PROD_PASSWORD@$FSBUCKET_PROD_HOST -e "mirror / $APP_HOME/resources/uploads/ ; quit"
#
4 changes: 2 additions & 2 deletions docker-compose.override.yml-dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ services:
- "9225:80"
environment:
AFUP_GLOBAL_MENU_PREFIX: 'https://localhost:9205'
AFUP_WEBSITE_URL: 'https://apachephp:80'

AFUP_WEBSITE_URL: 'https://172.17.0.1:9205'
AFUP_BLOG_API_KEY: '123456'
7 changes: 6 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ services:
uid: ${CURRENT_UID:-1001}
gid: "1001"
environment:
AFUP_WEBSITE_URL: 'https://apachephp:80'
MYSQL_ADDON_DB: event
MYSQL_ADDON_USER: afup
MYSQL_ADDON_PASSWORD: afup
MYSQL_ADDON_HOST: dbevent
MYSQL_ADDON_PORT: 3306
WP_DEBUG: 1
volumes:
- ./:/var/www/html
links:
Expand Down
57 changes: 35 additions & 22 deletions resources/config/wp-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@

// ** Réglages MySQL - Votre hébergeur doit vous fournir ces informations. ** //
/** Nom de la base de données de WordPress. */
define('DB_NAME', 'event');
define('DB_NAME', getenv('MYSQL_ADDON_DB'));

/** Utilisateur de la base de données MySQL. */
define('DB_USER', 'afup');
define('DB_USER', getenv('MYSQL_ADDON_USER'));

/** Mot de passe de la base de données MySQL. */
define('DB_PASSWORD', 'afup');
define('DB_PASSWORD', getenv('MYSQL_ADDON_PASSWORD'));

/** Adresse de l'hébergement MySQL. */
define('DB_HOST', 'dbevent');
define('DB_HOST', getenv('MYSQL_ADDON_HOST') . ':' . getenv('MYSQL_ADDON_PORT'));

/** Jeu de caractères à utiliser par la base de données lors de la création des tables. */
define('DB_CHARSET', 'utf8mb4');
Expand All @@ -42,46 +42,52 @@
* Clefs uniques d'authentification et salage.
*
* Remplacez les valeurs par défaut par des phrases uniques !
* Vous pouvez générer des phrases aléatoires en utilisant
* Vous pouvez générer des phrases aléatoires en utilisant
* {@link https://api.wordpress.org/secret-key/1.1/salt/ le service de clefs secrètes de WordPress.org}.
* Vous pouvez modifier ces phrases à n'importe quel moment, afin d'invalider tous les cookies existants.
* Cela forcera également tous les utilisateurs à se reconnecter.
*
* @since 2.6.0
*/
define('AUTH_KEY', 'xXp5lR3Pw.;Wc2,`&8.)$|8^*Z-Z6I<8z*!1+8TERo$UA9hg 7~I/%cxdXCNKA>6');
define('SECURE_AUTH_KEY', 'a|TULivMo#3*j[n+J9C?CMoRqLWg+y&XVI-kKvJK^-J MR{Wbr;FlBWyz!b{HxG[');
define('LOGGED_IN_KEY', 'UGiF=|)N|#x8S+pX&y-`=?Ok/KRJt}(aQ }OSH846;IM,5~Pd(Yy:i>JWVev~#/o');
define('NONCE_KEY', 'wI1?~(uW[kns(ifyrX$(^rnTX,EsBq0%crDCm?94lio6Bdj%nBw(i[U5-/$(.+sX');
define('AUTH_SALT', '[8N2^E?cK#{*u82h/*+hkf-)-@{E+z+5o%S/?p*?2]<P(^Kn=;+N-|4d-JjCOK14');
define('SECURE_AUTH_SALT', ')e*e^zYy,3-gA0#{knh{H7+1V$D)rmg()9!O2:Yiopm4qFQ6$}Ih/s8,Zjcac1L6');
define('LOGGED_IN_SALT', '&hcm.U;DIY|C4r`PGz=wcU86GW||EMD8v_-6qs1P88E:jKe=01yA9%S&y.Co+`W7');
define('NONCE_SALT', '&u_%N*/=lpw<0~]ktU|1$Sz#77,F!c_Cjx W]/OP<z.S+rFG?O5%dT+C)r/=_&f;');
define('AUTH_KEY', getenv('WP_AUTH_KEY'));
define('SECURE_AUTH_KEY', getenv('WP_SECURE_AUTH_KEY'));
define('LOGGED_IN_KEY', getenv('WP_LOGGED_IN_KEY'));
define('NONCE_KEY', getenv('WP_NONCE_KEY'));
define('AUTH_SALT', getenv('WP_AUTH_SALT'));
define('SECURE_AUTH_SALT', getenv('WP_SECURE_AUTH_SALT'));
define('LOGGED_IN_SALT', getenv('WP_LOGGED_IN_SALT'));
define('NONCE_SALT', getenv('WP_NONCE_SALT'));
/**#@-*/

/**
* Préfixe de base de données pour les tables de WordPress.
*
* Vous pouvez installer plusieurs WordPress sur une seule base de données
* si vous leur donnez chacune un préfixe unique.
* si vous leur donnez chacune un préfixe unique.
* N'utilisez que des chiffres, des lettres non-accentuées, et des caractères soulignés!
*/
$table_prefix = 'wp_';
$table_prefix = 'wp_2021_';

/**
/**
* Pour les développeurs : le mode deboguage de WordPress.
*
*
* En passant la valeur suivante à "true", vous activez l'affichage des
* notifications d'erreurs pendant votre essais.
* Il est fortemment recommandé que les développeurs d'extensions et
* de thèmes se servent de WP_DEBUG dans leur environnement de
* de thèmes se servent de WP_DEBUG dans leur environnement de
* développement.
*/
define('WP_DEBUG', true);
*/

$debug = false;
if (getenv('WP_DEBUG') == '1') {
$debug = true;
}

define('WP_DEBUG', $debug);

define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST']);
define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST']);

define('WP_SITEURL', 'https://' . $_SERVER['HTTP_HOST']);
define('WP_HOME', 'https://' . $_SERVER['HTTP_HOST']);


/* C'est tout, ne touchez pas à ce qui suit ! Bon blogging ! */
Expand All @@ -90,6 +96,13 @@
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');


if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
$_SERVER['HTTPS'] = 'on';
} elseif (isset($_SERVER['X_FORWARDED_PROTO']) && $_SERVER['X_FORWARDED_PROTO'] == 'https') {
$_SERVER['HTTPS'] = 'on';
}

/** Réglage des variables de WordPress et de ses fichiers inclus. */
require_once(ABSPATH . 'wp-settings.php');

Expand Down
7 changes: 7 additions & 0 deletions resources/themes/hestia-pro_child/page-curl.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
}

$afupBlogApiKey = getenv('AFUP_BLOG_API_KEY');
if ($afupBlogApiKey) {
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'X-Afup-Blog-Api-Key:' . $afupBlogApiKey,
));
}

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

if (defined('WP_DEBUG') && WP_DEBUG == true) {
Expand Down
2 changes: 2 additions & 0 deletions resources/web/.htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ RewriteRule . /index.php [L]
</IfModule>

# END WordPress


13 changes: 13 additions & 0 deletions src/ComposerScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ protected static function getDirWithContentToSymlink($baseDir, $wordpressDir)
];
}

protected static function getDirsToSymlink($baseDir, $wordpressDir)
{
return [
$baseDir . '/resources/uploads' => $wordpressDir . '/wp-content/uploads',
];
}

protected static function getPathsToDelete($wordpressDir)
{
return [
Expand Down Expand Up @@ -57,6 +64,12 @@ public static function createSymlinks(Event $event)
}
}

foreach (self::getDirsToSymlink($baseDir, $wordpressDir) as $sourceDirectory => $wordpressTarget) {
$event->getIO()->write($sourceDirectory . ' -> ' . $wordpressTarget);
$filesystem->remove($wordpressTarget);
$filesystem->symlink($sourceDirectory, $wordpressTarget);
}

foreach (self::getPathsToDelete($wordpressDir) as $pathToDelete) {
$event->getIO()->write('remove ' . $pathToDelete);
$filesystem->remove($pathToDelete);
Expand Down

0 comments on commit eb45ffe

Please sign in to comment.