jib icon indicating copy to clipboard operation
jib copied to clipboard

appRoot property is not actually defaulted to /app

Open artemptushkin opened this issue 3 years ago • 4 comments

Environment:

  • Jib version: 3.2.1
  • Build tool: Gradle
  • OS: Mac OS Monterey 12.4, M1

Description of the issue:

The property reference jib.container.appRoot returns root container directory instead of default /app

It works properly when you have container section explicitly defined (see below) but it's not convenient as the documentation says it should be /app by default

Expected behavior:

jib.container.appRoot always has the default value as it's documented

Steps to reproduce:

The next configuration:

jib {
    extraDirectories {
        paths {
            path {
                from = "$project.rootDir/frontend/build"
                into = "${jib.container.appRoot}/resources"
            }
        }
    }
    from {
        image = "eclipse-temurin:17-jre"
    }
}

Brings that inside the image files from $project.rootDir/frontend/build will be in . / root container directory and not the /app where other files are located

Workaround

Define container container before extraDirectories:

jib {
    container {
        appRoot = "/app"
    }
    extraDirectories {
        paths {
            path {
                from = "$project.rootDir/frontend/build"
                into = "${jib.container.appRoot}/resources"
            }
        }
    }
    from {
        image = "eclipse-temurin:17-jre"
    }
}

artemptushkin avatar Jul 06 '22 14:07 artemptushkin

You are right that this is a bit confusing in the documentation. What is meant by "default" is that if jib.container.appRoot is missing, the rest of Jib functionality will use /app by default. Jib never meant to set a default value for the gradle property.

This is working as intended, but if you have ideas on how to make this distinction clearer, we'd be happy to accept a documentation contribution.

elefeint avatar Jul 11 '22 19:07 elefeint

@elefeint I see, thanks. But why can't we just set /app as default?

artemptushkin avatar Jul 12 '22 07:07 artemptushkin

No reason; we'd accept a contribution to that effect.

elefeint avatar Jul 12 '22 13:07 elefeint

@elefeint I'd contribute then, I'll open a PR later

artemptushkin avatar Jul 12 '22 14:07 artemptushkin