mv dockerfile port logic to common function + tests. closes #1280
This commit is contained in:
@@ -36,7 +36,7 @@ case "$1" in
|
||||
|
||||
dockerfile)
|
||||
# extract first port from Dockerfile
|
||||
DOCKERFILE_PORT=$(grep "^EXPOSE \+[[:digit:]]\+\(\/tcp\)\? *$" Dockerfile | head -1 | sed 's/EXPOSE \+\([[:digit:]]\+\)\(\/tcp\)\?.*/\1/' || true)
|
||||
DOCKERFILE_PORT=$(get_dockerfile_exposed_port Dockerfile)
|
||||
[[ -n "$DOCKERFILE_PORT" ]] && dokku config:set-norestart $APP DOKKU_DOCKERFILE_PORT=$DOCKERFILE_PORT
|
||||
|
||||
# buildstep pluginhooks don't necessarily make sense for dockerfiles. call the new breed!!!
|
||||
|
||||
@@ -201,3 +201,12 @@ get_container_ids() {
|
||||
shopt -u nullglob
|
||||
echo $DOKKU_CIDS
|
||||
}
|
||||
|
||||
get_dockerfile_exposed_port() {
|
||||
local DOCKERFILE_PORT=$(grep "^EXPOSE \+[[:digit:]]\+\(\/tcp\)\? *$" $1 | head -1 | sed 's/EXPOSE \+\([[:digit:]]\+\)\(\/tcp\)\?.*/\1/' || true)
|
||||
if [[ -n "$DOCKERFILE_PORT" ]]; then
|
||||
echo "$DOCKERFILE_PORT"
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user