matrix : refonte avec podman-compose
This commit is contained in:
parent
d33b44a160
commit
faf3db7d49
|
@ -6,8 +6,8 @@ before_script:
|
|||
- podman container rm --force synapse-generate
|
||||
- podman container rm --force buildkitd
|
||||
- rm -f ~/.config/systemd/user/pod-podman-matrix.service && systemctl --user daemon-reload
|
||||
- podman volume rm --force matrixdotorg_synapse-data
|
||||
- podman volume rm --force matrixdotorg_synapse-pgsql
|
||||
- podman volume rm --force podman-matrix_matrixdotorg_synapse-data
|
||||
- podman volume rm --force podman-matrix_matrixdotorg_synapse-pgsql
|
||||
|
||||
matrix:
|
||||
stage: test
|
||||
|
|
|
@ -20,25 +20,43 @@ if ! podman volume exists ${dbvolume} ; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
cat <<EOT >> .env
|
||||
POSTGRES_PASSWORD=${GARBAYE_MATRIX_POSTGRES_PASSWORD}
|
||||
POSTGRES_USER=${container_name}
|
||||
POSTGRES_DB=${container_name}
|
||||
POSTGRES_INITDB_ARGS=--encoding=UTF8 --locale=C
|
||||
EOT
|
||||
|
||||
export postgres_image
|
||||
export postgres_version
|
||||
export synapse_image
|
||||
export synapse_version
|
||||
export listen_if
|
||||
export listen_port
|
||||
|
||||
if ! podman image exists ${synapse_image}:${synapse_version}; then
|
||||
podman image pull ${synapse_image}:${synapse_version} || exit 1
|
||||
fi
|
||||
podman image pull ${postgres_image}:${postgres_version} &&
|
||||
if ! podman network exists ${project_name}_default; then
|
||||
podman network create ${project_name}_default
|
||||
fi
|
||||
podman pod create --name ${pod_name} --infra=true --infra-name=${project_name}_infra --share='' &&
|
||||
podman container run -d --name ${db_container_name} --pod ${pod_name} --requires=${project_name}_infra --net ${project_name}_default \
|
||||
--mount type=volume,src=${dbvolume},dst=/var/lib/postgresql/data/ \
|
||||
-e POSTGRES_PASSWORD=${GARBAYE_MATRIX_POSTGRES_PASSWORD} \
|
||||
-e POSTGRES_USER=${container_name} \
|
||||
-e POSTGRES_DB=${container_name} \
|
||||
-e POSTGRES_INITDB_ARGS="--encoding=UTF8 --locale=C" \
|
||||
${postgres_image}:${postgres_version} &&
|
||||
podman container run -d --name ${container_name} --pod ${pod_name} --requires=${project_name}_infra --net ${project_name}_default \
|
||||
--mount type=volume,src=${confvolume},dst=/data --publish ${listen_if}:${listen_port}:8008 ${synapse_image}:${synapse_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 &&
|
||||
|
||||
end=$((SECONDS+30))
|
||||
while [ $SECONDS -lt $end ]; do
|
||||
sleep 1
|
||||
if check_container_running synapse; then
|
||||
podman logs synapse 2>&1 | grep -qe 'Preparing for databases' &&
|
||||
break
|
||||
else
|
||||
podman logs synapse 2>&1 | grep -qe 'psycopg2.OperationalError: could not connect to server: Connection refused' &&
|
||||
podman healthcheck run synapse-db &&
|
||||
echo "Oops, synapse didn't wait for PostgreSQL, restarting"
|
||||
podman start synapse
|
||||
fi
|
||||
done &&
|
||||
|
||||
echo -n "Waiting for background tasks to end... " &&
|
||||
( podman container logs -f ${container_name} 2>&1 & ) | grep -q 'No more background updates to do' &&
|
||||
( podman container logs --tail=10 -f ${container_name} 2>&1 & ) | grep -q 'No more background updates to do' &&
|
||||
echo "OK." &&
|
||||
podman pod stop ${pod_name} &&
|
||||
echo "Done. Pod built and stopped."
|
||||
shred -u .env
|
||||
|
|
28
podman-matrix/container-compose.yml
Normal file
28
podman-matrix/container-compose.yml
Normal file
|
@ -0,0 +1,28 @@
|
|||
|
||||
services:
|
||||
synapse-db:
|
||||
image: "${postgres_image}:${postgres_version}"
|
||||
container_name: synapse-db
|
||||
volumes:
|
||||
- matrixdotorg_synapse-pgsql:/var/lib/postgresql/data/:Z
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
synapse:
|
||||
image: "${synapse_image}:${synapse_version}"
|
||||
container_name: synapse
|
||||
ports:
|
||||
- ${listen_if}:${listen_port}:8008
|
||||
volumes:
|
||||
- matrixdotorg_synapse-data:/data:Z
|
||||
depends_on:
|
||||
synapse-db:
|
||||
condition: service_healthy
|
||||
restart: true
|
||||
|
||||
volumes:
|
||||
matrixdotorg_synapse-pgsql:
|
||||
matrixdotorg_synapse-data:
|
|
@ -14,7 +14,7 @@ project_name=${PWD##*/}
|
|||
pod_name="pod_${project_name}"
|
||||
service_name="pod-${pod_name}.service"
|
||||
upstream_images="${synapse_image} ${postgres_image}"
|
||||
confvolume='matrixdotorg_synapse-data'
|
||||
dbvolume='matrixdotorg_synapse-pgsql'
|
||||
confvolume='podman-matrix_matrixdotorg_synapse-data'
|
||||
dbvolume='podman-matrix_matrixdotorg_synapse-pgsql'
|
||||
container_name='synapse'
|
||||
db_container_name='synapse-db'
|
||||
|
|
Loading…
Reference in a new issue