31 lines
1.4 KiB
Bash
31 lines
1.4 KiB
Bash
|
#!/usr/bin/env bash
|
||
|
|
||
|
ABSDIR="$( dirname "$(readlink -f -- "$0")" )"
|
||
|
source ${ABSDIR}/../functions.sh
|
||
|
source ${ABSDIR}/vars.sh
|
||
|
|
||
|
ensure_pwd_is_scriptdir
|
||
|
ensure_not_root
|
||
|
|
||
|
buildfolder=/tmp/vaultwarden-$$
|
||
|
|
||
|
if ! podman image exists ${vaultwarden_image}:${vaultwarden_version}; then
|
||
|
mkdir ${buildfolder} &&
|
||
|
git clone --depth=1 --branch=${vaultwarden_version} https://github.com/dani-garcia/vaultwarden.git ${buildfolder}/ && {
|
||
|
sed_in_place "^FROM vaultwarden/web-vault" "FROM docker.io/vaultwarden/web-vault" ${buildfolderdocker/amd64/Dockerfile.alpine
|
||
|
sed_in_place "^FROM blackdex/rust-musl" "FROM docker.io/blackdex/rust-musl" ${buildfolderdocker/amd64/Dockerfile.alpine
|
||
|
sed_in_place "^FROM alpine" "FROM docker.io/library/alpine" ${buildfolderdocker/amd64/Dockerfile.alpine
|
||
|
TMPDIR=${HOME} podman image build -t ${vaultwarden_image}:${vaultwarden_version} -f ${buildfolderdocker/amd64/Dockerfile.alpine ${buildfolder}
|
||
|
}
|
||
|
rm -rf ${buildfolder}
|
||
|
podman image prune -a -f --filter dangling=true
|
||
|
podman image prune -a -f --filter intermediate=true
|
||
|
podman image rm -f $(podman images -a -q -- vaultwarden/web-vault)
|
||
|
podman image rm -f $(podman images -a -q -- docker.io/blackdex/rust-musl)
|
||
|
podman image rm -f $(podman images -a -q -- dockerio/library/alpine)
|
||
|
else
|
||
|
echo "Image ${vaultwarden_image}:${vaultwarden_version} already built"
|
||
|
fi
|
||
|
|
||
|
oci_push_to_registry ${vaultwarden_image}:${vaultwarden_version}
|