Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker and Plotly

I created a python script using plotly dash to draw graphs, then using plotly-orca to export a static image of the created graph. I want to dockerise this script but my problem is I build and run the image i get a "The orca executable is required in order to export figures as static images" error. My question now is how do I include the executable as part of my docker image?

like image 530
theBean Avatar asked Sep 08 '25 08:09

theBean


2 Answers

It's a bit complicated due to the nature of plotly-orca, but it can be done, according to this Dockerfile based on this advice. Add this to your Dockerfile:

# Download orca AppImage, extract it, and make it executable under xvfb
RUN apt-get install --yes xvfb
RUN wget https://github.com/plotly/orca/releases/download/v1.1.1/orca-1.1.1-x86_64.AppImage -P /home
RUN chmod 777 /home/orca-1.1.1-x86_64.AppImage 

# To avoid the need for FUSE, extract the AppImage into a directory (name squashfs-root by default)
RUN cd /home && /home/orca-1.1.1-x86_64.AppImage --appimage-extract
RUN printf '#!/bin/bash \nxvfb-run --auto-servernum --server-args "-screen 0 640x480x24" /home/squashfs-root/app/orca "$@"' > /usr/bin/orca
RUN chmod 777 /usr/bin/orca
RUN chmod -R 777 /home/squashfs-root/
like image 170
proinsias Avatar answered Sep 10 '25 02:09

proinsias


I would just upgrade to plotly 4.9 or newer, and use kaleido through pip - an official substitute for Orca which has been a pain to setup with docker. https://plotly.com/python/static-image-export/

like image 43
ahmedhosny Avatar answered Sep 10 '25 01:09

ahmedhosny