4

I was trying to create a docker image for my python script and upload it to AWS ECR and then use it in Lambda. Our python runtime is 3.8 shown on the AWS console so I just followed this manual: https://docs.aws.amazon.com/lambda/latest/dg/images-create.html#images-create-from-base

But I got the error when I run docker build -t image-name .

#6 14.02 gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/var/lang/include/python3.8 -c bitarray/_bitarray.c -o build/temp.linux-x86_64-3.8/bitarray/_bitarray.o
#6 14.02 unable to execute 'gcc': No such file or directory
#6 14.02 error: command 'gcc' failed with exit status 1

I double checked and I have gcc installed on my macOS:

Warning: gcc 11.2.0 is already installed and up-to-date.
To reinstall 11.2.0, run:
brew reinstall gcc

Would appreciate some help on resolving this. thanks!

EDIT: This issue originates from me unable to import a CPython library cytoolz when running my script on Lambda, so I consulted these issues to simulate the runtime using docker. https://github.com/Miserlou/Zappa/issues/1717#issuecomment-445821158 https://github.com/ethereum/web3.py/issues/1456#issuecomment-866862759

If there is a better way to import cytoolz without using docker I would also def appreciate some hints!

Thx!!

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
BigCousin
  • 41
  • 1
  • 3
  • 1
    gcc needs to be installed in the Docker container. The build process doesn't use any software installed on the host (except docker itself). – Hans Kilian Oct 12 '21 at 06:17
  • @Hans Kilian hey thanks Hans. I've updated my docker file to `RUN yum groups mark install "Development Tools" RUN yum groups mark convert "Development Tools" RUN yum groupinstall "Development Tools"` However I still get `executor failed running [/bin/sh -c yum groupinstall "Development Tools": exit code: 1` I consulted this [post](https://access.redhat.com/solutions/1310043) but with no avail. Do you have any hints on how to work around this? – BigCousin Oct 13 '21 at 22:16
  • 5
    No, sorry. I don't have much experience with yum or aws images. If the base image you use is Debian or Ubuntu based, I'd try installing gcc with `RUN apt-get update && apt-get install -y build-essential`. – Hans Kilian Oct 14 '21 at 06:09

1 Answers1

3

Add the below commands to get requried things installed.

RUN yum update -y

RUN yum groupinstall 'Development Tools' -y

Sample Dockerfile:

FROM public.ecr.aws/lambda/python:3.9

RUN yum update -y

RUN yum groupinstall 'Development Tools' -y

RUN pip --version
DilLip_Chowdary
  • 841
  • 4
  • 18