Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dockerfile for containerizing #242

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM node:12.22-buster-slim as gui

RUN apt-get update && apt-get install -y libgtk-3-0 libx11-xcb1 libxss1 libgconf-2-4 libnss3 libasound2

WORKDIR /app
COPY . .
RUN yarn --network-timeout 100000

EXPOSE 1212
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might need to expose more ports to allow communication like 8081 or the environmental variable ${PORT} could be handled with the ARG/ENV Dockerfile annotations

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should only need a single exposed port to talk to the server on the RPi. The DPU/calibrations scripts that get kicked off via the GUI communicate with the RPi through the same port (<evolver_ip>:8081 by default). The GUI also needs to be able to access the file system of the machine its running on and any mounted drives.

Locations of python scripts being run:
https://github.com/FYNCH-BIO/evolver-electron/blob/master/app/main.dev.js#L85
https://github.com/FYNCH-BIO/evolver-electron/blob/master/app/main.dev.js#L118

And the relevant DPU scripts which are run:
https://github.com/FYNCH-BIO/dpu/blob/master/experiment/template/eVOLVER.py
https://github.com/FYNCH-BIO/dpu/blob/master/calibration/calibrate.py

CMD ["yarn","dev"]
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,37 @@ $ mv evolver-electron-1.0.0.AppImage-new evolver-electron-1.0.0.AppImage
$ sudo reboot now
```

## Docker Build and Run

Download and install Docker.

+ Linux: check your package manager / distribution instructions.
+ Mac: [Instructions](https://docs.docker.com/docker-for-mac/install/)
+ Windows: [Instructions](https://docs.docker.com/docker-for-windows/install/) (Windows 10) / [Instructions](https://docs.docker.com/toolbox/toolbox_install_windows/) (Windows 7/8)

Pull, and Build the image:
```bash
docker build -t evolver-electron .
docker run -p 1212:1212 -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY:0 evolver-electron
```

### Docker Additional Requirement
eVOLVER relies on x11 as a GUI which can be installed following the instructions below and replacing the environmental variable `DISPLAY=$DISPLAY:0` with an appropriate line from `Docker Environmental Variables` sub-section

Macs, can install [xQuartz](https://www.xquartz.org/) with additional configuration [here](https://gist.github.com/cschiewek/246a244ba23da8b9f0e7b11a68bf3285)
Windows, can install [Cygwin](https://x.cygwin.com/) with additional configuraiton [here](https://www.kombitz.com/2020/01/31/how-to-configure-cygwin-x-for-remote-connection/)
A restart may be needed after installation, but a test container can be ran via:
```bash
docker run -p 1212:1212 -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY:0 nonasoftware/evolver-electron:latest
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be changed, but just wanted a registry to store the image. I also have some Github Actions scripts I can add in to auto build and upload on PRs, manually, and/or on commit to master

```

### Docker Environmental Variables
```
macOS: -e DISPLAY=docker.for.mac.host.internal:0
Windows: -e DISPLAY=host.docker.internal:0
Linux: --net=host -e DISPLAY=:0
```

## Credit

- [Zachary Heins](https://github.com/zheins)
Expand Down