[mod] webawesome 3.2.1
This commit is contained in:
parent
1d27f16a2c
commit
ebcb1b2c57
5 changed files with 296 additions and 208 deletions
46
scripts/docker-populate-volume.sh
Normal file
46
scripts/docker-populate-volume.sh
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
#!/usr/bin/env bash
|
||||
# examine result
|
||||
# docker run --rm -it -v webawesome-3.2.1:/volume alpine sh
|
||||
set -euo pipefail # strict error handling
|
||||
|
||||
# Usage message
|
||||
usage() {
|
||||
echo "Usage: $0 <volume_name> [source_dir]"
|
||||
echo " volume_name Name of the Docker volume to create/populate"
|
||||
echo " source_dir Source directory (default: current directory)"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Check args
|
||||
[[ $# -lt 1 ]] && usage
|
||||
|
||||
VOLUME_NAME="$1"
|
||||
SOURCE_DIR="${2:-.}"
|
||||
|
||||
# Resolve source dir to absolute path (handles relative paths, symlinks via readlink)
|
||||
if ! SOURCE_DIR=$(cd "$SOURCE_DIR" && pwd); then
|
||||
echo "❌ Error: Source directory '$2' does not exist or is not readable." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "📦 Populating Docker volume '$VOLUME_NAME' from: $SOURCE_DIR"
|
||||
|
||||
# Create the volume (safe: no-op if exists)
|
||||
docker volume create "$VOLUME_NAME" >/dev/null 2>&1 || true
|
||||
|
||||
# Use Alpine Linux container to copy contents into the volume
|
||||
# - --rm: auto-cleanup after exit
|
||||
# - read-only source for safety
|
||||
# - cp -a preserves all metadata (symlinks, perms, timestamps)
|
||||
# - /source/. → copies *contents* of source dir into target root
|
||||
docker run --rm \
|
||||
-v "$SOURCE_DIR:/source:ro" \
|
||||
-v "$VOLUME_NAME:/target" \
|
||||
alpine:latest \
|
||||
sh -c 'cp -a /source/. /target/' || {
|
||||
echo "❌ Error copying files. Is Docker running?" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
echo "✅ Volume '$VOLUME_NAME' is now populated from '$SOURCE_DIR'"
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue