From c8fd67dcbe250bffd677b5b5a7ef0fb708ab8490 Mon Sep 17 00:00:00 2001 From: Thomas Beckenhauer Date: Mon, 19 Jul 2021 21:39:39 -0400 Subject: [PATCH] Add Dockerfile --- Dockerfile | 24 +++++++++++++----------- README.md | 13 ++++++------- buildDocker.sh | 5 +++++ startDocker.sh | 2 ++ 4 files changed, 26 insertions(+), 18 deletions(-) create mode 100755 buildDocker.sh create mode 100755 startDocker.sh diff --git a/Dockerfile b/Dockerfile index 48f43f4..3186d66 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,16 @@ -# set base image FROM python:3.7-slim -# set the working directory in the container -WORKDIR /app +ENV PATH="~/.local/bin:${PATH}" +ENV PATH="/home/testuser/.local/bin:${PATH}" -# install fawkes -RUN pip install fawkes - -# downgrade h5py: https://github.com/Shawn-Shan/fawkes/issues/75 -RUN pip install --upgrade h5py==2.10.0 - -# copy the files you want to edit with fawkes -COPY imgs imgs \ No newline at end of file +#Mirror host user +#Efficently mirror host user and share files between host and docker +#https://stackoverflow.com/a/44683248/298240 +ARG UNAME=testuser +ARG UID=1000 +ARG GID=1000 +#FIXES https://stackoverflow.com/a/63377623/298240 +RUN apt-get update && apt-get install -y ffmpeg libsm6 libxext6 python3-opencv sudo && groupadd -g $GID -o $UNAME && useradd -m -u $UID -g $GID -o -s /bin/bash $UNAME && echo "testuser:testuser" | chpasswd && adduser testuser sudo +USER $UNAME +WORKDIR /home/$UNAME/workspace +RUN pip install --upgrade h5py==2.10.0 fawkes opencv-python diff --git a/README.md b/README.md index f891806..efe942e 100644 --- a/README.md +++ b/README.md @@ -64,15 +64,14 @@ If you don't have root privilege, please try to install on user namespace: `pip ## Installation and Usage with Docker -- clone this repository: `git clone [url]` +- On your host machine move or copy your images folder to your normal workspace directory `cd ~/workspace` +- clone this repository: `git clone [url]` into your normal workspace directory - go into cloned repository: `cd fawkes` -- create `/imgs` folder in root folder: `mkdir imgs` -- build docker image in root folder: `docker build -t fawkes .` -- run container: `docker run -it fawkes sh` -- run your fawkes command, e.g. `fawkes -d ./imgs --mode min` +- run `buildDocker.sh` +- run `startDocker.sh` +- You should now be in the fawkes container with your normal workspace directory to /home/testuser/workspace +- You can then run fawkes with something like: e.g. `fawkes -d ./imgs --mode=low` - exit from your container: `exit` -- find your container id: `docker container ls --all` -- copy the created data to your local machine: `docker cp [container-id]:/app/imgs ~/output-from-fawkes` Academic Research Usage ----------------------- diff --git a/buildDocker.sh b/buildDocker.sh new file mode 100755 index 0000000..29dd6b6 --- /dev/null +++ b/buildDocker.sh @@ -0,0 +1,5 @@ +#Pass in user id's for mirroring host user +docker build \ + --build-arg UID=$(id -u) \ + --build-arg GID=$(id -g) \ + -t fawkes . diff --git a/startDocker.sh b/startDocker.sh new file mode 100755 index 0000000..3067162 --- /dev/null +++ b/startDocker.sh @@ -0,0 +1,2 @@ +#Map Parrent directory to workspace folder under home directory +docker run -it -v "$(pwd)/..:/home/testuser/workspace" fawkes bash