You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm running into some trouble compiling for a slim container as I want to keep image size down. This is my Dockerfile where I first compile in the provided maturin container and then copy everything needed over to a slimmer image as soon as I have the wheel ready.
###################################### BUILD IMAGE ###############################################
FROM ghcr.io/pyo3/maturin AS build
# Copying all Rust source over
COPY src src
COPY Cargo.toml Cargo.toml
COPY rust-toolchain.toml rust-toolchain.toml
# Get dependencies for Python
COPY pyproject.toml pyproject.toml
# Copying Python source code
COPY project/modules /io/project/modules
COPY project/main.py /io/project/main.py
RUN maturin build -r --manylinux off
###################################### PROD IMAGE ###############################################
FROM python:3.9-slim-bullseye AS exec
COPY --from=build /io/project /app/project
RUN mkdir -p /app/target/wheels
COPY --from=build /io/target/wheels /app/target/wheels
WORKDIR /app
COPY project/requirements.txt /app/project/requirements.txt
RUN pip install -r /app/project/requirements.txt
RUN ls /app/target/wheels | xargs -I {} pip install /app/target/wheels/{}
ENTRYPOINT ["python3", "project/main.py"]
Unfortunately, when running the prod image, all functions included on the Rust side disappear:
docker run project:many
['__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__']
Traceback (most recent call last):
File "/app/project/main.py", line 149, in <module>
project.test_call_func()
where as my local environment produces
python3 project/main.py
['__all__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'test_call_func']
SUCCESS! You called this Rust function from Python.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hey everybody,
I'm running into some trouble compiling for a slim container as I want to keep image size down. This is my Dockerfile where I first compile in the provided maturin container and then copy everything needed over to a slimmer image as soon as I have the wheel ready.
Unfortunately, when running the prod image, all functions included on the Rust side disappear:
where as my local environment produces
Any help is appreciated!
Beta Was this translation helpful? Give feedback.
All reactions