Description of the issue:
Some web apps require static files to be copied into resources' staticdirectory. When adding arbitrary files to Jib, it can be more useful to be able to specify target directory.
Similar to the way that a JAR is constructed: https://github.com/oktadeveloper/okta-angular-deployment-example/blob/jar/notes-api/build.gradle.kts#L79
Current workaround is to copy the files into src/main/resources, but these are generated files and shouldn't go into src. See https://github.com/oktadeveloper/okta-angular-deployment-example/blob/jar/notes-api/build.gradle.kts#L98
jib-gradle-plugin Configuration:
See https://github.com/oktadeveloper/okta-angular-deployment-example/blob/jar/notes-api/build.gradle.kts#L98
Additional Information:
cc @mraible
I think this covers what you're asking for: https://github.com/GoogleContainerTools/jib/issues/1581
tl;dr - extraDirectories will allow something similar to the following:
maven:
<extraDirectories>
<paths>
<path>
<from>src/main/custom-dir</from>
<into>/target/on/container</into>
</path>
...
</paths>
</extraDirectories>
gradle:
jib {
extraDirectories {
paths {
path {
from = 'src/main/custom-dir'
into = '/target/on/container'
}
...
}
}
}
Closing as duplicate of #1581, feel free to comment on the existing issue if you have anything to add.
I believe this will work if the target can be a classpath and I can somehow add "static" as a prefix without copying my files somewhere else first.
Do you have a Gradle + Kotlin example?
Also, it looks like this is an open issue. Any chance there's a timeline for adding it as a feature?
On May 5, 2020, at 18:55, Tad Cordle notifications@github.com wrote:

Closed #2453.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
@TadCordle No need to answer my questions. I figured out a solution with @saturnism's help. Here's my Gradle + Kotlin build for Spring Boot that uses Jib and creates an image with Angular files from a different directory.
import com.moowork.gradle.node.npm.NpmTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("se.patrikerdes.use-latest-versions") version "0.2.13"
id("com.github.ben-manes.versions") version "0.28.0"
id("org.springframework.boot") version "2.2.6.RELEASE"
id("io.spring.dependency-management") version "1.0.9.RELEASE"
id("com.github.node-gradle.node") version "2.2.3"
id("com.google.cloud.tools.jib") version "2.2.0"
kotlin("jvm") version "1.3.61"
kotlin("plugin.spring") version "1.3.61"
kotlin("plugin.jpa") version "1.3.61"
}
val spa = "${projectDir}/../notes";
node {
version = "12.16.2"
nodeModulesDir = file(spa)
}
group = "com.okta.developer"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_11
repositories {
mavenCentral()
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-data-rest")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("com.okta.spring:okta-spring-boot-starter:1.4.0")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
if (project.hasProperty("prod")) {
runtimeOnly("org.postgresql:postgresql")
} else {
runtimeOnly("com.h2database:h2")
}
testImplementation("org.springframework.boot:spring-boot-starter-test") {
exclude(group = "org.junit.vintage", module = "junit-vintage-engine")
}
}
tasks.withType<Test> {
useJUnitPlatform()
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "1.8"
}
}
val buildWeb = tasks.register<NpmTask>("buildNpm") {
dependsOn(tasks.npmInstall)
setNpmCommand("run", "build")
setArgs(listOf("--", "--prod"))
inputs.dir("${spa}/src")
inputs.dir(fileTree("${spa}/node_modules").exclude("${spa}/.cache"))
outputs.dir("${spa}/dist")
}
val profile = if (project.hasProperty("prod")) "prod" else "dev"
tasks.bootRun {
args("--spring.profiles.active=${profile}")
}
tasks.processResources {
rename("application-${profile}.properties", "application.properties")
if (profile == "prod") {
dependsOn(buildWeb)
from("${spa}/dist/notes") {
into("static")
}
}
}
jib {
to {
image = "mraible/bootiful-angular"
}
container {
environment = mapOf("SPRING_PROFILES_ACTIVE" to profile)
}
}
Any chance there's a timeline for adding it as a feature?
I just started working on it recently, so hopefully it will be in the next release :)
@saturnism @mraible Jib 2.3.0 is released with this very handy feature. Now you can designate target directories with jib.extraDirectories.paths.path.into. See https://github.com/GoogleContainerTools/jib/issues/1581#issuecomment-632393257 for an example.
Cool - thanks!
Most helpful comment
I think this covers what you're asking for: https://github.com/GoogleContainerTools/jib/issues/1581
tl;dr -
extraDirectorieswill allow something similar to the following:maven:
gradle: