quarkiverse / quarkus-amazon-services

Quarkus Amazon Services extensions
Apache License 2.0
41 stars 50 forks source link

Problem with localstack init script #1420

Closed TheBroach closed 1 month ago

TheBroach commented 1 month ago

Hi! I am trying to use io.quarkiverse.amazonservices:quarkus-amazon-dynamodb-enhanced extension and an init script to create a DynamoDB table when I am running quarkusDev, but I cannot get it to work...

Here is a small MCVE that replicates how I am trying to set it up in my main project.

Thankful for any help, been banging my head against this wall for quite some time...

scrocquesel commented 1 month ago

Hi! I am trying to use io.quarkiverse.amazonservices:quarkus-amazon-dynamodb-enhanced extension and an init script to create a DynamoDB table when I am running quarkusDev, but I cannot get it to work...

Here is a small MCVE that replicates how I am trying to set it up in my main project.

Thankful for any help, been banging my head against this wall for quite some time...

Make sure the script is runnable. On linux, try chmod +x src/main/resources/scripts/init-localstack.sh

TheBroach commented 1 month ago

Thanks for the answer! Yes, the file has the permissions -rwxr-xr-x.

scrocquesel commented 1 month ago

@TheBroach Setting the absolute path to the folder in the application.properties make it works. I guess, gradle handles path differently than maven when it run the process. The mounted path with gradle is ./build/classes/kotlin/main/src/main/resources/scripts.

Need to find a way to be compatible with both maven and gradle

scrocquesel commented 1 month ago

Passing a relative path like quarkus.aws.devservices.localstack.init-scripts-folder=../../../resources/main/scripts does the job.

One solution would be to rely on the classloader to get a reliable path to the files, but it would require to extract the resources to a physical temporary directory for docker to be able to mount it. This is not ideal solution either to me.

FYI, while the container is running, I inspect it with docker inspect to see what is the resolved mounted path.

TheBroach commented 1 month ago

Thank you so much for the help! Yep, all working now. And thanks for the tip with docker inspect!

Just to learn, I had a hard time grasping the "location of execution" of the..."thing" that needs this script folder path configuration. Using your relative path example as a hint, I found a suspicious place in the build folder... Could it be ./build/tmp/quarkusDev? :)

scrocquesel commented 1 month ago

/build/classes/kotlin/main

I'm no gradle expert but what I experienced is that the working directory is in /build/classes/kotlin/main