Skip to content

Commit

Permalink
Add mongod into Dockerfile.
Browse files Browse the repository at this point in the history
- Fix eblocbroker init to constantly print folder_setup.sh output.

- Add venv installation from Dockerfile.
  • Loading branch information
avatar-lavventura committed May 28, 2022
2 parents 3d5939b + c3b219b commit dd3f66f
Show file tree
Hide file tree
Showing 91 changed files with 1,160 additions and 1,007 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,5 @@ slurm-*.out
README.html
_slurm/example/hello
alper.csv
helloWorld.txt
helloWorld.txt
volumes
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "orcid-authentication-php"]
path = orcid-authentication-php
url = https://github.com/avatar-lavventura/orcid-authentication-php.git
[submodule "orcid-authentication"]
path = orcid-authentication
url = https://github.com/avatar-lavventura/orcid-authentication
172 changes: 107 additions & 65 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,20 @@ WORKDIR /workspace/gdrive
RUN go env -w GO111MODULE=auto \
&& go get github.com/prasmussen/gdrive

# Instal SLURM
# ============
FROM python:3.7
WORKDIR /workspace
RUN git config --global advice.detachedHead false \
&& git clone --depth 1 --branch slurm-19-05-8-1 https://github.com/SchedMD/slurm.git
WORKDIR slurm
RUN ./configure --enable-debug --enable-front-end \
&& make \
&& make install \
&& slurmctld -V

FROM python:3.7
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

ENV PATH="/root/.pyenv/shims:/root/.pyenv/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/bin:$PATH"
ARG DEBIAN_FRONTEND=noninteractive
ARG DEBCONF_NOWARNINGS="yes"
EXPOSE 6817 6818 6819 6820 3306

## ebloc-broker -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
RUN apt-get update \
&& apt-get install -y --no-install-recommends apt-utils \
&& apt-get install -y --no-install-recommends libdbus-1-dev \
&& apt-get install -y --no-install-recommends --assume-yes apt-utils \
&& apt-get install -y --no-install-recommends --assume-yes \
build-essential \
libdbus-1-dev \
libdbus-glib-1-dev \
libgirepository1.0-dev \
libssl-dev \
Expand All @@ -45,24 +36,29 @@ RUN apt-get update \
pigz \
zlib1g-dev \
make \
default-mysql-server \
npm \
nodejs \
python3-venv \
# sudo \
# slurm-packages
gcc \
munge \
libmunge-dev \
libboost-all-dev \
libmunge2 \
default-mysql-client \
default-mysql-server \
software-properties-common \
default-libmysqlclient-dev \
mailutils \
npm \
nodejs \
unzip \
libmariadbd-dev \
mariadb-server
# build-essential \
# software-properties-common \
# tree \
# python-setuptools \
# default-libmariadbclient-dev \
# libmariadb-dev \
mariadb-server \
supervisor \
nano \
less \
&& apt-get clean

RUN npm config set fund false \
&& npm config set update-notifier false \
Expand All @@ -72,66 +68,112 @@ RUN npm config set fund false \
&& npm install -g npm@latest \
&& npm install -g ganache

RUN python3 -m venv /opt/venv
#: enable venv
ENV PATH="/opt/venv/bin:$PATH"

WORKDIR /workspace
RUN git clone https://github.com/ebloc/ebloc-broker.git
WORKDIR /workspace/ebloc-broker
#: pip install takes few minutes
RUN git checkout dev \
#: `pip install -e .` takes few minutes
RUN git checkout dev >/dev/null 2>&1 \
&& git fetch --all --quiet >/dev/null 2>&1 \
&& git pull --all -r -v >/dev/null 2>&1 \
&& pip install -U pip wheel \
&& pip install -e . \
&& eblocbroker >/dev/null 2>&1
&& pip install --upgrade pip \
&& pip install -U pip wheel setuptools \
&& pip install -e . --use-deprecated=legacy-resolver \
&& eblocbroker >/dev/null 2>&1 \
&& ./broker/_utils/yaml.py >/dev/null 2>&1

COPY --from=0 /go /go
COPY --from=0 /usr/local/bin /usr/local/bin
COPY --from=0 /usr/local/go /usr/local/go
COPY --from=0 /workspace/gdrive /workspace/gdrive

COPY --from=1 /usr/local/sbin/ /usr/local/sbin/
COPY --from=1 /usr/local/bin /usr/local/bin
COPY --from=1 /usr/local/lib /usr/local/lib

# COPY --from=1 /opt/venv /opt/venv
# COPY --from=1 /usr/local/lib/node_modules /usr/local/lib/node_modules
# COPY --from=1 /usr/local/bin /usr/local/bin
# COPY --from=1 /workspace/ebloc-broker /workspace/ebloc-broker

ENV GOPATH=/go
ENV GOROOT=/usr/local/go
ENV PATH /opt/venv/bin:/go/bin:/usr/local/go/bin:$PATH
ENV PATH /go/bin:/usr/local/go/bin:$PATH

