refactor: cleanup Dockerfile and project.toml lookups
This commit is contained in:
@@ -18,20 +18,19 @@ trigger-builder-dockerfile-builder-build() {
|
|||||||
|
|
||||||
local IMAGE=$(get_app_image_name "$APP")
|
local IMAGE=$(get_app_image_name "$APP")
|
||||||
local DOCKER_BUILD_LABEL_ARGS="--label=org.label-schema.schema-version=1.0 --label=org.label-schema.vendor=dokku --label=com.dokku.app-name=$APP"
|
local DOCKER_BUILD_LABEL_ARGS="--label=org.label-schema.schema-version=1.0 --label=org.label-schema.vendor=dokku --label=com.dokku.app-name=$APP"
|
||||||
|
local dockerfile_path=Dockerfile
|
||||||
|
|
||||||
pushd "$SOURCECODE_WORK_DIR" &>/dev/null
|
pushd "$SOURCECODE_WORK_DIR" &>/dev/null
|
||||||
|
|
||||||
local NEW_DOCKERFILE="$(fn-builder-dockerfile-computed-dockerfile-path "$APP")"
|
local NEW_DOCKERFILE="$(fn-builder-dockerfile-computed-dockerfile-path "$APP")"
|
||||||
if [[ -f "$NEW_DOCKERFILE" ]]; then
|
if [[ -n "$NEW_DOCKERFILE" ]]; then
|
||||||
|
if [[ ! -f "$NEW_DOCKERFILE" ]]; then
|
||||||
|
dokku_log_fail "Invalid dockerfile-path specified: $NEW_DOCKERFILE"
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "$NEW_DOCKERFILE" != "Dockerfile" ]]; then
|
if [[ "$NEW_DOCKERFILE" != "Dockerfile" ]]; then
|
||||||
mv "$NEW_DOCKERFILE" Dockerfile
|
mv "$NEW_DOCKERFILE" Dockerfile
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
rm Dockerfile
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ ! -f Dockerfile ]]; then
|
|
||||||
dokku_log_fail "Invalid dockerfile-path specified: $dockerfile_path"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# extract first port from Dockerfile
|
# extract first port from Dockerfile
|
||||||
@@ -49,7 +48,7 @@ trigger-builder-dockerfile-builder-build() {
|
|||||||
declare -a ARG_ARRAY
|
declare -a ARG_ARRAY
|
||||||
eval "ARG_ARRAY=($DOCKER_ARGS)"
|
eval "ARG_ARRAY=($DOCKER_ARGS)"
|
||||||
|
|
||||||
"$DOCKER_BIN" image build --file "$dockerfile_path" "${DOCKER_BUILD_LABEL_ARGS[@]}" $DOKKU_GLOBAL_BUILD_ARGS "${ARG_ARRAY[@]}" "${DOKKU_DOCKER_BUILD_OPTS[@]}" -t $IMAGE .
|
"$DOCKER_BIN" image build "${DOCKER_BUILD_LABEL_ARGS[@]}" $DOKKU_GLOBAL_BUILD_ARGS "${ARG_ARRAY[@]}" "${DOKKU_DOCKER_BUILD_OPTS[@]}" -t $IMAGE .
|
||||||
|
|
||||||
plugn trigger post-build-dockerfile "$APP"
|
plugn trigger post-build-dockerfile "$APP"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,13 +29,15 @@ trigger-builder-pack-builder-build() {
|
|||||||
|
|
||||||
pushd "$SOURCECODE_WORK_DIR" &>/dev/null
|
pushd "$SOURCECODE_WORK_DIR" &>/dev/null
|
||||||
|
|
||||||
local NEW_PROJECT_TOML="$(fn-builder-pack-computed-projectoml-path "$APP")"
|
local NEW_PROJECT_TOML="$(fn-builder-pack-computed-projecttoml-path "$APP")"
|
||||||
if [[ -f "$NEW_PROJECT_TOML" ]]; then
|
if [[ -n "$NEW_PROJECT_TOML" ]]; then
|
||||||
if [[ "$NEW_DOCKERFILE" != "project.toml" ]]; then
|
if [[ ! -f "$NEW_PROJECT_TOML" ]]; then
|
||||||
|
dokku_log_fail "Invalid projecttoml-path specified: $NEW_PROJECT_TOML"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$NEW_PROJECT_TOML" != "project.toml" ]]; then
|
||||||
mv "$NEW_PROJECT_TOML" project.toml
|
mv "$NEW_PROJECT_TOML" project.toml
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
rm project.toml
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local TMP_FILE=$(mktemp "/tmp/dokku-${DOKKU_PID}-${FUNCNAME[0]}.XXXXXX")
|
local TMP_FILE=$(mktemp "/tmp/dokku-${DOKKU_PID}-${FUNCNAME[0]}.XXXXXX")
|
||||||
|
|||||||
@@ -36,9 +36,9 @@ cmd-builder-pack-report-single() {
|
|||||||
fi
|
fi
|
||||||
verify_app_name "$APP"
|
verify_app_name "$APP"
|
||||||
local flag_map=(
|
local flag_map=(
|
||||||
"--builder-pack-computed-projecttoml-path: $(fn-builder-pack-computed-projectoml-path "$APP")"
|
"--builder-pack-computed-projecttoml-path: $(fn-builder-pack-computed-projecttoml-path "$APP")"
|
||||||
"--builder-pack-global-projecttoml-path: $(fn-builder-pack-global-projectoml-path "$APP")"
|
"--builder-pack-global-projecttoml-path: $(fn-builder-pack-global-projecttoml-path "$APP")"
|
||||||
"--builder-pack-projecttoml-path: $(fn-builder-pack-projectoml-path "$APP")"
|
"--builder-pack-projecttoml-path: $(fn-builder-pack-projecttoml-path "$APP")"
|
||||||
)
|
)
|
||||||
|
|
||||||
if [[ -z "$INFO_FLAG" ]]; then
|
if [[ -z "$INFO_FLAG" ]]; then
|
||||||
@@ -67,24 +67,24 @@ cmd-builder-pack-report-single() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
fn-builder-pack-computed-projectoml-path() {
|
fn-builder-pack-computed-projecttoml-path() {
|
||||||
declare APP="$1"
|
declare APP="$1"
|
||||||
|
|
||||||
file="$(fn-builder-pack-projectoml-path "$APP")"
|
file="$(fn-builder-pack-projecttoml-path "$APP")"
|
||||||
if [[ "$file" == "" ]]; then
|
if [[ "$file" == "" ]]; then
|
||||||
file="$(fn-builder-pack-global-projectoml-path "$APP")"
|
file="$(fn-builder-pack-global-projecttoml-path "$APP")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "$file"
|
echo "$file"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn-builder-pack-global-projectoml-path() {
|
fn-builder-pack-global-projecttoml-path() {
|
||||||
declare APP="$1"
|
declare APP="$1"
|
||||||
|
|
||||||
fn-plugin-property-get "builder-pack" "--global" "projecttoml-path" "project.toml"
|
fn-plugin-property-get "builder-pack" "--global" "projecttoml-path" "project.toml"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn-builder-pack-projectoml-path() {
|
fn-builder-pack-projecttoml-path() {
|
||||||
declare APP="$1"
|
declare APP="$1"
|
||||||
|
|
||||||
fn-plugin-property-get "builder-pack" "$APP" "projecttoml-path" ""
|
fn-plugin-property-get "builder-pack" "$APP" "projecttoml-path" ""
|
||||||
|
|||||||
Reference in New Issue
Block a user