Files
dokku/tests/unit/nginx-vhosts_5.bats
T
Jose Diaz-Gonzalez f8ccf52079 refactor: only use detected port mapping if override is not specified
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
2023-08-05 10:58:57 -04:00

82 lines
2.3 KiB
Bash

#!/usr/bin/env bats
load test_helper
source "$PLUGIN_CORE_AVAILABLE_PATH/config/functions"
setup() {
global_setup
[[ -f "$DOKKU_ROOT/VHOST" ]] && cp -fp "$DOKKU_ROOT/VHOST" "$DOKKU_ROOT/VHOST.bak"
}
teardown() {
detach_delete_network
destroy_app
[[ -f "$DOKKU_ROOT/VHOST.bak" ]] && mv "$DOKKU_ROOT/VHOST.bak" "$DOKKU_ROOT/VHOST" && chown dokku:dokku "$DOKKU_ROOT/VHOST"
global_teardown
}
@test "(nginx-vhosts) proxy:build-config (sslip.io style hostnames)" {
echo "127.0.0.1.sslip.io.dokku.me" >"$DOKKU_ROOT/VHOST"
run deploy_app
echo "output: $output"
echo "status: $status"
assert_success
check_urls http://${TEST_APP}.127.0.0.1.sslip.io.dokku.me
assert_http_success http://${TEST_APP}.127.0.0.1.sslip.io.dokku.me
}
@test "(nginx-vhosts) proxy:build-config (dockerfile expose)" {
run deploy_app dockerfile
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku domains:add $TEST_APP www.test.app.dokku.me"
echo "output: $output"
echo "status: $status"
assert_success
check_urls http://${TEST_APP}.dokku.me:3000
check_urls http://${TEST_APP}.dokku.me:3003
check_urls http://www.test.app.dokku.me:3000
check_urls http://www.test.app.dokku.me:3003
assert_http_localhost_success "http" "${TEST_APP}.dokku.me" "3000"
assert_http_localhost_success "http" "${TEST_APP}.dokku.me" "3003"
assert_http_localhost_success "http" "www.test.app.dokku.me" "3000"
assert_http_localhost_success "http" "www.test.app.dokku.me" "3003"
}
@test "(nginx-vhosts) proxy:build-config (multiple networks)" {
run deploy_app
echo "output: $output"
echo "status: $status"
assert_success
create_attach_network
run /bin/bash -c "dokku proxy:build-config $TEST_APP"
echo "output: $output"
echo "status: $status"
assert_success
}
@test "(nginx-vhosts) proxy:build-config (global DOKKU_PROXY_PORT)" {
local GLOBAL_PORT=30999
run /bin/bash -c "dokku config:set --global DOKKU_PROXY_PORT=${GLOBAL_PORT}"
echo "output: $output"
echo "status: $status"
assert_success
run deploy_app
echo "output: $output"
echo "status: $status"
assert_success
check_urls http://${TEST_APP}.dokku.me:${GLOBAL_PORT}
assert_http_success http://${TEST_APP}.dokku.me:${GLOBAL_PORT}
run /bin/bash -c "dokku config:unset --global DOKKU_PROXY_PORT"
echo "output: $output"
echo "status: $status"
assert_success
}