Raj Rajeshwari Prasad
Raj Rajeshwari Prasad

Reputation: 334

Using PIConnect in Docker Container

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.

Upvotes: 2

Views: 345

Answers (1)

Nilesh Zagade
Nilesh Zagade

Reputation: 31

A bit late for this but no its not possible to run PIConnect in Container. PIConnect needs AF SDK to be installed which is automatically installed when PI AF Client Tools are installed. You can force load it into linux however AF SDK was built for windows only and uses propeitary Windows networking stack.

Aveva is working on a .net 8 version which looks like it will be completely decoupled however they haven't priortised Linux support.

The next best way is to use PI WebAPI.

Upvotes: 1

Related Questions