deploy: check the books dir from a root container (deploy user cannot traverse /home/stan)
Some checks failed
Deploy production / deploy (push) Failing after 2m12s
Some checks failed
Deploy production / deploy (push) Failing after 2m12s
Run #78 skipped the /books mount because [ -d /home/stan/books/library ] runs as the deploy account, which has no access to /home/stan (0750). Check inside a container with the dir bind-mounted instead; the mount itself is done by dockerd.
This commit is contained in:
@@ -19,13 +19,26 @@ environment_name=production
|
|||||||
image="git.stanrunge.dev/stan/website:$sha"
|
image="git.stanrunge.dev/stan/website:$sha"
|
||||||
compose="$directory/compose.prod.yml"
|
compose="$directory/compose.prod.yml"
|
||||||
compose_files=(-f "$compose")
|
compose_files=(-f "$compose")
|
||||||
|
# Images built before the repo rename (stan/personal-website -> stan/website) keep
|
||||||
|
# their old local name; retag so rollbacks to those SHAs still work.
|
||||||
|
legacy_image="git.stanrunge.dev/stan/personal-website:$sha"
|
||||||
|
if ! sudo docker image inspect "$image" >/dev/null 2>&1 &&
|
||||||
|
sudo docker image inspect "$legacy_image" >/dev/null 2>&1; then
|
||||||
|
sudo docker tag "$legacy_image" "$image"
|
||||||
|
fi
|
||||||
|
if ! sudo docker image inspect "$image" >/dev/null 2>&1; then
|
||||||
|
echo "Image $image is not on this host" >&2; exit 1
|
||||||
|
fi
|
||||||
# Book files (ebooks + covers) live on the host and are bind-mounted read-only at /books;
|
# Book files (ebooks + covers) live on the host and are bind-mounted read-only at /books;
|
||||||
# the app streams them only to the owner via /trackers/books/files/<id> (no static path).
|
# the app streams them only to the owner via /trackers/books/files/<id> (no static path).
|
||||||
# Layout: $books_host_dir/library/<files.path> and $books_host_dir/covers/<works.cover_path>.
|
# Layout: $books_host_dir/library/<files.path> and $books_host_dir/covers/<works.cover_path>.
|
||||||
# compose.prod.yml is host-managed, so the mount goes in a generated override file.
|
# compose.prod.yml is host-managed, so the mount goes in a generated override file.
|
||||||
books_host_dir=${BOOKS_HOST_DIR:-/home/stan/books}
|
books_host_dir=${BOOKS_HOST_DIR:-/home/stan/books}
|
||||||
case "$books_host_dir" in /*) ;; *) echo 'BOOKS_HOST_DIR must be absolute' >&2; exit 2 ;; esac
|
case "$books_host_dir" in /*) ;; *) echo 'BOOKS_HOST_DIR must be absolute' >&2; exit 2 ;; esac
|
||||||
if [ -d "$books_host_dir/library" ]; then
|
# The deploy account can't traverse /home/stan (0750); check from a root container instead.
|
||||||
|
if sudo docker run --rm --entrypoint sh \
|
||||||
|
--mount "type=bind,source=$books_host_dir,target=/books,readonly" "$image" \
|
||||||
|
-c 'test -d /books/library' 2>/dev/null; then
|
||||||
sudo tee "$directory/compose.books.yml" >/dev/null <<YAML
|
sudo tee "$directory/compose.books.yml" >/dev/null <<YAML
|
||||||
services:
|
services:
|
||||||
app:
|
app:
|
||||||
@@ -41,16 +54,6 @@ YAML
|
|||||||
else
|
else
|
||||||
echo "No $books_host_dir/library on this host; book files will not be readable" >&2
|
echo "No $books_host_dir/library on this host; book files will not be readable" >&2
|
||||||
fi
|
fi
|
||||||
# Images built before the repo rename (stan/personal-website -> stan/website) keep
|
|
||||||
# their old local name; retag so rollbacks to those SHAs still work.
|
|
||||||
legacy_image="git.stanrunge.dev/stan/personal-website:$sha"
|
|
||||||
if ! sudo docker image inspect "$image" >/dev/null 2>&1 &&
|
|
||||||
sudo docker image inspect "$legacy_image" >/dev/null 2>&1; then
|
|
||||||
sudo docker tag "$legacy_image" "$image"
|
|
||||||
fi
|
|
||||||
if ! sudo docker image inspect "$image" >/dev/null 2>&1; then
|
|
||||||
echo "Image $image is not on this host" >&2; exit 1
|
|
||||||
fi
|
|
||||||
previous_tag=$(sed -n 's/^IMAGE_TAG=//p' "$directory/.env" | head -n 1)
|
previous_tag=$(sed -n 's/^IMAGE_TAG=//p' "$directory/.env" | head -n 1)
|
||||||
switched=0
|
switched=0
|
||||||
rollback() {
|
rollback() {
|
||||||
|
|||||||
Reference in New Issue
Block a user