I managed to get it working. First I tried to copy files from the lib folder (.cmxs etc), but did not manage to solve all dependencies. It would probably have worked if I had spent some more time figuring out what was still missing. So I installed opam2 and installed the packages using the destdir folder (/opt/myapp) for p in `opam2 list | cut -d ' ' -f 1`; do opam2 install --destdir /opt/myapp/ $p ; done (This is all, so I still have a job to do to figure out which I can do without) Also installed the Osigen app under /opt/myapp/ The whole folder was then copied a target node under /opt/myapp/ To solve paths I had to crate a new findlib.conf file and put it under /opt/myapp/etc/ $ cat /opt/myapp/etc/findlib.conf destdir="/opt/myapp/lib" path="/opt/myapp/lib" ocamlc="ocamlc.opt" ocamlopt="ocamlopt.opt" ocamldep="ocamldep.opt" ocamldoc="ocamldoc.opt" To run it, have have this script setting the environment $ cat /opt/myapp/run.sh #!/bin/bash MYTOP=/opt/myapp/ CAML_LD_LIBRARY_PATH=$MYTOP/lib/stublibs MANPATH=:$MYTOP/man PERL5LIB=$MYTOP/lib/perl5: OCAML_TOPLEVEL_PATH=/lib/toplevel PATH=$MYTOP/bin:$PATH OCAMLPATH=$MYTOP export OCAMLFIND_CONF=$MYTOP/etc/findlib.conf ocsigenserver.opt -c $MYTOP/etc/myapp/myapp.conf Also, oscigenserver seems to use the ~/.opam2/4.06.1/ paths form extensions loaded, so these have to be configured. Got this kind of log messages ocsigenserver.opt: ocsipersist:dbm: Launching a new Ocsidbm process: /home/hans/.opam2/4.06.1/lib/ocsigenserver/extensions/ocsidbm.opt on directory /opt/myapp/var/data/myapp/ocsipersist. Needed to change the configuration of the module to use the right path for the binary vi /opt/myapp/etc/myapp/myapp.conf ... ... Still have a problem with mime-types, but it's probably a similar config change. So it's not totally smooth, but it seems to be doable. Regards, Hans Ole Rafaelsen On Fri, Mar 30, 2018 at 4:11 PM, Louis Gesbert wrote: > There is no perfect solution at the moment, as there are still some > hiccups with relocation of quite a few opam packages, but there are a few > options: > > 1. Not precisely what you were asking for, since it involves re-compiling, > but opam-bundle¹ can generate an all-in-one package that can easily be > deployed to a different system and will bootstrap OCaml, opam, the packages > and their dependencies, and can put wrappers for the binaries to your PATH. > This takes a while, but avoids any relocation problems and is quite > reliable. > The bundle could also be used as base for a container, or even copied > across similar hosts (to the same location), and just the wrappers > reinstalled. > > 2. opam 2.0 has an `opam install --destdir` option, that you could use to > copy the installed artefacts of the required packages to some prefix (be > sure to reinstall all the dependencies, or start from an empty switch). You > could then tar/gz that prefix, and copy it across hosts. > > 3. in a simpler way, you could just copy the opam switch across hosts. > With opam 2, all metadata is gathered in /.opam-switch/, so > omit that subdirectory and you just get a "normal" Linux prefix (i.e. with > bin/, lib/, etc. subdirectories). > > Of course, 2. and 3. can hit relocation issues, depending on what the > packages you are interested in use (e.g. ocsigenserver seems to have > specific needs). As Gerd mentionned, specifying `CAML_LD_LIBRARY_PATH` and > `OCAMLPATH` (and maybe a few others²) may help. > And none of these reduce the end result to "just the binaries needed", > although 2. might help a little by letting you choose which packages get > into the dest-prefix. I am not aware of a way to do this automatically. A > vast super-appoximation could be to just ignore opam build-dependencies: > `opam reinstall --destdir SOME_TEMP_PREFIX $(opam list --installed --rec > --required-by PACKAGES --nobuild --short)`, on the origin host, then > package and ship SOME_TEMP_PREFIX, possibly with wrappers to set the > required PATH variables. > > These are just a few clues, but hope this helps! > > Louis Gesbert — OCamlPro > > > > ¹ https://github.com/AltGr/opam-bundle > ² https://github.com/ocaml/opam-repository/issues/10863# > issuecomment-347174662 > > > - Hans Ole Rafaelsen, 29/03/2018 18:31 - > > Hi, > > > > I have small application written using Ocsigen. Ocaml and the rest of the > > development environment is installed using OPAM. > > > > Now I want to install this application on a few other nodes, without > having > > to bring bring along the whole development process for deployment on each > > node. What I want to end up with, is a single unit, e.g a tar-file, a > > docker container or similar, that can be copied and deployed to the > target > > nodes. This unit should only contain the binaries needed to run the > > application. > > > > I have tried to ask on the Ocsigen mailing-list how do do this for > Ocsigen > > applications, but without success. But I guess the problem is more > related > > to how to deploy applications built using OPAM. I did not find any way to > > do this with OPAM, but I might have missed something. I have tried to > copy > > all the binary files (.so, .cmxa .cmxs, etc) from the OPAM directory and > > setting the environment variables to point the this new location, but > > without much success. When starting ocsigenserver it was not able to > solve > > all symbols. Looking more into the problem, it looks like binaries such > as > > ocsigenserver has hard coded the location of the OPAM development > > environment. Might be possible to override this using environment > > variables, but I'm not sure how. So I gave up on this track. > > > > > > Is there a way to generate such a deployable unit from OPAM development > > environment? > > > > Do anyone have some tips / best practice on how to deploy applications > > built using OPAM? > > > > (I'm developing and want to deploy on Ubuntu 16.04.) > > > > Regards, > > > > Hans Ole Rafaelsen > > > > > -- Caml-list mailing list. Subscription management and archives: https://sympa.inria.fr/sympa/arc/caml-list Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs