[nix] add corenlp.nix, implement in Dockerfile

parent 181e477d
Pipeline #7412 failed with stages
in 82 minutes and 18 seconds
......@@ -18,32 +18,27 @@ ENV PATH=/root/.local/bin:$PATH
RUN apt-get update && \
apt-get install --no-install-recommends -y \
apt-transport-https \
autoconf \
automake \
build-essential \
#autoconf \
#automake \
#build-essential \
ca-certificates \
curl \
#gcc \
git \
gnupg2 \
libffi-dev \
libffi8 \
libgmp-dev \
libgmp10 \
libncurses-dev \
libncurses6 \
libnuma-dev \
libtinfo6 \
#libffi-dev \
#libffi8 \
#libgmp-dev \
#libgmp10 \
#libncurses-dev \
#libncurses6 \
#libnuma-dev \
#libtinfo6 \
locales \
lsb-release \
#lsb-release \
software-properties-common \
#strace \
sudo \
#wget \
#vim \
xz-utils \
zlib1g-dev \
#openjdk-21-jdk \
unzip && \
apt-get clean && rm -rf /var/lib/apt/lists/* && \
mkdir -m 0755 /nix && groupadd -r nixbld && chown root /nix && \
......@@ -55,23 +50,24 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"]
COPY ./shell.nix /builds/gargantext/shell.nix
COPY ./nix/pkgs.nix /builds/gargantext/nix/pkgs.nix
COPY ./nix/corenlp.nix /builds/gargantext/nix/corenlp.nix
COPY ./nix/pinned-25.05.nix /builds/gargantext/nix/pinned-25.05.nix
COPY ./devops/coreNLP/build.sh /root/devops/coreNLP/build.sh
COPY ./devops/coreNLP/startServer.sh /root/devops/coreNLP/startServer.sh
#COPY ./devops/coreNLP/startServer.sh /root/devops/coreNLP/startServer.sh
COPY ./bin/setup-ci-environment /builds/gargantext/bin/setup-ci-environment
COPY ./bin/install-cabal2stack /builds/gargantext/bin/install-cabal2stack
#RUN cd /root/devops/coreNLP; ./build.sh && \
RUN set -o pipefail && \
locale-gen en_US.UTF-8 && \
bash <(curl -L https://releases.nixos.org/nix/nix-2.26.2/install) --no-daemon && \
locale-gen en_US.UTF-8 && chown root -R /nix && \
chown root -R /nix && \
. "$HOME/.nix-profile/etc/profile.d/nix.sh" && \
mkdir -p "/builds/gargantext/" && chmod 777 -R "/builds/gargantext" && \
echo "source $HOME/.nix-profile/etc/profile.d/nix.sh" >> "$HOME/.bashrc" && \
echo `which nix-env` && \
. $HOME/.bashrc && nix-env --version && \
cd /builds/gargantext && nix-shell --run "./bin/install-cabal2stack" && \
cd /root/devops/coreNLP && nix-shell -p jre --run "./build.sh"
cd /builds/gargantext && nix-shell --run "./bin/install-cabal2stack"
#cd /root/devops/coreNLP && nix-shell -p jre --run "./build.sh"
WORKDIR "/builds/gargantext/"
# https://nixos.wiki/wiki/Java
{ fetchzip,
stdenv,
writeShellScript,
jre,
version ? "4.5.8",
hash ? "sha256-HZHNyw+LrxAN4OLueAhyxRG2onPWNMm5MwJDLLzsE2M="
}:
let
file_name = "stanford-corenlp-${version}.zip";
url = "http://nlp.stanford.edu/software/${file_name}";
zip_file = fetchzip { inherit url hash; };
start_server = writeShellScript "startCoreNLPServer.sh" ''
PORT=9000
while getopts ':p:h' opt; do
case $opt in
(p) PORT=$OPTARG;;
(h) echo "$(basename $0) [-p 9000]"
exit 0
;;
esac
done
shift "$((OPTIND - 1))"
${jre}/bin/java -mx4g -cp "${zip_file}/*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port $PORT -timeout 15000
'';
in
stdenv.mkDerivation rec {
name = "corenlp";
inherit version;
phases = "installPhase";
installPhase = ''
mkdir -p $out/bin
cp ${start_server} $out/bin/startCoreNLPServer.sh
'';
}
......@@ -88,6 +88,9 @@ rec {
'';
});
corenlp = pkgs.callPackage ./corenlp.nix { };
hsBuildInputs = [
ghc966
cabal_install
......@@ -97,6 +100,7 @@ rec {
];
nonhsBuildInputs = with pkgs; [
bzip2
corenlp
czmq
docker-compose
git
......
......@@ -19,18 +19,16 @@ startCoreNLPServer :: IO ProcessHandle
startCoreNLPServer = do
putText "calling start core nlp"
devNull <- openFile "/dev/null" WriteMode
let p = proc "./startServer.sh" []
(_, _, _, hdl) <- (createProcess $ p { cwd = Just "devops/coreNLP/stanford-corenlp-current"
let p = proc "startCoreNLPServer.sh" []
(_, _, _, hdl) <- (createProcess $ p {
cwd = Nothing
, delegate_ctlc = True
, create_group = True
, std_out = UseHandle devNull
, std_err = UseHandle devNull
}) `catch` \e -> case e of
_ | True <- "does not exist" `isInfixOf` (T.pack . show @SomeException $ e)
-> fail $ "Cannot execute the 'startServer.sh' script. If this is the " <>
"first time you are running the tests, you have to run " <>
"cd devops/coreNLP && ./build.sh first. You have to run it only once, " <>
"and then you are good to go for the time being."
-> fail $ "Cannot execute the 'startCoreNLPServer.sh' script. Make sure you are in a nix environment."
| otherwise -> throwIO e
pure hdl
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment