From e71d5aa6d93a03bc4067ce19b4434c9b6550eae0 Mon Sep 17 00:00:00 2001 From: Gitouche <26656-gitouche@users.noreply.framagit.org> Date: Wed, 15 Nov 2023 20:33:24 +0100 Subject: [PATCH] Ajout wpamapsta --- podman-wpamapsta/05_freshinstall.sh | 24 +++++++++++++++ podman-wpamapsta/10_install.sh | 41 ++++++++++++++++++++++++++ podman-wpamapsta/20_enable.sh | 1 + podman-wpamapsta/30_start.sh | 1 + podman-wpamapsta/40_stop.sh | 1 + podman-wpamapsta/70_disable.sh | 1 + podman-wpamapsta/80_destroy.sh | 1 + podman-wpamapsta/90_prune.sh | 1 + podman-wpamapsta/ci_build-images.sh | 6 ++++ podman-wpamapsta/container-compose.yml | 35 ++++++++++++++++++++++ podman-wpamapsta/vars.sh | 18 +++++++++++ 11 files changed, 130 insertions(+) create mode 100755 podman-wpamapsta/05_freshinstall.sh create mode 100755 podman-wpamapsta/10_install.sh create mode 120000 podman-wpamapsta/20_enable.sh create mode 120000 podman-wpamapsta/30_start.sh create mode 120000 podman-wpamapsta/40_stop.sh create mode 120000 podman-wpamapsta/70_disable.sh create mode 120000 podman-wpamapsta/80_destroy.sh create mode 120000 podman-wpamapsta/90_prune.sh create mode 100644 podman-wpamapsta/ci_build-images.sh create mode 100644 podman-wpamapsta/container-compose.yml create mode 100644 podman-wpamapsta/vars.sh diff --git a/podman-wpamapsta/05_freshinstall.sh b/podman-wpamapsta/05_freshinstall.sh new file mode 100755 index 0000000..1a881fd --- /dev/null +++ b/podman-wpamapsta/05_freshinstall.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +ABSDIR="$( dirname "$(readlink -f -- "$0")" )" +source ${ABSDIR}/../functions.sh +source ${ABSDIR}/vars.sh + +ensure_pwd_is_scriptdir +ensure_not_root + +ensure_variables_are_defined "$envvars" + +for volume in ${dbvolume} ${wpvolume}; do + if podman volume exists ${volume} ; then + echo "Volume ${volume} from previous installation already exists" + echo "Please remove them before fresh install, or try to continue with normal installation" + exit 1 + fi +done + +podman volume create ${wpvolume} && \ +podman volume create ${dbvolume} && \ +podman unshare chown -R 999:999 `get_podman_volume_path ${dbvolume}` + +${ABSDIR}/10_install.sh diff --git a/podman-wpamapsta/10_install.sh b/podman-wpamapsta/10_install.sh new file mode 100755 index 0000000..26d1f51 --- /dev/null +++ b/podman-wpamapsta/10_install.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +ABSDIR="$( dirname "$(readlink -f -- "$0")" )" +source ${ABSDIR}/../functions.sh +source ${ABSDIR}/vars.sh + +ensure_pwd_is_scriptdir +ensure_not_root + +ensure_pod_not_exists ${pod_name} +ensure_variables_are_defined "$envvars" + +for volume in ${dbvolume} ${wpvolume}; do + if ! podman volume exists ${volume} ; then + echo "Error : conf volume ${volume} does not exists. Consider running 05_freshinstall.sh if this is the first install." + exit 1 + fi +done + +cat <> .env +MARIADB_PASSWORD=${GARBAYE_WPAMAPSTA_MYSQL_PASSWORD} +WORDPRESS_DB_PASSWORD=${GARBAYE_WPAMAPSTA_MYSQL_PASSWORD} + +EOT + +export wp_image +export wp_version +export mysql_image +export mysql_version +export listen_if +export listen_port + +if ! podman image exists ${wp_image}:${wp_version}; then + podman image pull ${wp_image}:${wp_version} || exit 1 +fi +podman image pull ${mysql_image}:${mysql_version} && + +podman-compose --pod-args="--infra=true --infra-name=${project_name}_infra --share=" --podman-run-args "--requires=${project_name}_infra --env-file .env" up -d && +sleep 10 # TODO : wait for healthckeck on mariadb +shred -u .env && +podman pod stop ${pod_name} diff --git a/podman-wpamapsta/20_enable.sh b/podman-wpamapsta/20_enable.sh new file mode 120000 index 0000000..ea522ac --- /dev/null +++ b/podman-wpamapsta/20_enable.sh @@ -0,0 +1 @@ +../_podman-common/20_enable_pod.sh \ No newline at end of file diff --git a/podman-wpamapsta/30_start.sh b/podman-wpamapsta/30_start.sh new file mode 120000 index 0000000..29ddbe3 --- /dev/null +++ b/podman-wpamapsta/30_start.sh @@ -0,0 +1 @@ +../_podman-common/30_start_pod.sh \ No newline at end of file diff --git a/podman-wpamapsta/40_stop.sh b/podman-wpamapsta/40_stop.sh new file mode 120000 index 0000000..7e51cf5 --- /dev/null +++ b/podman-wpamapsta/40_stop.sh @@ -0,0 +1 @@ +../_podman-common/40_stop_pod.sh \ No newline at end of file diff --git a/podman-wpamapsta/70_disable.sh b/podman-wpamapsta/70_disable.sh new file mode 120000 index 0000000..10a944b --- /dev/null +++ b/podman-wpamapsta/70_disable.sh @@ -0,0 +1 @@ +../_podman-common/70_disable_pod.sh \ No newline at end of file diff --git a/podman-wpamapsta/80_destroy.sh b/podman-wpamapsta/80_destroy.sh new file mode 120000 index 0000000..1b8a370 --- /dev/null +++ b/podman-wpamapsta/80_destroy.sh @@ -0,0 +1 @@ +../_podman-common/80_destroy_pod.sh \ No newline at end of file diff --git a/podman-wpamapsta/90_prune.sh b/podman-wpamapsta/90_prune.sh new file mode 120000 index 0000000..5fed91e --- /dev/null +++ b/podman-wpamapsta/90_prune.sh @@ -0,0 +1 @@ +../_podman-common/90_prune_pod.sh \ No newline at end of file diff --git a/podman-wpamapsta/ci_build-images.sh b/podman-wpamapsta/ci_build-images.sh new file mode 100644 index 0000000..cf93aea --- /dev/null +++ b/podman-wpamapsta/ci_build-images.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +# TODO : FIX BUILD +git clone --depth=1 https://github.com/docker-library/wordpress.git +cd wordpress/latest/php8.0/apache/ +podman build -t ${wp_image}:${wp_version} . diff --git a/podman-wpamapsta/container-compose.yml b/podman-wpamapsta/container-compose.yml new file mode 100644 index 0000000..01bb6d2 --- /dev/null +++ b/podman-wpamapsta/container-compose.yml @@ -0,0 +1,35 @@ +version: '3.1' +services: + db: + container_name: db + image: "${mysql_image}:${mysql_version}" + environment: + - MARIADB_DATABASE=exampledb + - MARIADB_USER=exampleuser + - MARIADB_RANDOM_ROOT_PASSWORD='1' + healthcheck: + test: ["CMD-SHELL", "healthcheck.sh --su-mysql --connect --innodb_initialized"] + interval: 60s + timeout: 10s + retries: 3 + start_period: 5s + volumes: + - db:/var/lib/mysql:Z + + wp: + container_name: wp + image: "${wp_image}:${wp_version}" + depends_on: + - db + ports: + - ${listen_if}:${listen_port}:80 + environment: + - WORDPRESS_DB_HOST=db + - WORDPRESS_DB_USER=exampleuser + - WORDPRESS_DB_NAME=exampledb + volumes: + - wp:/var/www/html:Z + +volumes: + db: + wp: diff --git a/podman-wpamapsta/vars.sh b/podman-wpamapsta/vars.sh new file mode 100644 index 0000000..1c96920 --- /dev/null +++ b/podman-wpamapsta/vars.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +## vars +wp_image='git.garbaye.fr/garbaye/wordpress' +wp_version='6.1.4-php8.0-apache' +mysql_image='docker.io/library/mariadb' +mysql_version='10.11' +## default vars : override with ENV var +listen_if="${GARBAYE_WPAMAPSTA_ENV_LISTENIF:-127.0.0.1}" +listen_port="${GARBAYE_WPAMAPSTA_ENV_LISTENPORT:-8092}" +## mandatory ENV vars +envvars='GARBAYE_WPAMAPSTA_MYSQL_PASSWORD' +## internal vars : do not touch +project_name=${PWD##*/} +pod_name="pod_${project_name}" +service_name="pod-${pod_name}.service" +upstream_images="${wp_image} docker.io/library/php" +dbvolume='podman-wpamapsta_db' +wpvolume='podman-wpamapsta_wp'