paketo-buildpacks / spring-boot

A Cloud Native Buildpack that contributes Spring Boot dependency information and slices an application into multiple layers
Apache License 2.0
178 stars 21 forks source link

adding bindings to /workspace and activating CDS fail with removing the bindings host files #500

Closed yhgillet closed 1 month ago

yhgillet commented 4 months ago

When using the following configuration, the image build fails with error [creator] Error: /workspace already exists and is not empty and removes the content of the /datadog host directory. Note that when not activating the BP_JVM_CDS_ENABLED, it works fine.

<configuration>
                    <image>
                        <builder>paketobuildpacks/builder-jammy-buildpackless-tiny</builder>
                        <buildpacks>
                            <buildpack>paketobuildpacks/java</buildpack>
                        </buildpacks>
                        <bindings>
                            <!-- WARN: bindings to /workspace doesnt work and it removes your host files -->
                            <binding>${project.basedir}/datadog:/workspace/datadog</binding>
                            <!--                            <binding>${project.basedir}/datadog:/platform/bindings/datadog</binding>-->
                        </bindings>
                        <env>
                            <BP_JVM_CDS_ENABLED>true</BP_JVM_CDS_ENABLED>
                            <BP_SPRING_AOT_ENABLED>true</BP_SPRING_AOT_ENABLED>
                        </env>
                    </image>
                </configuration>

Possible Solution

I found later in the docs that the recommended configuration with binding is using instead /platform/bindings path instead of /workspace , so maybe the buildpack should fail mentioning that the configuration is wrong.

Steps to Reproduce

This repo can be used to reproduce calling mvn clean install shows the issue

anthonydahanne commented 4 months ago

Hello @yhgillet , and thank you for your report.

@pivotal-david-osullivan and @dmikusa , I had a look at what @yhgillet described, and it turns out that, due to the way we unzip / rezip the workspace during CDS processing, it clashes when the user binds a volume in /workspace.

I'm not sure what's best: prevent (or discourage via warning messages) the users not to mount their bindings under workspaces, or, change the CDS processing so that it does disrupt the workspace too much.

The

removes the content of the /datadog host directory.

got me worried 😧 (I could reproduce everything described by @yhgillet )

anthonydahanne commented 3 months ago

hello @yhgillet ! we have moved this issue to the pack cli

https://github.com/buildpacks/pack/issues/2237

I am now wondering if we also should ask @scottfrederick to get this in the Spring Boot plugins 🤔...

anthonydahanne commented 1 month ago

closing this issue as it was solved with https://github.com/buildpacks/pack/issues/2237