Ajout wpamapsta

This commit is contained in:
Gitouche 2023-11-15 20:33:24 +01:00
parent d8afceef4d
commit e71d5aa6d9
11 changed files with 130 additions and 0 deletions

View File

@ -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

41
podman-wpamapsta/10_install.sh Executable file
View File

@ -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 <<EOT >> .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}

View File

@ -0,0 +1 @@
../_podman-common/20_enable_pod.sh

View File

@ -0,0 +1 @@
../_podman-common/30_start_pod.sh

1
podman-wpamapsta/40_stop.sh Symbolic link
View File

@ -0,0 +1 @@
../_podman-common/40_stop_pod.sh

View File

@ -0,0 +1 @@
../_podman-common/70_disable_pod.sh

View File

@ -0,0 +1 @@
../_podman-common/80_destroy_pod.sh

View File

@ -0,0 +1 @@
../_podman-common/90_prune_pod.sh

View File

@ -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} .

View File

@ -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:

18
podman-wpamapsta/vars.sh Normal file
View File

@ -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'