Docker with Python and Benthos

I am doing a project where there is a benthos script that insert some data into a cassandra db, but during the execution, with a function, benthos call a python script , that create and populate the cassandra database. I am trying building with docker:

  • i need to install python and Benthos
  • i need to install the python library for cassandra
  • like cmd , to start the benthos script

docker-compose that create 3 different service:

  • one for the db
  • one for the Python script
  • one for the Benthos script

dockerfile

FROM ubuntu:latest

WORKDIR /home

RUN apt-get update && apt-get upgrade -y &&  \ 
    apt-get install -y python3 python3-pip python3-venv curl && \
    apt-get clean

RUN python3 -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"

RUN pip install --upgrade pip

RUN pip install cassandra-driver

RUN curl -L -o /usr/local/bin/benthos https://github.com/benthosdev/benthos/releases/download/v4.8.0/benthos-linux-amd64 \
    && chmod +x /usr/local/bin/benthos

COPY ./src /home

USER 1000

CMD ["benthos", "-c", "/home/main.yaml"]

Do you think is the best way using an ubuntu image and install on it evrything. I have defined a Python virtual environment to include the virtual environment’s binaries, making python and pip available globally in the container. it Is correct this choice ?

DockerCompose

services:
  benthos:
    image: benthos-study
    build:
     context: .
     dockerfile: ./Dockerfile  
    ports:
      - 8010:4195
    volumes:
      - ./src:/home/src/
    container_name: benthos-container
    stdin_open: true
    tty: true
    depends_on:
      database:
        condition: service_healthy
        
  app:
    build: 
      context: .
      dockerfile: ./Dockerfile
    volumes:
      - ./src:/home/src/
    container_name: python-container
    depends_on:
      database:
        condition: service_healthy

  database:
    image: cassandra:latest
    ports:
      - 9042:9042
    container_name: cassandra-container
    healthcheck:
      test: ["CMD-SHELL", "cqlsh -u cassandra -p cassandra -e 'DESCRIBE KEYSPACES'"]
      interval: 30s
      timeout: 10s
      retries: 5

The build don’t give me any type of error, but when i trie to execute, The cassandra container work, but the oder two no, this is the error:

python-container     | exec /usr/local/bin/benthos: exec format error
benthos-container    | exec /usr/local/bin/benthos: exec format error
python-container exited with code 1
benthos-container exited with code 1