Skip to content

Commit

Permalink
Added basic docker builds.
Browse files Browse the repository at this point in the history
  • Loading branch information
phockett committed Apr 16, 2024
1 parent 83c71d4 commit e212212
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 0 deletions.
37 changes: 37 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# frogDAQ install with Jupyterlab Open stacks base (UB22)
# 16/04/24
#
#
# For test builds
# docker build -t frogdaq:vXXXX .
#
# Run (with sudo)
# docker run -it -p 9119:8888 --user root -e GRANT_SUDO=yes frogdaq
#
# To autoremove on stop, add --rm to run command
#
# For USB device access, see https://stackoverflow.com/a/66427245
#
# TEST BUILDS... (note need SUDO for seabreeze config testing)
# docker run -it --rm -v ~/github/frogDAQ:/home/jovyan/frogDAQ -p 9119:8888 --user root -e GRANT_SUDO=yes -e NB_USER="jovyan" frogdaq:v160424 bash

# Use full scipy notebook, see https://jupyter-docker-stacks.readthedocs.io/en/latest/using/selecting.html
# 23/01/23 - force to python 3.8 build, can't install Spinnaker whl otherwise!
# https://hub.docker.com/layers/jupyter/scipy-notebook/x86_64-python-3.8.13/images/sha256-e3b039665109ca38ecf173b548b13ecaca7e2f92755f5175e0c48253fbc482d6?context=explore
# FROM jupyter/scipy-notebook:x86_64-python-3.8.13

# Latest build
FROM jupyter/scipy-notebook

# Set user to root for installers below.
# TODO 21/02/24: change to Jovyan for Conda env creation and/or fix perms and/or run with SUDO - currently have some weird perm issues otherwise, e.g. `conda run -n spinnaker python --version` fails for Jovyan user.
# USER root

# Copy source - use local version?
# COPY ../frogDAQ . # Failing with relative parent here?
# COPY /home/paul/github/frogDAQ ./frogDAQ
# COPY ./install_prereqs.sh

# Or just pull...
# Note optional @branch here
# RUN pip install --no-deps git+https://github.com/phockett/frogDAQ@updatesApril2024
65 changes: 65 additions & 0 deletions docker/install_prereqs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/env bash

# Minimal installer for frogDAQ prerequisites
#
# NOTE: this uses pip to install libs, if using virtual envs please first activate desired env!
#
# v1 16/04/24 For Docker builds.
#

# Set working dir, defaults to cwd
WORKINGDIR=${1:-$(pwd)}
REPODIR=${2:-$(cd ../ && pwd)}

echo "Working dir: ${WORKINGDIR}"
echo "Repo/parent dir: ${REPODIR}"

#*** FROGLIB, https://github.com/xmhk/froglib
# Clone repo
echo "Cloning Froglib"
cd $REPODIR
git clone https://github.com/xmhk/froglib.git
# Add setup file patch to allow for pip install.
cp ${WORKINGDIR}/patches/setup_froglib.py ${REPODIR}/froglib/setup.py

#*** Install local repos
echo "Running 'pip install -e .' for local repos..."
cd $WORKINGDIR
pip install -e .

cd ${REPODIR}/froglib
pip install -e .

#*** Install other repos
echo "Installing pyserial and NewportESP libs..."

# Install from https://pypi.org/project/NewportESP, may need patching
# pip install NewportESP

# Install local patched version
cd $WORKINGDIR/patches/newportESP-1.1
pip install .

pip install pyserial

# pip install NewportESP
# conda install pyserial

# NOTE - currently need to replace NewportESP with frogDAQ/patches/NewportESPbyte.py - not sure how to automate this (with conda this is in something like <conda user dir>/<env>/site-packages)
# In test Docker builds, /opt/conda/lib/python3.9/site-packages/newportESP.py
# UPDATE: now use frogDAQ/patches/newportESP-1.1 instead. Should push to Github?



#*** pySEABREEZE, from https://python-seabreeze.readthedocs.io/en/latest/install.html
echo "Installing seabreeze lib..."
# conda install -c conda-forge seabreeze
pip install seabreeze

# Run Seabreeze USB config script, see https://github.com/ap--/python-seabreeze/tree/main/os_support
# For Linux this sets UDEV rules
# For Win, downloads drivers.
# In Docker this only works if /etc/udev available...?

# seabreeze_os_setup
echo "To configure spectrometers, run 'seabreeze_os_setup'."

0 comments on commit e212212

Please sign in to comment.