brefphp / extra-php-extensions

Community-maintained extra PHP extensions usable in AWS Lambda with the Bref PHP runtimes.
https://bref.sh/docs/environment/php.html#extra-extensions
213 stars 109 forks source link

docker error: "tar" executable not found in $PATH #80

Closed terox closed 4 years ago

terox commented 4 years ago

Hello!

I am trying to test a new layer before send the PR, but when I execute the make layers docker shows me an error:

docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"tar\": executable file not found in $PATH": unknown.
ERRO[0000] error waiting for container: context canceled 

I lost some hours trying to understand what is happening. Is only happening to me or maybe is general? I think that some is wrong in the main docker imagebref/build-php-XX because seems that tar command is not available. But I am not sure.

Anybody can help me to fix it with some clue?

Thank you so much

gocebonev commented 4 years ago

I am guessing you are using scratch as the final image. Change it to lambci/lambda:provided and it works. Related to changes introduced in #75

mnapoli commented 4 years ago

Oh that's an interesting point @gocebo, maybe @shouze is there anything to improve in the instructions or docs if scratch changes a few things for users? I'm not really sure about the impact here.

shouze commented 4 years ago

@terox could you please either send the PR as a draft of give me an example of how to reproduce? :angel:

gocebonev commented 4 years ago

@terox Downloading the latest repo and running make layers reproduces the problem but this line is the issue https://github.com/brefphp/extra-php-extensions/blob/cc8428c829d28dfccc63c7495668e58bedbf2715/Makefile#L48 since there is no tar entrypoint in scratch.

shouze commented 4 years ago

@terox Downloading the latest repo and running make layers reproduces the problem but this line is the issue

https://github.com/brefphp/extra-php-extensions/blob/cc8428c829d28dfccc63c7495668e58bedbf2715/Makefile#L48 since there is no tar entrypoint in scratch.

Ok my fault indeed. The fix will be probably straight forward as docker already have a built in command to produce a tar from a docker image. Will send a fix 🔜

terox commented 4 years ago

@gocebo os in the track. That line is the problematic. Waiting the fix. Thanks for the help. When all is ready I will try all again

shouze commented 4 years ago

Ok docker image save does not produces the output I expected, it will be a little more complicated.

# effectively produces a tar
docker image save bref/layers/gd-php-74 > output.tar
# But when I untar...
tar -x -f output.tar
# I obtain all the layers whith json files describing them
ls
02b29024ea229d5dc79752905acc6f41bff3465a2654ed63c0da0e41e9b72beb/
0f972130cc2b0ea162d574b9b0e07536bec0ec224b710a90ad62fd7225eb8982/
88592bfb09ca523eb8042d6d0cd5aa9431833ed2d2e2972581c973becf183b72/
eff5cd62635634639eb272f0ee96cd64668616870fa54efe1b0654007ba794de.json
manifest.json
repositories
# Especially this one that can be used to iterate over each layer to untar
cat manifest.json | jq -r '.[0].Layers'
[
  "02b29024ea229d5dc79752905acc6f41bff3465a2654ed63c0da0e41e9b72beb/layer.tar",
  "88592bfb09ca523eb8042d6d0cd5aa9431833ed2d2e2972581c973becf183b72/layer.tar",
  "0f972130cc2b0ea162d574b9b0e07536bec0ec224b710a90ad62fd7225eb8982/layer.tar"
]
# And when I untar each one I obtain the reconstitution of the filesystem 
# that we want to export as a layer in a zip file
Nyholm commented 4 years ago

So.. This means I cannot deploy the new layers. Since I need to run tar.

Is there a workaround? Or should we create "scratch with tar"?

shouze commented 4 years ago

@Nyholm scratch with tar could be alpine for example, as scratch has no os, no libc and so on, this is an empty image.

As it's a bit harder to fix than expected with scratch (my previous comment), you can replace scratch everywhere by the smallest possible docker image, alpine for example (I've searched for a minimal tar docker image but didn't find any). Then I we will be able to rollback to scratch but this time taking make layers into account.

terox commented 4 years ago

Ok docker image save does not produces the output I expected, it will be a little more complicated.

# effectively produces a tar
docker image save bref/layers/gd-php-74 > output.tar
# But when I untar...
tar -x -f output.tar
# I obtain all the layers whith json files describing them
ls
02b29024ea229d5dc79752905acc6f41bff3465a2654ed63c0da0e41e9b72beb/
0f972130cc2b0ea162d574b9b0e07536bec0ec224b710a90ad62fd7225eb8982/
88592bfb09ca523eb8042d6d0cd5aa9431833ed2d2e2972581c973becf183b72/
eff5cd62635634639eb272f0ee96cd64668616870fa54efe1b0654007ba794de.json
manifest.json
repositories
# Especially this one that can be used to iterate over each layer to untar
cat manifest.json | jq -r '.[0].Layers'
[
  "02b29024ea229d5dc79752905acc6f41bff3465a2654ed63c0da0e41e9b72beb/layer.tar",
  "88592bfb09ca523eb8042d6d0cd5aa9431833ed2d2e2972581c973becf183b72/layer.tar",
  "0f972130cc2b0ea162d574b9b0e07536bec0ec224b710a90ad62fd7225eb8982/layer.tar"
]
# And when I untar each one I obtain the reconstitution of the filesystem 
# that we want to export as a layer in a zip file

I don't understand exactly what is the issue with "docker image save", but I understand that tar result tar contains all image files and not the raw "extension" or binary that was the expected behaviour? Sorry I am not an expert in Docker at this levels. In other case seems a little tricky issue but not impossible to solve :)

When we have all ready I can test the make layers in my computer to ensure that is fine. I will not able to publish my extension as a PR because it was about msgpack and it is merged now from other contributor. But, in any case I can send some feedback from this issue.

Nyholm commented 4 years ago

I think the issue is this:

When we use the docker images, we really want to use scratch because it is small.

However, when one is creating aws layers, we are only interested in the files, so we use tar to get the files from the docker image.

I can see if I'll write up a solution today.

shouze commented 4 years ago

@terox this is not impossible to solve, I have a good idea in fact on how to solve it :smile: : simply extract all the sub tar(s) of docker save image to reconstitute a zippable exported filesystem.

This is why I've exposed so far where I am in https://github.com/brefphp/extra-php-extensions/issues/80#issuecomment-707514769: to resume quickly on this issue when I'll find a time slot to dedicate :wink:

Nyholm commented 4 years ago

https://github.com/brefphp/extra-php-extensions/pull/82

shouze commented 4 years ago

@Nyholm you hacker :clap: :pirate_flag:

terox commented 4 years ago

@terox this is not impossible to solve, I have a good idea in fact on how to solve it : simply extract all the sub tar(s) of docker save image to reconstitute a zippable exported filesystem.

This is why I've exposed so far where I am in #80 (comment): to resume quickly on this issue when I'll find a time slot to dedicate

I understand much better the intentions! :)