Skip to content

Commit

Permalink
Allow generating snapshot for any cpanfile
Browse files Browse the repository at this point in the history
by adding optional parameter `path/to/cpanfile` to the script
`generate_cpanfile_snapshot.sh`.  Without parameter, it still
generates snapshot for the cpanfile in its grand-parent directory.
The script can still be called from any current working directory.
  • Loading branch information
yvanzo committed Nov 17, 2018
1 parent b6f48eb commit 37bf412
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions docker/generate_cpanfile_snapshot.sh
Expand Up @@ -2,7 +2,13 @@

set -e

if [ $# -ne 0 -a "(" $# -ne 1 -o "${1##*/}" != "cpanfile" ")" ]; then
echo "Usage: $0 [path/to/cpanfile]"
exit 1
fi

MB_SERVER_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/../" && pwd)
CPANFILE_DIR=$(cd "$(dirname ${1:-$MB_SERVER_ROOT/cpanfile})/" && pwd)
cd "$MB_SERVER_ROOT"

make -C docker config
Expand All @@ -13,14 +19,14 @@ TMP_DIR=/tmp/.$TMP_IMG
mkdir -p "$TMP_DIR"
cd "$TMP_DIR"

cp "$MB_SERVER_ROOT/cpanfile" "$TMP_DIR/"
cp "$CPANFILE_DIR/cpanfile" "$TMP_DIR/"
cp "$MB_SERVER_ROOT/docker/Dockerfile.cpanfile-snapshot" "$TMP_DIR/Dockerfile"

docker build -t $TMP_IMG .
CONTAINER_ID=$(docker create $TMP_IMG)
docker cp \
$CONTAINER_ID:/home/musicbrainz/musicbrainz-server/cpanfile.snapshot \
"$MB_SERVER_ROOT/"
"$CPANFILE_DIR/"
docker rm $CONTAINER_ID
docker rmi $TMP_IMG

Expand Down

0 comments on commit 37bf412

Please sign in to comment.