mirror of
https://github.com/dokku/dokku.git
synced 2025-12-29 00:25:08 +01:00
Previously, we would always set the port mapping during a dockerfile build, making it difficult for users to override mappings. We also only _sometimes_ updated the detected port mapping, further confusing issues when users were migrating from Dockerfile to Buildpacks for builds. Now, we always detect the port mapping during the build process, and only use that detected port mapping if an override is not specified. This greatly simplifies the experience around port mapping, as now a user can create an app, set a port mapping, and that first deploy will respect the port mapping without an additional deploy. The builder always has the best context for what the app should be listening on, and thus we can always specify a "default" port mapping at this stage. Users can override this map as desired later. This change also results in the removal of a ton of internal code that is now centralized in the ports plugin. Closes #4067
97 lines
2.4 KiB
Bash
97 lines
2.4 KiB
Bash
#!/usr/bin/env bats
|
|
|
|
load test_helper
|
|
|
|
setup() {
|
|
create_app
|
|
DOCKERFILE="$BATS_TMPDIR/Dockerfile"
|
|
}
|
|
|
|
teardown() {
|
|
rm -f "$DOCKERFILE"
|
|
destroy_app
|
|
}
|
|
|
|
@test "(builder-dockerfile:set)" {
|
|
run deploy_app dockerfile
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku builder-dockerfile:set $TEST_APP dockerfile-path nonexistent-dockerfile"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku ps:rebuild $TEST_APP"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_failure
|
|
|
|
run /bin/bash -c "dokku builder-dockerfile:set $TEST_APP dockerfile-path second.Dockerfile"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku ps:rebuild $TEST_APP"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
assert_output_contains 'echo hi'
|
|
|
|
run /bin/bash -c "dokku builder-dockerfile:set $TEST_APP dockerfile-path"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku ps:rebuild $TEST_APP"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
assert_output_contains 'echo hi' 0
|
|
}
|
|
|
|
@test "(builder-dockerfile) config export" {
|
|
run /bin/bash -c "dokku config:set $TEST_APP GITHUB_TOKEN=custom-value"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku docker-options:add $TEST_APP build '--build-arg GITHUB_TOKEN'"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run deploy_app dockerfile
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
assert_output_contains "TOKEN is: custom-value" 2
|
|
}
|
|
|
|
@test "(builder-dockerfile) port exposure (dockerfile raw port)" {
|
|
source "$PLUGIN_CORE_AVAILABLE_PATH/builder-dockerfile/internal-functions"
|
|
cat <<EOF >$DOCKERFILE
|
|
EXPOSE 3001/udp
|
|
EXPOSE 3003
|
|
EXPOSE 3000/tcp
|
|
EOF
|
|
run fn-builder-dockerfile-get-ports-from-dockerfile $DOCKERFILE
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_output "3001/udp 3003 3000/tcp"
|
|
}
|
|
|
|
@test "(builder-dockerfile) port exposure (dockerfile tcp port)" {
|
|
source "$PLUGIN_CORE_AVAILABLE_PATH/builder-dockerfile/internal-functions"
|
|
cat <<EOF >$DOCKERFILE
|
|
EXPOSE 3001/udp
|
|
EXPOSE 3000/tcp
|
|
EXPOSE 3003
|
|
EOF
|
|
run fn-builder-dockerfile-get-ports-from-dockerfile $DOCKERFILE
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_output "3001/udp 3000/tcp 3003"
|
|
}
|