# Instal SLURM
# -=-=-=-=-=-=
# Add Tini
ENV TINI_VERSION v0.19.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
RUN chmod +x /tini

RUN git config --global advice.detachedHead false
WORKDIR /workspace
ARG JOBS=4
RUN git clone -b slurm-19-05-8-1 --single-branch --depth 1 https://github.com/SchedMD/slurm.git \
&& cd slurm \
&& ./configure --prefix=/usr --sysconfdir=/etc/slurm --enable-slurmrestd \
--with-mysql_config=/usr/bin --libdir=/usr/lib64 \
&& make \
&& make -j ${JOBS} install \
&& install -D -m644 etc/cgroup.conf.example /etc/slurm/cgroup.conf.example \
&& install -D -m644 etc/slurm.conf.example /etc/slurm/slurm.conf.example \
&& install -D -m600 etc/slurmdbd.conf.example /etc/slurm/slurmdbd.conf.example \
&& install -D -m644 contribs/slurm_completion_help/slurm_completion.sh /etc/profile.d/slurm_completion.sh \
&& cd .. \
&& rm -rf slurm \
&& slurmctld -V \
&& groupadd -r slurm \
&& useradd -r -g slurm slurm \
&& mkdir -p /etc/sysconfig/slurm \
/var/spool/slurmd \
/var/spool/slurmctld \
/var/log/slurm \
/var/run/slurm \
&& chown -R slurm:slurm /var/spool/slurmd \
/var/spool/slurmctld \
/var/log/slurm \
/var/run/slurm

RUN chown root:munge -R /etc/munge /etc/munge/munge.key /var/lib/munge # works but root is alright?
WORKDIR /var/log/slurm
WORKDIR /workspace/ebloc-broker
WORKDIR /var/run/supervisor
COPY broker/_slurm/files/supervisord.conf /etc/

# Mark externally mounted volumes
VOLUME ["/var/lib/mysql", "/var/lib/slurmd", "/var/spool/slurm", "/var/log/slurm", "/run/munge"]

COPY --chown=slurm broker/_slurm/files/slurm/slurm.conf /etc/slurm/slurm.conf
COPY --chown=slurm broker/_slurm/files/slurm/gres.conf /etc/slurm/gres.conf
COPY --chown=slurm broker/_slurm/files/slurm/slurmdbd.conf /etc/slurm/slurmdbd.conf
RUN chmod 0600 /etc/slurm/slurmdbd.conf

## mongodb
RUN curl -fsSL https://www.mongodb.org/static/pgp/server-4.4.asc | apt-key add - \
&& echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | \
tee /etc/apt/sources.list.d/mongodb-org-4.4.list \
&& apt-get update \
&& apt-get install -y mongodb-org \
&& mkdir -p /data/db \
&& chown -R mongodb. /var/log/mongodb \
&& chown -R mongodb. /var/lib/mongodb \
&& chown mongodb:mongodb /data/db

# RUN git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k \
# && echo "source ~/powerlevel10k/powerlevel10k.zsh-theme" >> ~/.zshrc \

## Finally
WORKDIR /workspace/ebloc-broker/broker
RUN apt-get clean \
&& apt-get autoremove \
&& apt-get autoclean \
&& ipfs version \
&& ganache --version

# Configure munge (for SLURM authentication)
RUN mkdir /var/run/munge && \
chown root /var/lib/munge && \
chown root /etc/munge && chmod 600 /var/run/munge && \
chmod 755 /run/munge && \
chmod 600 /etc/munge/munge.key

VOLUME ["/home", "/.secret"]

# 22: SSH
# 3306: MariaDB
# 6817: Slurm Ctl D
# 6818: Slurm D
# 6819: Slurm DBD
EXPOSE 22 3306 6817 6818 6819
COPY broker/_slurm/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
ENTRYPOINT ["/tini", "--", "/usr/local/bin/docker-entrypoint.sh"]
CMD ["/bin/bash"]

# RUN git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k \
# && echo "source ~/powerlevel10k/powerlevel10k.zsh-theme" >> ~/.zshrc \
# && ipfs version \
# && ganache --version
# -=-=-=-=-=-=-=-=-=-=-=-=- DELETE -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# COPY --from=1 /opt/venv /opt/venv # /opt/venv/bin
# COPY --from=1 /usr/local/lib/node_modules /usr/local/lib/node_modules
# COPY --from=1 /usr/local/bin /usr/local/bin
# COPY --from=1 /workspace/ebloc-broker /workspace/ebloc-broker

