forked from pymc-devs/pymc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update dockerfile to PyMC v4 (pymc-devs#5881)
* rename and update build docker container * add a script for running docker container from bash * update running docker container from juppyter notebook * simplify into one bash script * remove root user from Dockerfile * remove obsolete scripts * update documents on running PyMC in Docker
- Loading branch information
Showing
7 changed files
with
68 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
(docker_container)= | ||
# Running PyMC in Docker | ||
|
||
We have provided a Dockerfile which helps for isolating build problems, and local development. | ||
Install [Docker](https://www.docker.com/) for your operating system, clone this repo, then | ||
run the following commands to build a `pymc` docker image. | ||
|
||
```bash | ||
cd pymc | ||
bash scripts/docker_container.sh build | ||
``` | ||
|
||
After successfully building the docker image, you can start a local docker container called `pymc` either from `bash` or from [`jupyter`](http://jupyter.org/) notebook server running on port 8888. | ||
|
||
```bash | ||
bash scripts/docker_container.sh bash # running the container with bash | ||
bash scripts/docker_container.sh jupyter # running the container with jupyter notebook | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,30 @@ | ||
FROM jupyter/minimal-notebook | ||
FROM jupyter/base-notebook:python-3.9.12 | ||
|
||
ARG SRC_DIR=. | ||
LABEL name="pymc" | ||
LABEL description="Environment for PyMC version 4" | ||
|
||
MAINTAINER Austin Rochford <[email protected]> | ||
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8 | ||
|
||
ADD $SRC_DIR /home/jovyan/ | ||
RUN /bin/bash /home/jovyan/scripts/create_testenv.sh --global --no-setup | ||
# Switch to jovyan to avoid container runs as root | ||
USER $NB_UID | ||
|
||
# matplotlib nonsense | ||
ENV XDG_CACHE_HOME /home/$NB_USER/.cache/ | ||
ENV MPLBACKEND=Agg | ||
# for prettier default plot styling | ||
RUN pip install seaborn | ||
# Import matplotlib the first time to build the font cache. | ||
RUN python -c "import matplotlib.pyplot" | ||
COPY /conda-envs/environment-dev-py39.yml . | ||
RUN mamba env create -f environment-dev-py39.yml && \ | ||
/bin/bash -c ". activate pymc-dev-py39 && \ | ||
mamba install -c conda-forge -y pymc" && \ | ||
conda clean --all -f -y | ||
|
||
ENV PYTHONPATH $PYTHONPATH:"$HOME" | ||
# Fix PkgResourcesDeprecationWarning | ||
RUN pip install --upgrade --user setuptools==58.3.0 | ||
|
||
#Setup working folder | ||
WORKDIR /home/jovyan/work | ||
|
||
# For running from bash | ||
SHELL ["/bin/bash","-c"] | ||
RUN echo "conda activate pymc-dev-py39" >> ~/.bashrc && \ | ||
source ~/.bashrc | ||
|
||
# For running from jupyter notebook | ||
EXPOSE 8888 | ||
CMD ["conda", "run", "--no-capture-output", "-n", "pymc-dev-py39", "jupyter","notebook","--ip=0.0.0.0","--port=8888","--no-browser"] |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#! /bin/bash | ||
|
||
COMMAND="${1:-jupyter}" | ||
SRC_DIR=${SRC_DIR:-`pwd`} | ||
CONTAINER_NAME=${CONTAINER_NAME:-pymc} | ||
PORT=${PORT:-8888} | ||
|
||
# stop and remove previous instances of the pymc container to avoid naming conflicts | ||
if [[ $(docker ps -aq -f name=${CONTAINER_NAME}) ]]; then | ||
echo "Shutting down and removing previous instance of ${CONTAINER_NAME} container..." | ||
docker rm -f ${CONTAINER_NAME} | ||
fi | ||
|
||
# $COMMAND can be either `build` or `bash` or `jupyter` | ||
if [[ $COMMAND = 'build' ]]; then | ||
docker build \ | ||
-t ${CONTAINER_NAME} \ | ||
-f $SRC_DIR/scripts/Dockerfile $SRC_DIR | ||
|
||
elif [[ $COMMAND = 'bash' ]]; then | ||
docker run -it -v $SRC_DIR:/home/jovyan/work --rm --name ${CONTAINER_NAME} ${CONTAINER_NAME} bash | ||
else | ||
docker run -it -p $PORT:8888 -v $SRC_DIR:/home/jovyan/work --rm --name ${CONTAINER_NAME} ${CONTAINER_NAME} | ||
fi |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.