diff --git a/Project.toml b/Project.toml index 1065fe0451fa0df87b736929708f1fe57df28e07..1b5dd3db1655b9b9c4b897d22d63728e669243f6 100644 --- a/Project.toml +++ b/Project.toml @@ -8,7 +8,6 @@ Colors = "5ae59095-9a9b-59fe-a467-6f913c188581" Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" DocOpt = "968ba79b-81e4-546f-ab3a-2eecfa62a9db" Formatting = "59287772-0a20-5a39-b81b-1366585eb4c0" -JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1" JSServe = "824d6782-a2ef-11e9-3a09-e5662e0c26f9" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Logging = "56ddb016-857b-54e1-b83d-db4d58db5568" diff --git a/recipes/Dockerfile b/recipes/Dockerfile index 86a4d58c2d737ad5b3c3f9e9e35ca70587e2b236..e4f2cdffd4d3bc1a801a57fb7b30620b28480023 100644 --- a/recipes/Dockerfile +++ b/recipes/Dockerfile @@ -1,33 +1,36 @@ -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 +FROM julia:1.7.3-bullseye 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 +RUN apt-get update && apt-get install -y \ + git \ + && rm -rf /var/lib/apt/lists/* \ + && git clone --depth 1 --single-branch -b $BRANCH https://gitlab.pasteur.fr/nyx/larvatagger.jl $DIRNAME \ + && julia --project=$DIRNAME -e 'using Pkg; Pkg.instantiate()' \ + && ln -s /$DIRNAME/scripts/larvatagger.jl /bin + +COPY test/precompile.* test/data_sample* $DIRNAME/test/ -COPY ./extra $DIRNAME/ +ARG TIMEZONE=UTC +RUN ln -snf /usr/share/zoneinfo/$TIMEZONE /etc/localtime \ + && echo $TIMEZONE > /etc/timezone \ + && $DIRNAME/test/precompile.sh --shallow \ + && rm -f test/data_sample* + +COPY external $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; \ +RUN if [ "$BACKEND" = "MaggotUBA/20220418" ]; then \ + apt-get update && 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 \ + && rm -rf /var/lib/apt/lists/*; \ fi -WORKDIR $DIRNAME - ENTRYPOINT ["larvatagger.jl"] diff --git a/recipes/Dockerfile.local b/recipes/Dockerfile.local index 62e6538767cba74e7039c767a382a3a94461f619..2e44d254ecec6aba6ff3576bf68662400f7c2e2e 100644 --- a/recipes/Dockerfile.local +++ b/recipes/Dockerfile.local @@ -1,17 +1,14 @@ -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 +FROM julia:1.7.3-bullseye COPY src /app/src/ COPY scripts /app/scripts/ COPY Project.toml Manifest.toml /app/ -RUN cd /app &&\ - julia --project=. -e 'using Pkg; Pkg.instantiate()' &&\ +RUN apt-get update && apt-get install -y \ + git \ + && rm -rf /var/lib/apt/lists/* \ + && 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 index d8a4c38f72d7af42a092f1c65a60d2fb438da279..f7ad15726b0880d508019c1ea29a9aa03441cb78 100755 --- a/scripts/larvatagger.sh +++ b/scripts/larvatagger.sh @@ -12,13 +12,13 @@ if ! [ -f recipes/Dockerfile ]; then echo "the build command can only be run from the project root directory" exit 1 fi -mkdir -p ./extra +mkdir -p ./external 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 +DOCKER_ARGS="--build-arg BACKEND=MaggotUBA/20220418 "; shift +cd ./external if [ -d structured-temporal-convolution ]; then cd structured-temporal-convolution; git pull; cd .. else @@ -27,28 +27,32 @@ fi cd .. else echo "argument not supported: $1"; shift -#rm -rf ./extra +#rm -rf ./external exit 1 fi done +DOCKER_ARGS="--build-arg TIMEZONE=$(cat /etc/timezone) $DOCKER_ARGS" if [ "$BUILD" == "--dev" ]; then -docker build -t "${LARVATAGGER_IMAGE}:dev" -f recipes/Dockerfile.local $BACKEND . +docker build -t "${LARVATAGGER_IMAGE}:dev" -f recipes/Dockerfile.local ${DOCKER_ARGS}. elif [ "$BUILD" == "--stable" ]; then -docker build -t "$LARVATAGGER_IMAGE:stable" -f recipes/Dockerfile $BACKEND . +docker build -t "${LARVATAGGER_IMAGE}:stable" -f recipes/Dockerfile ${DOCKER_ARGS}. else -docker build -t "$LARVATAGGER_IMAGE:latest" -f recipes/Dockerfile $BACKEND --build-arg BRANCH=dev . +docker build -t "${LARVATAGGER_IMAGE}:latest" -f recipes/Dockerfile ${DOCKER_ARGS}--build-arg BRANCH=dev . fi -#rm -rf ./extra +#rm -rf ./external ;; open) -ARGS="-p 9284:9284" -if ! [ -z "$LARVATAGGER_PORT" -o "$LARVATAGGER_PORT" == "9284" ]; then -ARGS="-p $LARVATAGGER_PORT:9284 $ARGS" +if [ -z "$LARVATAGGER_PORT" -o "$LARVATAGGER_PORT" == "9284" ]; then +DOCKER_ARGS="-p 9284:9284" +TAGGER_ARGS= +else +DOCKER_ARGS="-p $LARVATAGGER_PORT:$LARVATAGGER_PORT" +TAGGER_ARGS="--port=$LARVATAGGER_PORT" fi file=$1; shift -exec docker run -iv $(pwd):/data $ARGS "$LARVATAGGER_IMAGE" open "/data/$file" $@ +exec docker run -iv $(pwd):/data $DOCKER_ARGS "$LARVATAGGER_IMAGE" open "/data/$file" $TAGGER_ARGS $@ ;; import) diff --git a/test/precompile.jl b/test/precompile.jl new file mode 100644 index 0000000000000000000000000000000000000000..00f22103b040bac3057e735a3243dbeb5e81a5dd --- /dev/null +++ b/test/precompile.jl @@ -0,0 +1,24 @@ +using LarvaTagger +using JSServe: Server + +datafile = joinpath(@__DIR__, "data_sample") +ispath(datafile) || exit() + +app = larvaeditor(datafile) +srv = Server(app, "0.0.0.0", 9284) + +if isempty(ARGS) + + using HTTP + HTTP.request(:GET, "http://127.0.0.1:9284") + +elseif ARGS == ["--electron"] + + using Blink + win = Window(async=false) + loadurl(win, "http://127.0.0.1:9284") + close(win) + +end + +close(srv) diff --git a/test/precompile.sh b/test/precompile.sh new file mode 100755 index 0000000000000000000000000000000000000000..4bda55d90a36c4c16fc0a0f0333f1ea86ca4f38b --- /dev/null +++ b/test/precompile.sh @@ -0,0 +1,27 @@ +#!/bin/sh +root=$(dirname $(dirname $0)) +if [ "$1" = "--shallow" ]; then +shift +echo "Project root: $root" +julia --project=$root -e 'using Pkg; Pkg.add("HTTP")' +echo "[$(date +%T)] Further precompiling..." +julia --project=$root $root/test/precompile.jl +echo "[$(date +%T)] Precompilation done" +julia --project=$root -e 'using Pkg; Pkg.rm("HTTP")' +else +packages="unzip xvfb libgtk-3-0 libnss3 libxss1 libasound2" +apt-get update +apt-get install -y $packages +echo "Project root: $root" +julia --project=$root -e 'using Pkg; Pkg.add("Blink")' +# to find out missing dependencies: +# electron=$(julia --project=$root -e 'using Blink; println(Blink.AtomShell.electron())') +# echo $electron +# $electron +echo "[$(date +%T)] Further precompiling..." +xvfb-run julia --project=$root $root/test/precompile.jl --electron +echo "[$(date +%T)] Precompilation done" +julia --project=$root -e 'using Pkg; Pkg.rm("Blink")' +apt-get autoremove -y $packages +rm -rf /var/lib/apt/lists/* +fi