Browse Source

wordpress container to be continued

main
pvincent 3 weeks ago
parent
commit
6534e1184b
  1. 20
      .vscode/settings.json
  2. 95
      recipes/wordpress.container
  3. 54
      tools/miaou-recipe

20
.vscode/settings.json

@ -6,5 +6,23 @@
"editor.defaultFormatter": "mads-hartmann.bash-ide-vscode",
"bashIde.shfmt.binaryNextLine": true,
"bashIde.shfmt.languageDialect": "bash",
"bashIde.shfmt.spaceRedirects": true
"bashIde.shfmt.spaceRedirects": true,
"files.associations": {
"*.container": "shellscript"
},
"todohighlight.include": [
"**/*.js",
"**/*.jsx",
"**/*.ts",
"**/*.tsx",
"**/*.html",
"**/*.css",
"**/*.scss",
"**/*.php",
"**/*.rb",
"**/*.txt",
"**/*.mdown",
"**/*.md",
"**/*.container"
]
}

95
recipes/wordpress.container

@ -0,0 +1,95 @@
#!/usr/bin/env miaou-recipe
# CONSTANTS
FORCE=${FORCE:-false}
PHP_VERSION=8.4
UPLOAD_MAX_SIZE=2G
WORDPRESS_NAME=reunionbenevolat #TODO: to be personalized
# FUNCTIONS
function install_mariadb {
if $FORCE || ! systemctl is-active mariadb.service --quiet; then
# debconf-set-selections <<EOF
# postfix postfix/mailname string $(hostname -f)
# postfix postfix/main_mailer_type string 'Internet Site'
# postfix postfix/mynetworks string '127.0.0.0/8'
# EOF
DEBIAN_FRONTEND=noninteractive apt-get install -y mariadb-server
echo mariadb installed successfully!
else
echo mariadb already installed!
fi
}
function install_php {
local php_service="php$PHP_VERSION-fpm"
if $FORCE || ! systemctl is-active "$php_service" --quiet; then
apt-get install -y php-fpm php-mysql php-curl php-dom php-imagick php-mbstring php-zip php-gd php-intl
sed -i "s/^post_max_size = 8M/post_max_size = $UPLOAD_MAX_SIZE/g" /etc/php/8.4/fpm/php.ini
sed -i "s/^upload_max_filesize = 2M/upload_max_filesize = $UPLOAD_MAX_SIZE/g" /etc/php/8.4/fpm/php.ini
systemctl enable "$php_service" --now
echo "$php_service installed successfully!"
else
echo "$php_service already installed!"
fi
}
function install_nginx_host {
if $FORCE || [[ ! -f /etc/nginx/sites-available/sympa.conf ]]; then
cat << EOF > /etc/nginx/sites-available/sympa.conf
server {
listen {{ env.APP_PORT }} default_server;
access_log /var/log/nginx/{{ env.APP_NAME }}/wp-access.log;
error_log /var/log/nginx/{{ env.APP_NAME }}/wp-error.log;
client_max_body_size 50M;
root /var/www/wordpress/{{ env.APP_NAME }};
index index.php index.html index.htm;
charset UTF-8;
location / {
try_files $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php-fpm.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
location ~* \.(js|css|png|jpg|jpeg|svg|gif|ico|eot|otf|ttf|woff|woff2|mp3|wav|ogg)$ {
add_header Access-Control-Allow-Origin *;
access_log off; log_not_found off; expires 30d;
}
# Mailpoet - tinyMCE quick fix
location ~ /wp-content/plugins/wysija-newsletters/js/tinymce/.*\.(htm|html)$ {
add_header Access-Control-Allow-Origin *;
access_log off; log_not_found off; expires 30d;
}
location = /robots.txt { access_log off; log_not_found off; }
location ~ /\. { deny all; access_log off; log_not_found off; }
}
EOF
cd /etc/nginx/sites-enabled && rm -f default && ln -sf ../sites-available/sympa.conf && cd
systemctl reload nginx
echo host for nginx installed successfully!
else
echo host for nginx already installed!
fi
}
# MAIN
install_mariadb
install_php
# install_wordpress
# install_nginx_host

54
tools/miaou-recipe

@ -11,43 +11,43 @@ FORCE=${FORCE:-false}
# FUNCTIONS
function usage {
echo "$(basename "$0") {CONTAINER_NAME} {PATH_TO_SCRIPT} [[--debug|-d]]"
echo "$(basename "$0") {CONTAINER_NAME} {PATH_TO_SCRIPT} [[--debug|-d]]"
}
function parse_options {
while [[ $# -gt 0 ]]; do
case "$1" in
--help | -h)
usage && exit 0
;;
--debug | -d)
DEBUG=true
;;
*)
if [[ -z $CONTAINER ]]; then
CONTAINER=$1
elif [[ -z $SCRIPT ]]; then
SCRIPT=$1
else
echo >&2 "Unknown option: $1" && usage && exit 2
fi
;;
esac
shift 1 # Move to the next argument
done
[[ -n $CONTAINER ]] && [[ -n $SCRIPT ]] || (usage && exit 1)
while [[ $# -gt 0 ]]; do
case "$1" in
--help | -h)
usage && exit 0
;;
--debug | -d)
DEBUG=true
;;
*)
if [[ -z $CONTAINER ]]; then
CONTAINER=$1
elif [[ -z $SCRIPT ]]; then
SCRIPT=$1
else
echo >&2 "Unknown option: $1" && usage && exit 2
fi
;;
esac
shift 1 # Move to the next argument
done
[[ -n $CONTAINER ]] && [[ -n $SCRIPT ]] || (usage && exit 1)
}
function debug_option {
[[ $DEBUG == 'true' ]] && echo "-x" || true
[[ $DEBUG == 'true' ]] && echo "-x" || true
}
function recipe {
[[ ! -f $SCRIPT ]] && echo >&2 "Script not found: $SCRIPT" && exit 3
[[ ! -f $SCRIPT ]] && echo >&2 "Script not found: $SCRIPT" && exit 3
# hot changes
cat "$SCRIPT" | incus exec "$CONTAINER" -- env FORCE="$FORCE" bash $(debug_option)
# hot changes
cat "$SCRIPT" | incus exec "$CONTAINER" -- env FORCE="$FORCE" bash $(debug_option)
}

Loading…
Cancel
Save