- Strip prefix directories from tarball
This commit is contained in:
1 parent
712e1cada7
commit
5a51246007
2 files changed
+20
-5
No files matched your search
@@ -40,7 +40,14 @@ case "$1" in
|
|||||||
# extract tar file
|
# extract tar file
|
||||||
chmod 755 $TMP_WORK_DIR
|
chmod 755 $TMP_WORK_DIR
|
||||||
pushd $TMP_WORK_DIR > /dev/null
|
pushd $TMP_WORK_DIR > /dev/null
|
||||||
tar -x -C "$TMP_WORK_DIR" -f "$DOKKU_ROOT/$APP/src.tar"
|
|
||||||
|
# Detect a common prefix that all files in the tar have, and strip off each directory found in it
|
||||||
|
COMMON_PREFIX=$(tar -tf "$DOKKU_ROOT/$APP/src.tar" | sed -e 'N;s/^\(.*\).*\n\1.*$/\1\n\1/;D')
|
||||||
|
BOGUS_PARTS=$(echo "$COMMON_PREFIX " | awk 'BEGIN{FS="/"} {print NF-1}')
|
||||||
|
|
||||||
|
dokku_log_info1_quiet "Striping $BOGUS_PARTS worth of directories from tarball"
|
||||||
|
|
||||||
|
tar -x -C "$TMP_WORK_DIR" -f "$DOKKU_ROOT/$APP/src.tar" --strip-components=$BOGUS_PARTS
|
||||||
#find -name .git -prune -exec rm -rf {} \; > /dev/null
|
#find -name .git -prune -exec rm -rf {} \; > /dev/null
|
||||||
|
|
||||||
if [[ -f Dockerfile ]] && [[ "$([[ -f .env ]] && grep -q BUILDPACK_URL .env; echo $?)" != "0" ]] && [[ ! -f ".buildpacks" ]]; then
|
if [[ -f Dockerfile ]] && [[ "$([[ -f .env ]] && grep -q BUILDPACK_URL .env; echo $?)" != "0" ]] && [[ ! -f ".buildpacks" ]]; then
|
||||||
|
|||||||
+12
-4
@@ -12,15 +12,15 @@ teardown() {
|
|||||||
|
|
||||||
deploy_app_tar() {
|
deploy_app_tar() {
|
||||||
APP_TYPE="$1"; APP_TYPE=${APP_TYPE:="nodejs-express"}
|
APP_TYPE="$1"; APP_TYPE=${APP_TYPE:="nodejs-express"}
|
||||||
GIT_REMOTE="$2"; GIT_REMOTE=${GIT_REMOTE:="dokku@dokku.me:$TEST_APP"}
|
|
||||||
TMP=$(mktemp -d -t "dokku.me.XXXXX")
|
TMP=$(mktemp -d -t "dokku.me.XXXXX")
|
||||||
rmdir $TMP && cp -r ./tests/apps/$APP_TYPE $TMP
|
rmdir $TMP && cp -r ./tests/apps/$APP_TYPE $TMP
|
||||||
cd $TMP
|
cd $TMP
|
||||||
tar c . | ssh dokku@dokku.me tar:in $TEST_APP || destroy_app $?
|
shift 1
|
||||||
|
tar c . $* | ssh dokku@dokku.me tar:in $TEST_APP || destroy_app $?
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "(tar) basic deploy using tar:in" {
|
@test "(tar) non-tarbomb deploy using tar:in" {
|
||||||
deploy_app_tar
|
deploy_app_tar nodejs-express --transform 's,^,prefix/,'
|
||||||
|
|
||||||
run bash -c "response=\"$(curl -s -S my-cool-guy-test-app.dokku.me)\"; echo \$response; test \"\$response\" == \"nodejs/express\""
|
run bash -c "response=\"$(curl -s -S my-cool-guy-test-app.dokku.me)\"; echo \$response; test \"\$response\" == \"nodejs/express\""
|
||||||
echo "output: "$output
|
echo "output: "$output
|
||||||
@@ -28,3 +28,11 @@ deploy_app_tar() {
|
|||||||
assert_success
|
assert_success
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "(tar) tarbomb deploy using tar:in" {
|
||||||
|
deploy_app_tar nodejs-express
|
||||||
|
|
||||||
|
run bash -c "response=\"$(curl -s -S my-cool-guy-test-app.dokku.me)\"; echo \$response; test \"\$response\" == \"nodejs/express\""
|
||||||
|
echo "output: "$output
|
||||||
|
echo "status: "$status
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
Reference in new issue
Block a user