Skip to content

Commit

Permalink
build: Add Dockerfile and shim (#47)
Browse files Browse the repository at this point in the history
* build: Add Dockerfile and shims

* build: Publish dockerfile to docker hub

* build: Fix permisson error when writing in docker

* fix: Fix wrong ouput if no given model

* docs(docker): Add documentation for running with docker
  • Loading branch information
josix authored Sep 8, 2021
1 parent 15e433b commit cb9f6e5
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM ubuntu:18.04

ENV DEBIAN_FRONTEND noninteractive
ENV BASE_DIR /usr/local
ENV APP_DIR $BASE_DIR/smore

RUN apt-get update \
&& apt-get -y install g++-7 make\
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

COPY cli $APP_DIR/cli
COPY src $APP_DIR/src
COPY ./entrypoint.sh $APP_DIR
COPY Makefile $APP_DIR
WORKDIR $APP_DIR

RUN make CC=g++-7
ENTRYPOINT ["./entrypoint.sh"]
VOLUME ["$APP_DIR/data"]
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,29 @@ sh train_youtube.sh
```
Changing the number of threads in *train_youtube.sh* could speedup the process.

# Running with Docker
- Running with locally built image
- Building docker image which is created following the instructions of Dockerfile
```sh
docker build -t smore:latest .
```
- Running container instantiated by image.
```sh
docker run -it --name smore --rm -v "$PWD":/usr/local/smore/data smore:latest model_name -train training_dataset -save embedding [model_options]
```
- Example:
```sh
docker run -it --name smore --rm -v "$PWD":/usr/local/smore/data smore:latest hpe -train net.txt -save rep.txt
```
- Running with published image
- Running `smore.sh`
```sh
./smore.sh model_name -train training_dataset -save embedding [model_options]
```
- Example:
```
./smore.sh model_name -train training_dataset -save embedding [model_options]
```
# Related Work
You can find related work from [awesome-network-embedding](https://github.com/chihming/awesome-network-embedding).

Expand Down
15 changes: 15 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
if [ $# -lt 1 ];then
echo "Usage:\n ./smore.sh model_name -train training_dataset -save embedding [model_options]"
echo "Example:\n ./smore.sh hpe -train net.txt -save rep.txt"
exit 1
fi
args=( "$@" )
for ((i=0; i < $#; i++)) ;do
next_arg=$((i+1))
if [ "${args[$i]}" == "-train" ] || [ "${args[$i]}" == "-save" ]; then
args[${next_arg}]="data/"${args[${next_arg}]}
fi
done
set "${args[@]}"
exec "./cli/$@"
8 changes: 8 additions & 0 deletions smore.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
if [ $# -lt 1 ];then
echo "Usage:\n ./smore.sh model_name -train training_dataset -save embedding [model_options]"
echo "Example:\n ./smore.sh hpe -train net.txt -save rep.txt"
exit 1
fi
IMAGE=josix/smore:latest
docker run -it --name smore --rm --user="$(id -u):$(id -g)" -v "$PWD":/usr/local/smore/data "$IMAGE" "$@"

0 comments on commit cb9f6e5

Please sign in to comment.