Dockerfile distroless unable to locate custom module

366 Views Asked by At

I have two folders:

scripts/

  • main.py

source/

  • memory.py

My dockerfile ( I am using example from https://github.com/GoogleContainerTools/distroless/blob/main/examples/python3-requirements/Dockerfile) :

FROM debian:11-slim AS build

RUN mkdir scripts
COPY source source
COPY scripts/main.py scripts/main.py

RUN apt-get update && \
    apt-get install --no-install-suggests --no-install-recommends --yes python3-venv gcc libpython3-dev && \
    python3 -m venv /venv && \
    /venv/bin/pip install --upgrade pip setuptools wheel

FROM gcr.io/distroless/python3-debian11
COPY --from=build /venv /venv
COPY . /app
WORKDIR /app
ENV PYTHONPATH /source

ENTRYPOINT ["/venv/bin/python3", "scripts/main.py"]

I get the following:

Traceback (most recent call last):

File "/app/scripts/main.py", line 5, in

import memory as mm

ModuleNotFoundError: No module named 'memory'

my main.py:

#!/usr/bin/env python3


import memory as mm

...
0

There are 0 best solutions below