Access Repository source code in Dockerfile during build
Hi,
Is there a way to access the repository source code within a docker build as a git clone inside the Dockerfile?
I tried something like that:
job("Build push Docker rails production image") {
host("Build and push") {
dockerBuildPush {
context = "docker"
file = "docker/base_images/rails/production/Dockerfile"
labels["vendor"] = "ABCDEFG"
args["JB_SPACE_WORK_DIR_PATH"] = "${"$"}JB_SPACE_WORK_DIR_PATH"
val spaceRepo = "abcdefg.registry.jetbrains.space/p/main/images/rails_production"
tags {
+"$spaceRepo:1.0.${"$"}JB_SPACE_EXECUTION_NUMBER"
+"$spaceRepo:latest"
}
}
}
}
But the directory coming from JB_SPACE_WORK_DIR_PATH does not exists.
Any ideas?
Please sign in to leave a comment.
The "JB_SPACE_WORK_DIR_PATH" environment variable should return the full path of the working directory. Please let me know if it works incorrectly in your case.
As for getting the repository source code, the below Help Articles explain how to do this:
https://www.jetbrains.com/help/space/check-out-project-sources.html#where-source-code-is-stored
https://www.jetbrains.com/help/space/run-a-step-in-a-container.html#selecting-a-container-image
If any further questions arise, please don't hesitate to post them.
Oleg Beriashvili
JetBrains
http://www.jetbrains.com
The Drive to Develop
Hi Oleg,
I have fitted JB_SPACE_WORK_DIR_PATH as an ARG to my build script.
Now it works but the normal Dockerfile "COPY" doesn't work right for some reason.
It always searched for the directory like: "mnt/space/work/repo/mnt/space/work/repo" when i do "COPY ${JB_SPACE_WORK_DIR_PATH} /targetFolder/"
When i use "RUN cp -r ${JB_SPACE_WORK_DIR_PATH}/. /targetFolder/" it works perfectly.
Thanks for your help
Best regards
Marco