lxc.sh.rst 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. .. _snap: https://snapcraft.io
  2. .. _snapcraft LXD: https://snapcraft.io/lxd
  3. .. _LXC/LXD Image Server: https://uk.images.linuxcontainers.org/
  4. .. _LXC: https://linuxcontainers.org/lxc/introduction/
  5. .. _LXD: https://linuxcontainers.org/lxd/introduction/
  6. .. _`LXD@github`: https://github.com/lxc/lxd
  7. .. _archlinux: https://www.archlinux.org/
  8. .. _lxc.sh:
  9. ================
  10. ``utils/lxc.sh``
  11. ================
  12. .. sidebar:: further reading
  13. - snap_, `snapcraft LXD`_
  14. - LXC_, LXD_
  15. - `LXC/LXD Image Server`_
  16. - `LXD@github`_
  17. With the use of *Linux Containers* (LXC_) we can scale our tasks over a stack of
  18. containers, what we call the: *lxc suite*. The *searx suite*
  19. (:origin:`lxc-searx.env <utils/lxc-searx.env>`) is loaded by default, every time
  20. you start the ``lxc.sh`` script (*you do not need to care about*).
  21. Before you can start with containers, you need to install and initiate LXD_
  22. once::
  23. $ snap install lxd
  24. $ lxd init --auto
  25. To make use of the containers from the *searx suite*, you have to build the
  26. :ref:`LXC suite containers <lxc.sh help>` initial. But be warned, **this might
  27. take some time**::
  28. $ sudo -H ./utils/lxc.sh build
  29. A cup of coffee later, your LXC suite is build up and you can run whatever task
  30. you want / in a selected or even in all :ref:`LXC suite containers <lxc.sh
  31. help>`. If you do not want to build all containers, **you can build just
  32. one**::
  33. $ sudo -H ./utils/lxc.sh build searx-ubu1804
  34. *Good to know ...*
  35. Each container shares the root folder of the repository and the command
  36. ``utils/lxc.sh cmd`` **handles relative path names transparent**, compare output
  37. of::
  38. $ sudo -H ./utils/lxc.sh cmd -- ls -la Makefile
  39. ...
  40. In the containers, you can run what ever you want, e.g. to start a bash use::
  41. $ sudo -H ./utils/lxc.sh cmd searx-ubu1804 bash
  42. INFO: [searx-ubu1804] bash
  43. root@searx-ubu1804:/share/searx#
  44. If there comes the time you want to **get rid off all** the containers and
  45. **clean up local images** just type::
  46. $ sudo -H ./utils/lxc.sh remove
  47. $ sudo -H ./utils/lxc.sh remove images
  48. .. _lxc.sh install suite:
  49. Install suite
  50. =============
  51. To install the complete :ref:`searx suite (includes searx, morty & filtron)
  52. <lxc-searx.env>` into all LXC_ use::
  53. $ sudo -H ./utils/lxc.sh install suite
  54. The command above installs a searx suite (see :ref:`installation scripts`). To
  55. get the IP (URL) of the filtron service in the containers use ``show suite``
  56. command. To test instances from containers just open the URLs in your
  57. WEB-Browser::
  58. $ sudo ./utils/lxc.sh show suite | grep filtron
  59. [searx-ubu1604] INFO: (eth0) filtron: http://n.n.n.246:4004/ http://n.n.n.246/searx
  60. [searx-ubu1804] INFO: (eth0) filtron: http://n.n.n.147:4004/ http://n.n.n.147/searx
  61. [searx-ubu1910] INFO: (eth0) filtron: http://n.n.n.140:4004/ http://n.n.n.140/searx
  62. [searx-ubu2004] INFO: (eth0) filtron: http://n.n.n.18:4004/ http://n.n.n.18/searx
  63. [searx-fedora31] INFO: (eth0) filtron: http://n.n.n.46:4004/ http://n.n.n.46/searx
  64. [searx-archlinux] INFO: (eth0) filtron: http://n.n.n.32:4004/ http://n.n.n.32/searx
  65. To :ref:`install a nginx <installation nginx>` reverse proxy for filtron and
  66. morty use (or alternatively use :ref:`apache <installation apache>`)::
  67. sudo -H ./utils/lxc.sh cmd -- FORCE_TIMEOUT=0 ./utils/filtron.sh nginx install
  68. sudo -H ./utils/lxc.sh cmd -- FORCE_TIMEOUT=0 ./utils/morty.sh nginx install
  69. Running commands
  70. ================
  71. **Inside containers, you can use make or run scripts** from the
  72. :ref:`toolboxing`. By example: to setup a :ref:`buildhosts` and run the
  73. Makefile target ``test`` in the archlinux_ container::
  74. sudo -H ./utils/lxc.sh cmd searx-archlinux ./utils/searx.sh install buildhost
  75. sudo -H ./utils/lxc.sh cmd searx-archlinux make test
  76. Setup searx buildhost
  77. =====================
  78. You can **install the searx buildhost environment** into one or all containers.
  79. The installation procedure to set up a :ref:`build host<buildhosts>` takes its
  80. time. Installation in all containers will take more time (time for another cup
  81. of coffee).::
  82. sudo -H ./utils/lxc.sh cmd -- ./utils/searx.sh install buildhost
  83. To build (live) documentation inside a archlinux_ container::
  84. sudo -H ./utils/lxc.sh cmd searx-archlinux make docs.clean docs.live
  85. ...
  86. [I 200331 15:00:42 server:296] Serving on http://0.0.0.0:8080
  87. To get IP of the container and the port number *live docs* is listening::
  88. $ sudo ./utils/lxc.sh show suite | grep docs.live
  89. ...
  90. [searx-archlinux] INFO: (eth0) docs.live: http://n.n.n.12:8080/
  91. .. _lxc.sh help:
  92. Overview
  93. ========
  94. The ``--help`` output of the script is largely self-explanatory:
  95. .. program-output:: ../utils/lxc.sh --help
  96. .. _lxc-searx.env:
  97. searx suite
  98. ===========
  99. .. literalinclude:: ../../utils/lxc-searx.env
  100. :language: bash