Skip to content

Commit

Permalink
add dockerfile and instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter-Metz committed Jun 1, 2020
1 parent 38b03bf commit 456b36a
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 0 deletions.
27 changes: 27 additions & 0 deletions DOCKER_INSTRUCTIONS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
This repository builds and runs a Docker container with everything you need to run IPOPTR. In addition, the directory `r` is mounted into the container at run time. In other words, programs saved in this folder can be opened and modified in the container.

To compile IPOPTR with HSL, download the HSL source code and move the unzipped folder (in my case this was called `coinhsl-2019.05.21/`) to the base of this directory. When the Docker image is built, HSL will compile.

If your folder with HSL is called something different, you may need to modify the follow line in the `Dockerfile` or simply comment it out:

```
COPY ./coinhsl-2019.05.21 /ipopt_df/CoinIpopt/ThirdParty/HSL
```

## Requirements

1. [Docker](https://docs.docker.com/installation/)

## Firing up

```
docker build -t MY_CONTAINER . # build your image
docker run -p 80:8787 --name="SOME_NAME" -e ROOT=TRUE -e USER=peter -e PASSWORD=peter -v $(pwd)/r_scripts:/home/peter/r -d MY_CONTAINER:latest
```

Note that you can pick any `--name`, `USER`, and `PASSWORD`. Make sure to swap out your `USER` in `/home/peter/r_scripts`.


## Get into it

Now travel to the appropriate IP address in your browser (in this case, it's `http://localhost:80`) and log into R studio with the `USER` and `PASSWORD` you provided when you ran the container.
69 changes: 69 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
FROM rocker/rstudio:4.0.0
FROM rocker/tidyverse

MAINTAINER Peter Metz <[email protected]>

WORKDIR /ipopt_df

COPY ./r /ipopt_df/r

# IPoptr envrionment directory
ENV IPOPTR_DIR=/ipopt_df/CoinIpopt/build/Ipopt/contrib

# Give the user root access
RUN echo "$USER ALL = NOPASSWD: ALL" >> /etc/sudoers && \

apt-get update && apt-get install -y \
gcc g++ gfortran git patch wget pkg-config liblapack-dev libmetis-dev && \

##################
# Download ipoptr source
# http://www.coin-or.org/Ipopt/documentation/node10.html
##################
cd /ipopt_df && \
wget http://www.coin-or.org/download/source/Ipopt/Ipopt-3.12.13.tgz && \
gunzip Ipopt-3.12.13.tgz && \
tar -xvf Ipopt-3.12.13.tar && \
rm -rf Ipopt-3.12.13.tar && \
mv Ipopt-3.12.13 CoinIpopt

COPY ./coinhsl-2019.05.21 /ipopt_df/CoinIpopt/ThirdParty/HSL

RUN cd /ipopt_df/CoinIpopt && \

# Downloading third party solvers
cd ThirdParty/Blas && \
./get.Blas && \
cd ../Lapack && \
./get.Lapack && \
cd ../ASL && \
./get.ASL && \
cd ../Mumps && \
./get.Mumps && \
cd ../Metis && \
./get.Metis && \
cd ../HSL && \
./configure && \

##################
# Compile ipoptr
##################
cd ../../ && \
mkdir build && \
cd build && \
../configure -with-pic CXXFLAGS="-fopenmp" FCFLAGS="-fopenmp" CFLAGS="-fopenmp" ADD_FFLAGS=-fPIC ADD_CFLAGS=-fPIC ADD_CXXFLAGS=-fPIC && \
make -j3 && \
make test && \
make install && \

##################
# Pre-install ipoptr
##################
echo "install.packages('/ipopt_df/CoinIpopt/build/Ipopt/contrib/RInterface', repos=NULL, type='source')" \
>> installIpoptrPackage.R && \
r installIpoptrPackage.R && \
rm installIpoptrPackage.R

# Default CMD from
# https://github.com/rocker-org/rocker/blob/master/rstudio/Dockerfile
# CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]

0 comments on commit 456b36a

Please sign in to comment.