Open albertbuchard opened 2 years ago
Hi, @albertbuchard!
Thank you for the detailed description of the problem. We have built and added packages for the arm64
architecture and tested according to the process you have described above.
Could you please check if it solve the issue and confirm that?
Hi @shadinua,
I have the exact same issue bug report as @albertbuchard.
Am I using the wrong base image? Thank you so much for your help.
Describe the bug Docker image fails to build
To Reproduce Steps to reproduce the behavior:
ARG FUNCTION_DIR="/function"
FROM python:3.10 as build-image
ARG FUNCTION_DIR
RUN mkdir -p ${FUNCTION_DIR} COPY . ${FUNCTION_DIR}
RUN pip install \ --target ${FUNCTION_DIR} \ awslambdaric
RUN apt update && \ apt -y install apt-transport-https
RUN wget -qO - https://pkgs-ce.cossacklabs.com/gpg | apt-key add - RUN echo "deb https://pkgs-ce.cossacklabs.com/stable/debian buster main" | tee /etc/apt/sources.list.d/cossacklabs.list RUN apt update && apt install -y libthemis-dev
FROM python:3.10-slim
ARG FUNCTION_DIR
WORKDIR ${FUNCTION_DIR}
COPY --from=build-image ${FUNCTION_DIR} ${FUNCTION_DIR}
ENTRYPOINT [ "/usr/local/bin/python", "-m", "awslambdaric" ]
CMD [ "lambda_function.handler" ]
3. Run `docker build -t docker-image:test .`
4. See the following error:
ERROR: failed to solve: process "/bin/sh -c apt update && apt install -y libthemis-dev" did not complete successfully: exit code: 100
**Expected behavior**
Docker to build
**Environment (please complete the following information):**
- OS: OSX 13.3.1 Ventura
- Hardware: 64-bit Mac
- Themis version: 0.15.0 Newest
- Installation way:
- [ ] via package manager
- [X] built from docker
**Additional context**
Add any other relevant context for the problem here. Share an example project, if you can.
python:3.10 image uses debian:bookworm as base image that is not supported yet. please, try to use python:3.10-bullseye
FROM public.ecr.aws/lambda/python:3.10
# Copy requirements.txt
COPY requirements.txt ${LAMBDA_TASK_ROOT}
# Copy function code
COPY lambda_function.py ${LAMBDA_TASK_ROOT}
RUN yum update -y
# RUN yum install -y httpd
RUN rpm --import https://pkgs-ce.cossacklabs.com/gpg
RUN wget -qO - https://pkgs-ce.cossacklabs.com/stable/centos/cossacklabs.repo | tee /etc/yum.repos.d/cossacklabs.repo
RUN yum install libthemis-devel
# Install the specified packages
RUN pip install -r requirements.txt
# Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile)
CMD [ "lambda_function.handler" ]
that worked thank you @Lagovas.
now I need to transition the dockerfile to one of AWS's base images. This image is Amazon Linux based on RedHat to my knowledge. Do you have an idea why this fails?
I am not clear why yum cannot find libthemis-devel
[+] Building 4.4s (11/12)
=> [internal] load build definition from dockerfile 0.0s
=> => transferring dockerfile: 2.05kB 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for public.ecr.aws/lambda/python:3.10 0.9s
=> [1/8] FROM public.ecr.aws/lambda/python:3.10@sha256:19b2ea7fc3484f112f63b8dbc836847c1cd5ac41cf0305af8fdfa09b4470c9b6 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 75B 0.0s
=> CACHED [2/8] COPY requirements.txt /var/task 0.0s
=> CACHED [3/8] COPY lambda_function.py /var/task 0.0s
=> CACHED [4/8] RUN yum update -y 0.0s
=> [5/8] RUN rpm --import https://pkgs-ce.cossacklabs.com/gpg 1.4s
=> [6/8] RUN wget -qO - https://pkgs-ce.cossacklabs.com/stable/centos/cossacklabs.repo | tee /etc/yum.repos.d/cossacklabs.repo 0.3s
=> ERROR [7/8] RUN yum install libthemis-devel 1.8s
------
> [7/8] RUN yum install libthemis-devel:
#0 0.389 Loaded plugins: ovl
#0 1.683 No package libthemis-devel available.
#0 1.801 Error: Nothing to do
------
dockerfile:15
--------------------
13 | RUN rpm --import https://pkgs-ce.cossacklabs.com/gpg
14 | RUN wget -qO - https://pkgs-ce.cossacklabs.com/stable/centos/cossacklabs.repo | tee /etc/yum.repos.d/cossacklabs.repo
15 | >>> RUN yum install libthemis-devel
16 |
17 |
--------------------
ERROR: failed to solve: process "/bin/sh -c yum install libthemis-devel" did not complete successfully: exit code: 1
I'm unfamiliar with AWS and centos too much, and I'm not sure what repo structure AWS expects. We support, test and maintain repositories for centos 7/8, and temporarily latest version deployed only for x86_64. You can try to download .rpm manually from https://pkgs-ce.cossacklabs.com/stable/centos/8/x86_64/ and try to install it locally from the file. It may works if AWS expects different repo structure in comparison with centos 7/8 but okay with .rpm packages packed for them. And it may work only for x86_64, not arm64.
As I see, base image uses scratch
base image and install FS structure from archives - https://github.com/aws/aws-lambda-base-images/blob/python3.10/Dockerfile.python3.10 . So, it needs a time to investigate and debug.
Thanks for the response--and thanks for working on this lib. Yes, the base image was the key. By pivoting into the base image that you mentioned I finally got it, thank God. So, here's what I did for future reference:
# Define custom function directory
ARG FUNCTION_DIR="/function"
FROM python:3.10-bullseye as build-image
# Include global arg in this stage of the build
ARG FUNCTION_DIR
# Copy function code
RUN mkdir -p ${FUNCTION_DIR}
COPY . ${FUNCTION_DIR}
# Install the function's dependencies
RUN pip install --target ${FUNCTION_DIR} awslambdaric boto3 botocore pythemis
RUN apt update && apt install -y apt-transport-https wget gnupg
# Install themis
RUN wget -qO - https://pkgs-ce.cossacklabs.com/gpg | apt-key add -
RUN echo "deb https://pkgs-ce.cossacklabs.com/stable/debian bullseye main" | tee /etc/apt/sources.list.d/cossacklabs.list
RUN apt update && apt install -y libthemis-dev
WORKDIR ${FUNCTION_DIR}
Describe the bug When trying to dockerize themis using debian (buster or bullseye) - the dockerization stops at the installation of themis with error:
Unable to locate package libthemis-dev
To Reproduce Steps to reproduce the behavior:
Install themis
RUN wget -qO - https://pkgs-ce.cossacklabs.com/gpg | apt-key add - RUN echo "deb https://pkgs-ce.cossacklabs.com/stable/debian buster main" | tee /etc/apt/sources.list.d/cossacklabs.list RUN apt update && apt install -y libthemis-dev
error
Expected behavior Should find libthemis-dev
Environment (please complete the following information):
Additional context .