vaultwarden : tentative de standardisation++

This commit is contained in:
Gitouche 2023-08-18 18:14:05 +02:00
parent 3680cace09
commit 73d617216b
5 changed files with 77 additions and 13 deletions

View file

@ -39,16 +39,16 @@ SMTP_SECURITY=off
SMTP_PORT=25
EOT
export vaultwarden_image
export vaultwarden_version
export service_image
export service_version
export database_image
export database_version
export database_path
export container_name
export db_container_name
if ! podman image exists ${vaultwarden_image}:${vaultwarden_version}; then
podman image pull ${vaultwarden_image}:${vaultwarden_version} || exit 1
if ! podman image exists ${service_image}:${service_version}; then
podman image pull ${service_image}:${service_version} || exit 1
fi
if ! podman image exists ${database_image}:${database_version}; then
podman image pull ${database_image}:${database_version} || exit 1

64
podman-vaultwarden/50_update.sh Executable file
View file

@ -0,0 +1,64 @@
#!/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_exists "${pod_name}"
ensure_systemd_unit_exists "${service_name}"
ensure_variables_are_defined "$envvars"
current_version=$(podman container list -a --format "{{.Image}}" | grep -F "${service_image}" | awk -F: '{print $NF}')
reinstall_please () {
for image in ${upstream_images}; do
if ! podman image exists "${service_image}":"${service_version}"; then
podman image pull "${service_image}":"${service_version}" || exit 1
fi
done &&
check_pod_running "${pod_name}" && ./40_stop.sh
./70_disable.sh && \
./80_destroy.sh && \
./10_install.sh && \
./20_enable.sh && \
./30_start.sh
}
cleanup_images () {
echo "Remove ${current_version} images?"
select yn in "Yes" "No"; do
case $yn in
Yes)
podman image rm "${service_image}":"${current_version}"
exit 0
;;
No)
exit 0
;;
esac
done
}
if [ "${current_version}" != "${service_version}" ]; then
if [[ "${current_version}" > "${service_version}" ]]; then
echo "WARNING : you are about to DOWNGRADE your installation"
fi
echo "Migrating from ${current_version} to ${service_version}. Proceed?"
select yn in "Yes" "No"; do
case $yn in
Yes)
reinstall_please && \
cleanup_images
exit 0
;;
No)
exit 0
;;
esac
done
else
echo "Already using version ${service_version}. Exiting."
fi

View file

@ -9,11 +9,11 @@ ensure_not_root
buildfolder=/tmp/vaultwarden-$$
if ! podman image exists ${vaultwarden_image}:${vaultwarden_version}; then
if ! podman image exists ${service_image}:${service_version}; then
mkdir ${buildfolder} &&
if git clone --depth=1 --branch=${vaultwarden_version} https://github.com/dani-garcia/vaultwarden.git ${buildfolder}/ ; then
if git clone --depth=1 --branch=${service_version} https://github.com/dani-garcia/vaultwarden.git ${buildfolder}/ ; then
TMPDIR=${HOME} podman image build \
-t ${vaultwarden_image}:${vaultwarden_version} \
-t ${service_image}:${service_version} \
--build-arg DB=postgresql,enable_mimalloc \
-f ${buildfolder}/docker/amd64/Dockerfile.alpine \
${buildfolder} || retval=false
@ -26,7 +26,7 @@ if ! podman image exists ${vaultwarden_image}:${vaultwarden_version}; then
podman image rm -f "$(podman image list -a -q -- dockerio/library/alpine)"
eval "$retval"
else
echo "Image ${vaultwarden_image}:${vaultwarden_version} already built"
echo "Image ${service_image}:${service_version} already built"
fi &&
oci_push_to_registry ${vaultwarden_image}:${vaultwarden_version}
oci_push_to_registry ${service_image}:${service_version}

View file

@ -14,7 +14,7 @@ services:
app:
container_name: ${container_name}
image: ${vaultwarden_image}:${vaultwarden_version}
image: ${service_image}:${service_version}
volumes:
- data:/data:Z
ports:

View file

@ -1,7 +1,7 @@
#!/usr/bin/env bash
## vars
vaultwarden_image="git.garbaye.fr/garbaye/vaultwarden"
vaultwarden_version='1.29.1'
service_image="git.garbaye.fr/garbaye/vaultwarden"
service_version='1.29.1'
database_image="docker.io/library/postgres"
database_version='14-alpine'
database_path="/var/lib/postgresql/data"
@ -20,7 +20,7 @@ envvars='GARBAYE_VAULTWARDEN_ADMIN_PASSWORD GARBAYE_VAULTWARDEN_DATABASE_PASSWOR
project_name=${PWD##*/}
pod_name="pod_${project_name}"
service_name="pod-${pod_name}.service"
upstream_images="${vaultwarden_image} ${postgres_image}"
upstream_images="${service_image} ${database_image}"
datavolume="${project_name}_data"
dbvolume="${project_name}_database"
container_name="${project_name}_app"