Skip to content

Instantly share code, notes, and snippets.

@b2m
Last active March 25, 2022 10:27
Show Gist options
  • Save b2m/d29c9e5dba9658bb3e5aad6d6d93c3bb to your computer and use it in GitHub Desktop.
Save b2m/d29c9e5dba9658bb3e5aad6d6d93c3bb to your computer and use it in GitHub Desktop.
Put browse-ocrd into a docker container
docker build --tag browse-ocrd .
FROM python:3.7
RUN apt-get update \
&& apt-get install -y --no-install-recommends libcairo2-dev libgtk-3-bin libgtk-3-dev libglib2.0-dev libgtksourceview-3.0-dev libgirepository1.0-dev gir1.2-webkit2-4.0 pkg-config cmake \
&& pip3 install -U setuptools --use-feature=2020-resolver \
&& pip3 install browse-ocrd --use-feature=2020-resolver
ENV GDK_BACKEND broadway
ENV BROADWAY_DISPLAY :5
EXPOSE 8085
COPY init.sh /init.sh
RUN chmod +x /init.sh
CMD ["/init.sh"]
#!/usr/bin/env bash
set -x
nohup broadwayd :5 &
browse-ocrd /data/mets.xml
docker run -it --rm -v ${WORKSPACE}:/data -w /data -p 8085:8085 browse-ocrd
@b2m
Copy link
Author

b2m commented Oct 29, 2020

Using GTK Broadway to put browse-ocrd into a docker environment and make it accessible via Browser.

This is just a test and not production ready!

Usage:

  1. First download Dockerfile and init.sh
  2. Run the build command from build.sh in the directory of the Dockerfile and init.sh.
  3. Set the WORKSPACE environment variable and point it to your OCR-D Workspace.
  4. Run the run command from run.sh.
  5. Open http://localhost:8085/ in your browser.

@bertsky
Copy link

bertsky commented Oct 29, 2020

Fantastic!

2 tips:

  • I got docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"/init.sh\": permission denied": unknown. and fixed it with chmod +x init.sh and rebuild
  • HTTPS does not work, HTTP does

@b2m
Copy link
Author

b2m commented Oct 30, 2020

Thank you for the feedback.

* I got `docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"/init.sh\": permission denied": unknown.` and fixed it with `chmod +x init.sh` and rebuild

Added chown to the Dockerfile... on windows files are added with -rwxr-xr-x so I did not notice.

* HTTPS does not work, HTTP does

Funny how muscle memory automatically types https even when I try to type http.
Also corrected in my first comment.

@bertsky
Copy link

bertsky commented Mar 25, 2022

@b2m, with current Ubuntu/Debian repos (even just python:3.7), we get the following problem at run time:

Namespace WebKit2 not available

But installing gir1.2-webkit2-4.0 would pull in a full gnome-shell ...

@b2m
Copy link
Author

b2m commented Mar 25, 2022

Thx @bertsky for your comment. As you already figured out gir1.2-webkit2-4.0 was missing from the dependencies.

I do not know whether it was an indirect dependency before or it is a new dependency from browse-ocrd or it's libraries.

But installing gir1.2-webkit2-4.0 would pull in a full gnome-shell ...

Fortunately not as I am installing it with the option --no-install-recommends.

I updated this gist accordingly.

@bertsky
Copy link

bertsky commented Mar 25, 2022

I updated this gist accordingly.

and the wiki, too, you did already. Many thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment