diff --git a/recipes/Dockerfile b/recipes/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..86a4d58c2d737ad5b3c3f9e9e35ca70587e2b236 --- /dev/null +++ b/recipes/Dockerfile @@ -0,0 +1,33 @@ +FROM ubuntu:focal + +RUN apt-get update &&\ + apt-get install -y wget git &&\ + wget https://raw.githubusercontent.com/abelsiqueira/jill/main/jill.sh &&\ + bash jill.sh -y &&\ + rm jill.sh + +ENV DIRNAME app + +ARG BRANCH=main +RUN git clone --depth 1 --single-branch -b $BRANCH https://gitlab.pasteur.fr/nyx/larvatagger.jl $DIRNAME &&\ + cd $DIRNAME &&\ + julia --project=. -e 'using Pkg; Pkg.instantiate()' &&\ + ln -s $(pwd)/scripts/larvatagger.jl /bin + +COPY ./extra $DIRNAME/ + +ARG BACKEND +RUN if [ "$BACKEND" = "MaggotUBA_20220418" ]; then \ + apt-get install -y python3-pip &&\ + python3 -m pip install poetry &&\ + cd $DIRNAME &&\ + git clone --depth 1 --single-branch -b 20220418 https://gitlab.pasteur.fr/nyx/MaggotUBA-adapter MaggotUBA &&\ + cd MaggotUBA &&\ + python3 -m poetry remove structured-temporal-convolution &&\ + python3 -m poetry add ../structured-temporal-convolution &&\ + python3 -m poetry install; \ + fi + +WORKDIR $DIRNAME + +ENTRYPOINT ["larvatagger.jl"] diff --git a/recipes/Dockerfile.local b/recipes/Dockerfile.local new file mode 100644 index 0000000000000000000000000000000000000000..62e6538767cba74e7039c767a382a3a94461f619 --- /dev/null +++ b/recipes/Dockerfile.local @@ -0,0 +1,17 @@ +FROM ubuntu:jammy + +RUN apt-get update &&\ + apt-get install -y wget git &&\ + wget https://raw.githubusercontent.com/abelsiqueira/jill/main/jill.sh &&\ + bash jill.sh -y &&\ + rm jill.sh + +COPY src /app/src/ +COPY scripts /app/scripts/ +COPY Project.toml Manifest.toml /app/ + +RUN cd /app &&\ + julia --project=. -e 'using Pkg; Pkg.instantiate()' &&\ + ln -s /app/scripts/larvatagger.jl /bin + +ENTRYPOINT ["larvatagger.jl"] diff --git a/scripts/larvatagger.sh b/scripts/larvatagger.sh new file mode 100755 index 0000000000000000000000000000000000000000..d8a4c38f72d7af42a092f1c65a60d2fb438da279 --- /dev/null +++ b/scripts/larvatagger.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +cmd=$1; shift + +if [ -z "$LARVATAGGER_IMAGE" ]; then LARVATAGGER_IMAGE=larvatagger; fi + +case "$cmd" in + + build) + +if ! [ -f recipes/Dockerfile ]; then +echo "the build command can only be run from the project root directory" +exit 1 +fi +mkdir -p ./extra +while ! [ -z "$1" ]; do +if [ "$1" == "--dev" -o "$1" == "--stable" ]; then +BUILD=$1; shift +elif [ "$1" == "--get-backend" ]; then +BACKEND="--build-arg BACKEND=MaggotUBA_20220418"; shift +cd ./extra +if [ -d structured-temporal-convolution ]; then +cd structured-temporal-convolution; git pull; cd .. +else +git clone --depth 1 --single-branch -b light-stable-for-tagging git@gitlab.pasteur.fr:les-larves/structured-temporal-convolution.git +fi +cd .. +else +echo "argument not supported: $1"; shift +#rm -rf ./extra +exit 1 +fi +done +if [ "$BUILD" == "--dev" ]; then +docker build -t "${LARVATAGGER_IMAGE}:dev" -f recipes/Dockerfile.local $BACKEND . +elif [ "$BUILD" == "--stable" ]; then +docker build -t "$LARVATAGGER_IMAGE:stable" -f recipes/Dockerfile $BACKEND . +else +docker build -t "$LARVATAGGER_IMAGE:latest" -f recipes/Dockerfile $BACKEND --build-arg BRANCH=dev . +fi +#rm -rf ./extra +;; + + open) + +ARGS="-p 9284:9284" +if ! [ -z "$LARVATAGGER_PORT" -o "$LARVATAGGER_PORT" == "9284" ]; then +ARGS="-p $LARVATAGGER_PORT:9284 $ARGS" +fi +file=$1; shift +exec docker run -iv $(pwd):/data $ARGS "$LARVATAGGER_IMAGE" open "/data/$file" $@ +;; + + import) + +file=$1; shift +docker run -v $(pwd):/data "$LARVATAGGER_IMAGE" import "/data/$file" $@ +;; + + *) + +echo "usage: $0 build [--stable] [--dev] [--get-backend]" +echo " $0 open <filepath>" +echo " $0 import <filepath> [<outputfilename>] [--id=<runid>] [--framerate=<fps>]" +;; + +esac