Browse Source

Book: using a Docker image

master
pjotrp 4 years ago
parent
commit
71cd148a37
  1. 83
      CONTAINERS.org
  2. 17
      INSTALL.org

83
CONTAINERS.org

@ -97,3 +97,86 @@ Guix has its own containers using native Linux support, but you can
also run Guix in Docker and distribute software that way. One
interesting thing you can do is run guix 'pack' which creates a docker
image of a package with all its dependencies, see this [[https://www.gnu.org/software/guix/news/creating-bundles-with-guix-pack.html][description]].
** Providing a usable Docker container
*** Install the package in the main /gnu/store
For a paper we made a compilation of bioinformatics software and put
it all in one GNU Guix [[https://gitlab.com/genenetwork/guix-bioinformatics/blob/master/gn/packages/book_evolutionary_genomics.scm#L113][package]] named book-evolutionary-genomics. I
can install it using a local GUIX checkout commit
cc14a90fd3ce34a371175de610f9befcb2dad52b
#+begin_src shell
env GUIX_PACKAGE_PATH=../guix-bioinformatics \
./pre-inst-env guix package -p ~/opt/book-evolutionary-genomics \
--no-grafts -i book-evolutionary-genomics \
--substitute-urls="http://guix.genenetwork.org https://berlin.guixsd.org https://mirror.hydra.gnu.org"
#+end_src
resulting in a totally reproducible package.
*** Try things in a Guix container
Now we want to isolate them into a container. To run these tools
inside a Guix container you can do like the earlier
#+begin_src shell
env GUIX_PACKAGE_PATH=../guix-bioinformatics/ \
./pre-inst-env guix environment --no-grafts --ad-hoc \
--substitute-urls="http://guix.genenetwork.org https://berlin.guixsd.org https://mirror.hydra.gnu.org" \
coreutils book-evolutionary-genomics vim screen \
--container bash -- bash
#+end_src
starts up a bash shell in a clean container. For the book we have created
some scripts in the profile which can be found with the GUIX_ENVIRONMENT setting:
: cd $GUIX_ENVIRONMENT/share/book-evolutionary-genomics
The bin directory is on the PATH already, but for some scripts you may
want to create /usr/bin pointing to $GUIX_ENVIRONMENT/bin
: mkdir /usr
: ln -s $GUIX_ENVIRONMENT/bin /usr/bin
Note that /gnu/store is immutable and can therefore be shared with the
main system. This makes GNU Guix containers really small and fast.
*** Docker
You can create a Docker image without actually installing Docker(!)
#+begin_src shell
env GUIX_PACKAGE_PATH=../guix-bioinformatics/ \
./pre-inst-env guix pack -f docker --no-grafts \
-S /usr/bin=/bin coreutils book-evolutionary-genomics bash vim screen
#+end_src
note we now have the -S switch which can make the /usr/bin symlink
into the profile.
This produced a file which we can load into Docker
: docker load < /gnu/store/zln0bd5xwvp076ri8i42lqs8ynimix7n-docker-pack.tar.gz
: docker images
Now you should see the image id and you can run
: docker run 571260540410 /usr/bin/ruby --version
Find the profile
: docker run 571260540410 /usr/bin/ls /usr/bin -l
Read the profile settings
: docker run 571260540410 cat /gnu/store/425c1ignnjixxzwdwdr5anywnq9mg50m-profile/etc/profile
Run bioruby
: docker run 571260540410 bash -c "env GEM_PATH=/gnu/store/425c1ignnjixxzwdwdr5anywnq9mg50m-profile//lib/ruby/gems/2.4.0 /gnu/store/425c1ignnjixxzwdwdr5anywnq9mg50m-profile/share/book-evolutionary-genomics/src/bioruby/DNAtranslate.rb
with input file
: time docker run 571260540410 bash -c "env GEM_PATH=/gnu/store/425c1ignnjixxzwdwdr5anywnq9mg50m-profile//lib/ruby/gems/2.4.0 /gnu/store/425c1ignnjixxzwdwdr5anywnq9mg50m-profile/share/book-evolutionary-genomics/src/bioruby/DNAtranslate.rb /gnu/store/425c1ignnjixxzwdwdr5anywnq9mg50m-profile/share/book-evolutionary-genomics/test/data/test-dna.fa"

17
INSTALL.org

@ -525,12 +525,12 @@ when updating
Bootstrapping from source, after checking out the git Guix source tree
can be surprisingly tricky because of the build dependencies. Your
mileage may vary, but currently I recommend starting from the tar-ball
install described above instead and build Guix using Guix tools (in
the next section).
install described above instead and build Guix using Guix tools with
an environment and profile (explained in the next section).
For building from source I found it to be important to make sure not to
*mix* Guix and native dependencies. Also make sure you are using the
proper localstatedir.
For building from source it is particularly important not to *mix*
Guix and native dependencies. Also make sure you are using the proper
localstatedir.
* Building GNU Guix from source (using Guix) - the bullet proof way
@ -546,7 +546,7 @@ Install packages
#+begin_src sh :lang bash
guix package -i guix help2man git strace \
pkg-config less vim binutils coreutils grep guile guile-git gcc --no-grafts
pkg-config less vim binutils coreutils grep guile guile-git gcc guile-json --no-grafts
#+end_src sh :lang bash
The safest route is by using guix environment after starting
@ -568,7 +568,7 @@ in a pickle). For example:
screen -S guix-build # I tend to build in screen
env -i /bin/bash --login --noprofile --norc
/gnu/store/h410qzgv3ilk9pivi1a99q0pq0dlzkki-guix-0.13.0-5.228a398/bin/guix environment guix --ad-hoc help2man git strace \
pkg-config less vim binutils coreutils grep guile guile-git gcc --no-grafts
pkg-config less vim binutils coreutils grep guile guile-git gcc guile-json --no-grafts
bash # you may want this shell
#+end_src sh :lang bash
@ -584,7 +584,8 @@ env -i /bin/bash --login --noprofile --norc
bash # you may want this shell
#+end_src sh :lang bash
Use the --no-grafts switch if you have built packages that way before.
Use the --no-grafts switch if you have built packages that way before to avoid
triggering a full rebuild.
Note that you can opt to start guix by installing the binary tar ball,
or copying it from another machine using the rather useful `guix

Loading…
Cancel
Save