-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
123 lines (109 loc) · 4.12 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# Dockerfile for Bayota
#
# Files to exclude are listed in the ./dockerignore file
#
# Example commands...
#
# Create a docker image:
# >> docker build -f Dockerfile --tag bayota_app .
#
# -- Create a first-stage docker image from the 'builder' stage:
# >> docker build -f Dockerfile --tag bayota_app_builder . --target builder
# -- Create a second-stage docker image from the 'builder2' stage:
# >> docker build -f Dockerfile --tag bayota_app_builder2 . --target builder2
#
#
# MANAGE IMAGES
#
# Inspect the available docker images:
# >> docker images
#
# Delete/remove existing image <by Image ID> listed in "docker images"
# >> docker rmi <imageID>
# >> docker rmi ef9a50d6e1a2
#
#
# RUNNING
#
# Run a docker image in interactive mode (to see file directory structure):
# >> docker run -it <imageID> sh
# Run interactively, but also set up for running Bayota by passing environment variables and mounting directories.
# >> docker run -it -e "BAYOTA_WORKSPACE_HOME" -v /Users/Danny/bayota_ws_0.1b1.dev2:/Users/Danny/bayota_ws_0.1b1.dev2 bayota_conda_app sh
#
# Mount a host directory when running (add -v argument):
# >> docker run -v /host/directory:/container/directory -it <imageID>
#
# Test commands to pass to docker container:
# -- Generate a model:
# >> docker run -it <imageID> ./bin/scripts_by_level/run_generatemodel.py -g CalvertMD -n costmin_total_percentreduction -sf ~/bayota_ws_0.0a1.dev4/temp/model_instances/modelinstance_costmin_total_percentreduction_CalvertMD.pickle -bl 2010NoActionLoads.csv
# -- Solve a model trial:
# >> docker run -it <imageID> ./bin/scripts_by_level/run_conductexperiment.py -n /root/bayota/bin/run_specs/experiment_specs/costmin_1-40percentreduction -sf /root/bayota_ws_0.0a1.dev4/temp/model_instances/modelinstance_costmin_total_percentreduction_CalvertMD.pickle
# #################################################
# --- START ---
# #################################################
FROM continuumio/miniconda3
# Add the IPOPT directory generated in the `builder` container above
#COPY --from=builder /CoinIpopt /CoinIpopt
# Setup Conda Environment
RUN conda update -n base -c defaults conda -y
#RUN conda create --name bayota3
# Activate Environment
# Pull the environment name out of the environment.yml
#RUN echo "conda activate bayota3" > ~/.bashrc
#ENV PATH /opt/conda/envs/bayota3/bin:$PATH
RUN conda clean -afy
# Do not install user tools on unmanaged images
# add vim for basic editing and checking
# RUN apt-get update && apt-get install vim -y
# --- Install basic requirements ---
RUN apt-get update && apt-get install -y \
curl \
gcc \
g++ \
gfortran \
patch \
make \
&& rm -rf /var/lib/apt/lists/*
# --- Get the IPOPT code ---
WORKDIR /
RUN curl --remote-name https://www.coin-or.org/download/source/Ipopt/Ipopt-3.12.12.tgz \
\
&& tar -xvzf Ipopt-3.12.12.tgz \
&& mv /Ipopt-3.12.12 /CoinIpopt \
&& rm Ipopt-3.12.12.tgz
# --- Download external code packages ---
RUN cd /CoinIpopt/ThirdParty/Blas \
\
&& ./get.Blas \
&& cd ../Lapack \
&& ./get.Lapack \
&& cd ../ASL \
&& ./get.ASL \
&& cd ../Mumps \
&& ./get.Mumps
# --- Run IPOPT configure script ---
RUN mkdir /CoinIpopt/build \
&& cd /CoinIpopt/build \
\
&& /CoinIpopt/configure
# --- Build the IPOPT code ---
RUN ls -alht \
&& pwd \
&& cd /CoinIpopt/build \
&& make \
&& make test \
&& make install
# --- Set up Bayota ---
COPY . /root/bayota
WORKDIR /root/bayota
# -- set up default bayota path directories (needed for bayota install) --
ENV BAYOTA_HOME=/root/bayota
ENV BAYOTA_WORKSPACE_HOME=/root
# RUN python setup.py develop
RUN pip install .
# Remove in-container workspace... the workspace will be mounted from outside
# otherwise, the paths will be internal, where there aren't files
#RUN rm -r /root/bayota_ws*
# --- Ensure IPOPT is in path variable ---
ENV PATH="${PATH}:/CoinIpopt/build/bin"
CMD ["python", "/root/bayota/bin/slurm_scripts/run_step2_generatemodel.py","-cn","step1_studycon1d6c68f6-326c-4487-8d85-5c5113f67bd7", "--s3workspace", "optimization/ws_copies/bayota_ws_0.1b2.dev1", "--log_level=INFO"]