# https://github.com/GRomR1/docker-slurmbase/blob/master/Dockerfile
# https://github.com/SciDAS/slurm-in-docker/blob/master/base/Dockerfile
# https://stackoverflow.com/questions/42597739/accessing-docker-container-mysql-databases
# https://github.com/giovtorres/docker-centos7-slurm/blob/main/Dockerfile
# COPY --from=1 /usr/local/sbin/ /usr/local/sbin/
# COPY --from=1 /usr/local/bin /usr/local/bin
# COPY --from=1 /usr/local/lib /usr/local/lib
23 changes: 13 additions & 10 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ eBlocBroker is a blockchain based autonomous computational resource broker.
[[https://github.com/eth-brownie/brownie][eth-brownie]],
[[https://github.com/trufflesuite/ganache][ganache-cli]]


** Using Docker

You can use a sandbox container provided in the [[./docker-compose.yml]] file for testing inside a Docker
Expand All @@ -26,14 +25,20 @@ This container provides everything you need to test using a Python 3.7 interpret
Start the test environment:

#+begin_src bash
docker build -t ebloc-broker:latest --progress plain .
docker-compose up -d --remove-orphans
docker build -t ebb:latest . --progress plain
docker-compose up -d
#+end_src

To enter the shell of the running container in interactive mode, run:

#+begin_src bash
docker exec -it ebloc-broker_slurm_1 /bin/bash
#+end_src

To open a session to the container:
To stop the cluster container, run:

#+begin_src bash
docker-compose exec sandbox bash
docker-compose down
#+end_src

** Cloud Storages
Expand Down Expand Up @@ -67,13 +72,11 @@ Next, type ~eblocbroker --help~ for basic usage information.
*** Submit Job


In order to submit your job each user should already registered into
eBlocBroker.You can use [[./broker/eblocbroker/register_requester.py]] to register.
In order to submit your job each user should already registered into eBlocBroker.
You can use [[./broker/eblocbroker/register_requester.py]] to register.
Please update following arguments inside ~register.yaml~.

After registration is done, each user should authenticate their ORCID iD using
the following [[http://ebloc.cmpe.boun.edu.tr/orcid-authentication/index.php]].

After registration is done, each user should authenticate their ORCID iD using the following [[http://eblocbroker.duckdns.org/]].

~$ ./eblocbroker.py submit job.yaml~

Expand Down
13 changes: 13 additions & 0 deletions broker/.TODO.org_archive
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,16 @@ a = "this string needs compressing"
a = zlib.compress(a.encode())
print(zlib.decompress(a).decode())
#+end_src

* DONE
CLOSED: [2022-05-26 Thu 09:56]
:PROPERTIES:
:ARCHIVE_TIME: 2022-05-26 Thu 09:56
:ARCHIVE_FILE: ~/ebloc-broker/broker/TODO.org
:ARCHIVE_OLPATH: TASKS
:ARCHIVE_CATEGORY: TODO
:ARCHIVE_TODO: DONE
:END:
carry `run_with_output` into tools

convert all ~run(~ into ~run_with_output(~
10 changes: 4 additions & 6 deletions broker/_cli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ def driver():
def init():
import git
from pathlib import Path

from broker._utils.tools import run
from broker._utils.tools import run_keep_print

f = Path(__file__).parent.resolve()
repo = git.Repo(f, search_parent_directories=True)
run(Path(repo.working_tree_dir) / "broker" / "bash_scripts" / "folder_setup.sh")
run_keep_print(Path(repo.working_tree_dir) / "broker" / "bash_scripts" / "folder_setup.sh")


def about():
Expand Down Expand Up @@ -58,12 +57,11 @@ def daemon():
if args.daemon_type[0] == "slurm":
import git
import pathlib

from broker._utils.tools import run
from broker._utils.tools import run_keep_print

f = pathlib.Path(__file__).parent.resolve()
repo = git.Repo(f, search_parent_directories=True)
run(repo.working_tree_dir / "broker" / "bash_scripts" / "run_slurm.sh")
run_keep_print(repo.working_tree_dir / "broker" / "bash_scripts" / "run_slurm.sh")


def console():
Expand Down
6 changes: 3 additions & 3 deletions broker/_daemons/ipfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from broker import cfg, config
from broker._utils._log import ok
from broker._utils.tools import print_tb
from broker._utils.tools import print_tb, run
from broker.utils import is_ipfs_on, log, popen_communicate


Expand All @@ -17,7 +17,7 @@ def mount_ipfs():
log(run(["sudo", "ipfs", "mount", "-f", "/ipfs"]))


def run():
def _run():
"""Run ipfs daemon.
cmd: ipfs daemon --enable-gc --routing=none # --mount
Expand Down Expand Up @@ -52,7 +52,7 @@ def main():

if not is_ipfs_on():
cfg.ipfs.remove_lock_files()
run()
_run()
else:
log(f"## [green]IPFS[/green] daemon is already running{ok()}")
sys.exit(100)
Expand Down
Empty file added broker/_slurm/DAG/__init__.py
Empty file.
Loading

0 comments on commit dd3f66f

Please sign in to comment.