Commit f6aa72b2 authored by Pawel Sznajder's avatar Pawel Sznajder
Browse files

add docker Dockerfile in data/docker

parent 94681c27
# start from debian jessie
FROM debian:stretch
# PARTONS version
ENV PARTONSTAG="v1.0"
# set WORKSPACE env. variable
ENV WORKSPACE="/root/workspace"
# set working directory
WORKDIR ${WORKSPACE}
# install git
# install cmake, build and runtime libraries
RUN apt-get update && \
apt-get install -y --no-install-recommends git && \
apt-get install -y --no-install-recommends cmake build-essential libeigen3-dev libcln-dev libsfml-dev libqt4-dev libqt4-sql-mysql && \
apt-get clean && \
apt-get autoclean && \
rm -rf /var/lib/apt/lists/*
# pull and install elem-utils
RUN cd ${WORKSPACE} && \
git config --global http.sslVerify false && \
git clone --single-branch --depth 1 --branch ${PARTONSTAG} https://drf-gitlab.cea.fr/partons/core/elementary-utils.git && \
cd ${WORKSPACE}/elementary-utils/build && \
cmake -G"Unix Makefiles" ../ -DCMAKE_BUILD_TYPE=Release && \
make
# pull and install numa
RUN cd ${WORKSPACE} && \
git config --global http.sslVerify false && \
git clone --single-branch --depth 1 --branch ${PARTONSTAG} https://drf-gitlab.cea.fr/partons/core/numa.git && \
cd ${WORKSPACE}/numa/build && \
cmake -G"Unix Makefiles" ../ -DCMAKE_BUILD_TYPE=Release && \
make
# pull and install partons
RUN cd ${WORKSPACE} && \
git config --global http.sslVerify false && \
git clone --single-branch --depth 1 --branch ${PARTONSTAG} https://drf-gitlab.cea.fr/partons/core/partons.git && \
cd ${WORKSPACE}/partons/build && \
cmake -G"Unix Makefiles" ../ -DCMAKE_BUILD_TYPE=Release && \
make
# pull and compile partons-example
RUN cd ${WORKSPACE} && \
git config --global http.sslVerify false && \
git clone --single-branch --depth 1 --branch ${PARTONSTAG} https://drf-gitlab.cea.fr/partons/core/partons-example.git && \
cd ${WORKSPACE}/partons-example/build && \
cmake -G"Unix Makefiles" ../ -DCMAKE_BUILD_TYPE=Release && \
make
# creare directories and copy scripts
RUN mkdir ${WORKSPACE}/.docker && \
mkdir ${WORKSPACE}/partons-example/scenarios
COPY ./Dockerfile.partons.mysql ${WORKSPACE}/.docker
COPY ./Dockerfile.partons.startup ${WORKSPACE}/.docker
RUN chmod u+x ${WORKSPACE}/.docker/Dockerfile.partons.mysql && \
chmod u+x ${WORKSPACE}/.docker/Dockerfile.partons.startup
# set up database
RUN echo "mysql-server mysql-server/root_password password partons" | debconf-set-selections && \
echo "mysql-server mysql-server/root_password_again password partons" | debconf-set-selections && \
apt-get update && \
apt-get install -y --no-install-recommends mysql-server && \
apt-get clean && \
apt-get autoclean && \
rm -rf /var/lib/apt/lists/* && \
${WORKSPACE}/.docker/Dockerfile.partons.mysql && \
rm ${WORKSPACE}/.docker/Dockerfile.partons.mysql
# start mysql server each time container is used
# due to issue: https://github.com/docker/for-linux/issues/72
ENTRYPOINT [".docker/Dockerfile.partons.startup"]
#!/bin/bash
# start
find /var/lib/mysql -type f -exec touch {} \;
service mysql start &> /dev/null
# set env.
__mysql_database="partons"
__mysql_root="root"
__mysql_root_password="partons"
__mysql_user="partons"
__mysql_user_password="partons"
#define functioni to execute queries
function sql_exec() {
mysql -u "${__mysql_root}" -D "${__mysql_database}" -p${__mysql_root_password} -e "${1}"
}
# go to directory with schema
cd /root/workspace/partons/data/database/sql_schema
# create database and add user
mysql -u "${__mysql_root}" -p"${__mysql_root_password}" -e "create database ${__mysql_database}"
sql_exec "CREATE USER '${__mysql_user}'@'localhost' IDENTIFIED BY '${__mysql_user_password}';"
sql_exec "GRANT SELECT, INSERT, UPDATE, DELETE ON ${__mysql_database}.* TO '${__mysql_user}'@'localhost';"
sql_exec "GRANT FILE ON *.* TO '${__mysql_user}'@'localhost';"
# excecute scripts
# TODO: if scripts are going to be enumerated this piece of the code
#+ can be automated, therefore will need less further involvement
#+ of anyone.
#+
#+ Desirable naming might look like following:
#+ mysql5_common.sql -> mysql5_001_common.sql
#+ mysql5_gpd_layer.sql -> mysql5_002_gpd_layer.sql
#+ mysql5_convol_coeff_function_layer.sql -> mysql5_003_convol_coeff_function_layer.sql
#+ mysql5_observable_layer.sql -> mysql5_004_observable_layer.sql
sql_exec "SOURCE mysql5_common.sql"
sql_exec "SOURCE mysql5_gpd_layer.sql"
sql_exec "SOURCE mysql5_convol_coeff_function_layer.sql"
sql_exec "SOURCE mysql5_observable_layer.sql"
#!/bin/bash
echo "Welcome to PARTONS"
echo "See http://partons.cea.fr for description and technical documentation"
#mysql
find /var/lib/mysql -type f -exec touch {} \;
service mysql start &> /dev/null
if [ $# -eq 0 ]; then
/bin/bash
else
cd /root/workspace/partons-example
for i in $@; do
./bin/PARTONS_example scenarios/$i
done
fi
to create new image:
1) select PARTONS version (code tag) in Dockerfile.partons
2) execute (remamber to change vX.Y):
docker build . -f Dockerfile.partons -t pawelsznajder/partons:vX.Y
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment