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 synapse-generate
|
||||||
- podman container rm --force buildkitd
|
- podman container rm --force buildkitd
|
||||||
- rm -f ~/.config/systemd/user/pod-podman-matrix.service && systemctl --user daemon-reload
|
- rm -f ~/.config/systemd/user/pod-podman-matrix.service && systemctl --user daemon-reload
|
||||||
- podman volume rm --force matrixdotorg_synapse-data
|
- podman volume rm --force podman-matrix_matrixdotorg_synapse-data
|
||||||
- podman volume rm --force matrixdotorg_synapse-pgsql
|
- podman volume rm --force podman-matrix_matrixdotorg_synapse-pgsql
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
stage: test
|
stage: test
|
||||||
|
|
|
@ -20,25 +20,43 @@ if ! podman volume exists ${dbvolume} ; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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
|
if ! podman image exists ${synapse_image}:${synapse_version}; then
|
||||||
podman image pull ${synapse_image}:${synapse_version} || exit 1
|
podman image pull ${synapse_image}:${synapse_version} || exit 1
|
||||||
fi
|
fi
|
||||||
podman image pull ${postgres_image}:${postgres_version} &&
|
podman image pull ${postgres_image}:${postgres_version} &&
|
||||||
if ! podman network exists ${project_name}_default; then
|
podman-compose --pod-args="--infra=true --infra-name=${project_name}_infra --share=" --podman-run-args "--requires=${project_name}_infra --env-file .env" up -d &&
|
||||||
podman network create ${project_name}_default
|
|
||||||
fi
|
end=$((SECONDS+30))
|
||||||
podman pod create --name ${pod_name} --infra=true --infra-name=${project_name}_infra --share='' &&
|
while [ $SECONDS -lt $end ]; do
|
||||||
podman container run -d --name ${db_container_name} --pod ${pod_name} --requires=${project_name}_infra --net ${project_name}_default \
|
sleep 1
|
||||||
--mount type=volume,src=${dbvolume},dst=/var/lib/postgresql/data/ \
|
if check_container_running synapse; then
|
||||||
-e POSTGRES_PASSWORD=${GARBAYE_MATRIX_POSTGRES_PASSWORD} \
|
podman logs synapse 2>&1 | grep -qe 'Preparing for databases' &&
|
||||||
-e POSTGRES_USER=${container_name} \
|
break
|
||||||
-e POSTGRES_DB=${container_name} \
|
else
|
||||||
-e POSTGRES_INITDB_ARGS="--encoding=UTF8 --locale=C" \
|
podman logs synapse 2>&1 | grep -qe 'psycopg2.OperationalError: could not connect to server: Connection refused' &&
|
||||||
${postgres_image}:${postgres_version} &&
|
podman healthcheck run synapse-db &&
|
||||||
podman container run -d --name ${container_name} --pod ${pod_name} --requires=${project_name}_infra --net ${project_name}_default \
|
echo "Oops, synapse didn't wait for PostgreSQL, restarting"
|
||||||
--mount type=volume,src=${confvolume},dst=/data --publish ${listen_if}:${listen_port}:8008 ${synapse_image}:${synapse_version} &&
|
podman start synapse
|
||||||
|
fi
|
||||||
|
done &&
|
||||||
|
|
||||||
echo -n "Waiting for background tasks to end... " &&
|
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." &&
|
echo "OK." &&
|
||||||
podman pod stop ${pod_name} &&
|
podman pod stop ${pod_name} &&
|
||||||
echo "Done. Pod built and stopped."
|
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}"
|
pod_name="pod_${project_name}"
|
||||||
service_name="pod-${pod_name}.service"
|
service_name="pod-${pod_name}.service"
|
||||||
upstream_images="${synapse_image} ${postgres_image}"
|
upstream_images="${synapse_image} ${postgres_image}"
|
||||||
confvolume='matrixdotorg_synapse-data'
|
confvolume='podman-matrix_matrixdotorg_synapse-data'
|
||||||
dbvolume='matrixdotorg_synapse-pgsql'
|
dbvolume='podman-matrix_matrixdotorg_synapse-pgsql'
|
||||||
container_name='synapse'
|
container_name='synapse'
|
||||||
db_container_name='synapse-db'
|
db_container_name='synapse-db'
|
||||||
|
|
Loading…
Reference in a new issue