refactor: move herokuish app cache from the filesystem into a docker volume

This simplifies cache referencing and also paves the way for removing more from the app git directory.

Refs #1558
This commit is contained in:
Jose Diaz-Gonzalez
2022-11-28 02:24:27 -05:00
parent ce0177967d
commit 40b20e0c08
13 changed files with 126 additions and 50 deletions

View File

@@ -59,12 +59,16 @@ teardown() {
}
@test "(build-env) buildpack deploy with Dockerfile" {
run /bin/bash -c "dokku config:set --no-restart $TEST_APP BUILDPACK_URL='https://github.com/heroku/heroku-buildpack-nodejs'"
run /bin/bash -c "dokku config:set --no-restart $TEST_APP BUILDPACK_URL='https://github.com/dokku/heroku-buildpack-null'"
echo "output: $output"
echo "status: $status"
assert_success
run deploy_app python dokku@dokku.me:$TEST_APP move_dockerfile_into_place
echo "output: $output"
echo "status: $status"
assert_success
deploy_app dockerfile
run /bin/bash -c "dokku --quiet config:get $TEST_APP DOKKU_APP_TYPE"
echo "output: $output"
echo "status: $status"

View File

@@ -4,9 +4,11 @@ load test_helper
setup() {
global_setup
create_app
}
teardown() {
destroy_app
global_teardown
}
@@ -24,7 +26,7 @@ teardown() {
assert_output "$help_output"
}
@test "(repo) repo:gc, repo:purge-cache" {
@test "(repo) repo:gc" {
run deploy_app
echo "output: $output"
echo "status: $status"
@@ -34,29 +36,36 @@ teardown() {
echo "output: $output"
echo "status: $status"
assert_success
}
run /bin/bash -c "touch $DOKKU_ROOT/$TEST_APP/cache/derp"
@test "(repo) repo:purge-cache" {
run deploy_app
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "find $DOKKU_ROOT/$TEST_APP/cache -type f | wc -l"
run /bin/bash -c "docker volume ls -q --filter label=com.dokku.app-name=$TEST_APP | wc -l"
echo "count: '$output'"
echo "status: $status"
assert_not_output 0
run /bin/bash -c "dokku repo:purge-cache $TEST_APP"
echo "output: $output"
echo "status: $status"
assert_success
assert_output 1
run /bin/bash -c "find $DOKKU_ROOT/$TEST_APP/cache -type f | wc -l"
echo "count: '$output'"
echo "status: $status"
assert_output 0
run destroy_app
run /bin/bash -c "dokku repo:purge-cache $TEST_APP"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "docker volume ls -q --filter label=com.dokku.app-name=$TEST_APP | wc -l"
echo "count: '$output'"
echo "status: $status"
assert_output 0
run /bin/bash -c "find $DOKKU_ROOT/$TEST_APP/cache -type f | wc -l"
echo "count: '$output'"
echo "status: $status"
assert_output 0
}

View File

@@ -535,6 +535,13 @@ add_postdeploy_command() {
echo "${contents}" >"$APP_REPO_DIR/app.json"
}
move_dockerfile_into_place() {
local APP="$1"
local APP_REPO_DIR="$2"
[[ -z "$APP" ]] && local APP="$TEST_APP"
mv "$APP_REPO_DIR/alt.Dockerfile" "$APP_REPO_DIR/Dockerfile"
}
add_requirements_txt() {
local APP="$1"
local APP_REPO_DIR="$2"