deno-lambda icon indicating copy to clipboard operation
deno-lambda copied to clipboard

Working Directory is ignored in the Docker Image

Open wperron opened this issue 4 years ago • 3 comments

I have the following configuration in Terraform:

resource "aws_lambda_function" "this" {
  # ...
  image_config {
    working_directory = "/var/task/foo/bar"
    command           = ["baz.handler"]
  }
}

but the bootstrap script seems to be ignoring the working_directory parameter and tries to import /var/task/baz.js instead of /var/task/foo/bar/baz.js - as a workaround I commented out the parameter and changed the command to ["foo/bar/baz.handler"]

wperron avatar Dec 21 '20 14:12 wperron

Atm CMD ["foo/bar/baz.handler"] is the way forward. In some sense that's not a workaround but has always been the way to reference files not at the top level.

It's unclear to me how to support working directory... i need to think about it a little more... what you are supposed to do with LAMBDA_TASK_ROOT vs WORKDIR? 🤔

hayd avatar Dec 22 '20 15:12 hayd

We should run some tests with some of the default runtimes to see how they behave, that might enlighten us as to how to support workdir for the deno runtime.

wperron avatar Dec 22 '20 15:12 wperron

Not looked into this but my suspicion is what should be done is cd into /var/task and realpath the WORKDIR (initial directory).

# realpath -m --relative-to="/var/task/" "/var/task/foo/bar/baz.handler"
foo/bar/baz.handler

and use this as the HANDLER (if WORKDIR=LAMBDA_TASK_ROOT then above is a noop).

However, for sure there will need to be DENO_DIR tweak (since it's relative atm, but shouldn't be really).

hayd avatar Dec 22 '20 19:12 hayd