Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installing libraries in Docker via git #28004

Closed
nicor88 opened this issue Nov 15, 2023 · 3 comments
Closed

Installing libraries in Docker via git #28004

nicor88 opened this issue Nov 15, 2023 · 3 comments
Labels
@aws-cdk/aws-lambda Related to AWS Lambda bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@nicor88
Copy link

nicor88 commented Nov 15, 2023

Describe the bug

When using Lambdas with Docker, or when building ECS containers, I want to be able to install python libraries from via git.

e.g. I want to install git+https://github.com/dbt-athena/dbt-athena@main

When trying to do that I get this error:

ERROR: Error [Errno 2] No such file or directory: 'git' while executing command git version

Expected Behavior

I should be able to install a python library hosted in git.

Current Behavior

Considering that git is not available in the lambda packaging Docker image, I'm not able to install install librabries from git

Reproduction Steps

const MyLambda = new lambda.DockerImageFunction(
      this,
      "MyLambda",
      {
        code: lambda.DockerImageCode.fromImageAsset(
          path.join(__dirname, "./lambdas/my_lambda")
        ),
        timeout: cdk.Duration.seconds(900),
        memorySize: 4096,
        logRetention: logs.RetentionDays.ONE_WEEK,
      }
    );

inside my_lambda I have thi structure:

  • Dockerfile
  • requirementst.txt
  • app/
    • main.py

Dockerfile content

FROM public.ecr.aws/lambda/python:3.12
# Install the function's dependencies using file requirements.txt
# from your project folder.
COPY requirements.txt  .
RUN  pip3 install -r requirements.txt --target "${LAMBDA_TASK_ROOT}"
# Copy function code
COPY app/main.py ${LAMBDA_TASK_ROOT}
# Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile)
ADD app/components components
CMD [ "main.handler" ]

requirements.txt

awswrangler==3.4.2
requests==2.31.0
git+https://github.com/dbt-athena/dbt-athena@main

Possible Solution

Having git installed in the Docker packaing

Additional Information/Context

No response

CDK CLI Version

2.91.0

Framework Version

No response

Node.js Version

v18.0.0

OS

MacOs

Language

TypeScript

Language Version

No response

Other information

No response

@nicor88 nicor88 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 15, 2023
@github-actions github-actions bot added the @aws-cdk/aws-lambda Related to AWS Lambda label Nov 15, 2023
@nicor88
Copy link
Author

nicor88 commented Nov 15, 2023

Simply resolved adding RUN yum -y install git to my Dockerfile :)

@nicor88 nicor88 closed this as completed Nov 15, 2023
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@dennybiasiolli
Copy link

Thanks for the hint @nicor88 , I'm using public.ecr.aws/lambda/python:3.12 and I resolved the same issue adding
RUN dnf -y install git to my Dockerfile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-lambda Related to AWS Lambda bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

2 participants