thousands-plumber-33255
06/29/2022, 3:22 PMentrypoint.sh
pants.toml
/serviceA
Dockerfile
BUILD
And the COPY in the Dockerfile looks like this:
COPY entrypoint.sh /
What needs to be added to the BUILD file? It is always complaining that the file cannot be found.fast-nail-55400
06/29/2022, 3:28 PMBUILD
in root of your repo and add a file
target for it. Then depend on that file
target in your docker_image
target.thousands-plumber-33255
06/29/2022, 3:30 PMBUILD
file:
docker_image(
name="service-runtime",
source="runtime.Dockerfile",
dependencies = ["//:entrypoint"],
)
root BUILD
file:
file(
name='entrypoint',
source="lambda_entrypoint.sh",
)
Result:
#9 [4/5] COPY lambda_entrypoint.sh /
#9 sha256:4262b25edb23c1b1e7dd5b18cf34f449f18864e45c0ce62ee4fa0b0b2329e8b2
#9 ERROR: "/lambda_entrypoint.sh" not found: not found
What am I missing?fast-nail-55400
06/29/2022, 3:33 PM--no-process-cleanup
to your Pants invocation. The log will print out the directory where the execution sandbox has been preserved. Let’s see if the file made it into the execution sandbox. (There will also be a __run.sh
script with the docker build
invocation.)curved-television-6568
06/29/2022, 3:36 PMdocker_image
target is defined, you need to adjust the context_root
(see ./pants docker_image --help
)thousands-plumber-33255
06/29/2022, 3:37 PM15:35:00.22 [INFO] Preserving local process execution dir /tmp/pants-sandbox-Kugjdt for "Building docker image service-runtime:latest"
...
vscode ➜ /nefino_li (feature/DEV-2928-add-all-services ✗) $ ls -la /tmp/pants-sandbox-Kugjdt
total 20
drwxr-xr-x 3 vscode vscode 4096 Jun 29 15:35 .
drwxrwxrwt 1 root root 4096 Jun 29 15:35 ..
-rwxr-xr-x 1 vscode vscode 378 Jun 29 15:35 __run.sh
-rw-r--r-- 1 vscode vscode 185 Jun 29 15:35 lambda_entrypoint.sh
drwxr-xr-x 2 vscode vscode 4096 Jun 29 15:35 services
vscode ➜ /nefino_li (feature/DEV-2928-add-all-services ✗) $
Here services=serviceA directorycurved-television-6568
06/29/2022, 3:39 PM__run.sh
I would expect to see a docker invocation, that uses a subdirectory of your sandbox as build context.curved-television-6568
06/29/2022, 3:39 PMcurved-television-6568
06/29/2022, 3:40 PMthousands-plumber-33255
06/29/2022, 3:41 PM__run.sh
content:
#!/bin/bash
# This command line should execute the same process as pants did internally.
export FUNCTION_DIR=/function PACKAGE_DOWNLOAD_PATH=/packages VARIANT=3.8-bullseye
cd /tmp/pants-sandbox-Kugjdt
/usr/bin/docker build --tag $'service-runtime:latest' --build-arg FUNCTION_DIR --build-arg PACKAGE_DOWNLOAD_PATH --build-arg VARIANT --file services/runtime.Dockerfile services
curved-television-6568
06/29/2022, 3:41 PMservices
on the docker build line there is the context root.curved-television-6568
06/29/2022, 3:43 PMdocker_image(context_root="", ...)
in order to include all files in you sandbox in the build context.curved-television-6568
06/29/2022, 3:43 PMCOPY
instructions, mind you.thousands-plumber-33255
06/29/2022, 3:43 PMcontext_root=""
did the trick. Thank you! Learned something new again!curved-television-6568
06/29/2022, 3:45 PM