-
-
Save qtangs/69e0db74313e8b97708b88f9a7db9bfb to your computer and use it in GitHub Desktop.
#!/bin/bash | |
export PKG_DIR="python" | |
rm -rf ${PKG_DIR} && mkdir -p ${PKG_DIR} | |
docker run --rm -v $(pwd):/foo -w /foo lambci/lambda:build-python3.6 \ | |
pip install -r requirements.txt --no-deps -t ${PKG_DIR} |
the requirements.txt should be in the current directory. If you don't run the bash or Docker command in the same directory, switch to that directory or change the path to /requirements.txt
I still got the error even the file is in the current directory. I also tried the absolute path but still the same error.
I fixed it by copying the code directly from this gist and it just works without any errors.
This is a very helpful gist. Note that if you're running the commands outside of bash via Powershell on Windows, you'll need to add quotes around the -v portion of the argument: -v "$(pwd):/foo"
.
if you receive error: docker: invalid reference format: repository name must be lowercase.
Then add quotes around $pwd if you have spaces in your patch to working directory. It should look like that.
docker run --rm -v "$(pwd)":/foo -w /foo lambci/lambda:build-python3.6 \
pip install -r requirements.txt --no-deps -t ${PKG_DIR}
Thank you so much for this script!
I've tried quotes and no quotes around $(pwd)
. I also tried writing the file path to my current working directory in to the script and adding a cd
to the correct directory at the beginning.
However, I keep getting the same result --
docker: Error response from daemon: the working directory 'C:/Program Files/Git/foo' is invalid, it needs to be an absolute path.
I'm running the script from inside Git Bash on Windows 10. Any thoughts on what I'm doing wrong?
I was following your article https://medium.com/@qtangs/creating-new-aws-lambda-layer-for-python-pandas-library-348b126e9f3e. very interesting and useful post. But when I execute this shell script, I get the following error message
Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'
and my folder structure is the same as yours in your post. Wonder if you could shed some light. thanks.