Reputation: 716
I am using this Docker (FROM lambci/lambda:python3.6) and I need to install a private repository package. The problem is the Docker does not have git and I can not install git using apt-get or apk install because the Docker is not Linux.
Is there any possible way to fix this installing git? Or is there any other better method I could use to install this private repository package?
Upvotes: 9
Views: 14164
Reputation: 21
FROM python:3.9 as builder
RUN pip install --target /tmp/site-packages "git+GIT_URL"
FROM public.ecr.aws/lambda/python:3.9
COPY --from=builder /tmp/site-packages /var/lang/lib/python3.9/site-packages
You could use python:3.9 which has git, or any other image to install dependancies and then copy it into the AWS image.
To find the site-packages location, just use python -m site
in a lambda container
Upvotes: 2
Reputation: 102
in your dockerfile put this code before installing requirements and you will be fine:
RUN apt-get update && apt-get install -y git
Upvotes: 2
Reputation: 716
add this to makefile:
# makefile
git clone REPO
cd REPO_DIR; python setup.py bdist_wheel
cp REPO_DIR/dist/* .
rm -rf REPO_DIR/
add this to dockerfile:
# dockerfile
RUN pip install REPO*.whl
and then the package is successfully installed within docker
Upvotes: 4
Reputation: 1118
can you pip install
the git repo next to your source code and mount it together with your code into the container?
cd WORKING_DIRECTORY
pip install --target ./ GIT_URL
Upvotes: 0