I am trying to contenerize my code which comprises PIConnect library. Below is my dockerfile.
ARG PYTHON_VERSION=3.10.11
FROM python:${PYTHON_VERSION}-slim as base
RUN pip install piaf
RUN apt-get update && \
apt-get install -y mono-complete
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
WORKDIR /app
ARG UID=10001
RUN adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${UID}" \
appuser
RUN pip install PIConnect
RUN pip install pythonnet
RUN --mount=type=cache,target=/root/.cache/pip \
--mount=type=bind,source=requirements.txt,target=requirements.txt \
python -m pip install -r requirements.txt
ENV PYTHONPATH=$PYTHONPATH:/usr/local/lib/python3.10/site-packages/PIAF_SDK:$PWD
USER appuser
COPY . .
EXPOSE 8000
RUN mono --version
CMD ["python", "main.py", "--data_dir2", "/container/path2"]
After the container is succesfully build, when I try to run it, I get the following error:
/usr/local/lib/python3.10/site-packages/clr_loader/mono.py:180: UserWarning: Hosting Mono versions before v6.12 is known to be problematic. If the process crashes shortly after you see this message, try updating Mono to at least v6.12.
warnings.warn(
Traceback (most recent call last):
File "/app/main.py", line 18, in <module>
import PIconnect as PI
File "/usr/local/lib/python3.10/site-packages/PIconnect/__init__.py", line 5, in <module>
from PIconnect.AFSDK import AF, AF_SDK_VERSION
File "/usr/local/lib/python3.10/site-packages/PIconnect/AFSDK.py", line 54, in <module>
raise ImportError("PIAF SDK not found, check installation")
ImportError: PIAF SDK not found, check installation
Can someone please let me know whats the issue. Is it even possible to encorporate PIConnect sdk inside a container.