lxcdev-202006.html 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1">
  7. <title>Developing in Linux containers [202006] &#8212; Searx Documentation (Searx-1.1.0.tex)</title>
  8. <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
  9. <link rel="stylesheet" type="text/css" href="../_static/searx.css" />
  10. <link rel="stylesheet" type="text/css" href="../_static/tabs.css" />
  11. <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
  12. <script src="../_static/jquery.js"></script>
  13. <script src="../_static/underscore.js"></script>
  14. <script src="../_static/_sphinx_javascript_frameworks_compat.js"></script>
  15. <script src="../_static/doctools.js"></script>
  16. <script src="../_static/sphinx_highlight.js"></script>
  17. <script src="../_static/tabs.js"></script>
  18. <link rel="index" title="Index" href="../genindex.html" />
  19. <link rel="search" title="Search" href="../search.html" />
  20. <link rel="next" title="Limit access to your searx engines" href="private-engines.html" />
  21. <link rel="prev" title="Running shell commands to fetch results" href="command-line-engines.html" />
  22. </head><body>
  23. <div class="related" role="navigation" aria-label="related navigation">
  24. <h3>Navigation</h3>
  25. <ul>
  26. <li class="right" style="margin-right: 10px">
  27. <a href="../genindex.html" title="General Index"
  28. accesskey="I">index</a></li>
  29. <li class="right" >
  30. <a href="../py-modindex.html" title="Python Module Index"
  31. >modules</a> |</li>
  32. <li class="right" >
  33. <a href="private-engines.html" title="Limit access to your searx engines"
  34. accesskey="N">next</a> |</li>
  35. <li class="right" >
  36. <a href="command-line-engines.html" title="Running shell commands to fetch results"
  37. accesskey="P">previous</a> |</li>
  38. <li class="nav-item nav-item-0"><a href="../index.html">Searx Documentation (Searx-1.1.0.tex)</a> &#187;</li>
  39. <li class="nav-item nav-item-1"><a href="index.html" accesskey="U">Blog</a> &#187;</li>
  40. <li class="nav-item nav-item-this"><a href="">Developing in Linux containers [202006]</a></li>
  41. </ul>
  42. </div>
  43. <div class="document">
  44. <div class="documentwrapper">
  45. <div class="bodywrapper">
  46. <div class="body" role="main">
  47. <section id="developing-in-linux-containers-202006">
  48. <span id="blog-lxcdev-202006"></span><h1>Developing in Linux containers [202006]<a class="headerlink" href="#developing-in-linux-containers-202006" title="Permalink to this heading">¶</a></h1>
  49. <aside class="sidebar">
  50. <p class="sidebar-title">Audience</p>
  51. <p>This blog post is written for experienced admins and developers / readers
  52. should have a serious meaning about: <em>distributed</em>, <em>merge</em> and <em>linux
  53. container</em>.</p>
  54. </aside>
  55. <nav class="contents local" id="contents">
  56. <p class="topic-title">Contents</p>
  57. <ul class="simple">
  58. <li><p><a class="reference internal" href="#motivation" id="id1">Motivation</a></p></li>
  59. <li><p><a class="reference internal" href="#gentlemen-start-your-engines" id="id2">Gentlemen, start your engines!</a></p></li>
  60. <li><p><a class="reference internal" href="#in-containers-work-as-usual" id="id3">In containers, work as usual</a></p></li>
  61. <li><p><a class="reference internal" href="#wrap-production-into-developer-suite" id="id4">Wrap production into developer suite</a></p></li>
  62. <li><p><a class="reference internal" href="#abstract" id="id5">Abstract</a></p></li>
  63. </ul>
  64. </nav>
  65. <p>In PR <a class="reference external" href="https://github.com/searx/searx/pull/1803">#1803</a> we added a lot of scripts to Searx’s boilerplate. In this blog
  66. post I will show you, how you can make use of them in <em>distributed and
  67. heterogeneous development cycles</em> (TL;DR; jump to the <a class="reference internal" href="#blog-lxcdev-202006-abstract"><span class="std std-ref">Abstract</span></a>).</p>
  68. <section id="motivation">
  69. <h2><a class="toc-backref" href="#id1" role="doc-backlink">Motivation</a><a class="headerlink" href="#motivation" title="Permalink to this heading">¶</a></h2>
  70. <p>Normally in our development cycle, we edit the sources and run some test and/or
  71. builds by using <code class="docutils literal notranslate"><span class="pre">make</span></code> before we commit. This cycle is simple and perfect but
  72. might fail in some aspects we should not overlook.</p>
  73. <blockquote>
  74. <div><p>The environment in which we run all our development processes matters!</p>
  75. </div></blockquote>
  76. <p>The <a class="reference internal" href="../dev/makefile.html#makefile"><span class="std std-ref">Makefile</span></a> and the <a class="reference internal" href="../dev/makefile.html#make-install"><span class="std std-ref">Python environment</span></a> encapsulate a lot for us, but they
  77. do not have access to all prerequisites. For example, there may have
  78. dependencies on packages that are installed on the developer’s desktop, but
  79. usually are not preinstalled on a server or client system. Another examples
  80. are; settings have been made to the software on the developer’s host that would
  81. never be set on a <em>production</em> system.</p>
  82. <p><em>Linux Containers</em> (<a class="reference external" href="https://linuxcontainers.org/lxc/introduction/">LXC</a>) are isolate environments and not to mix up on
  83. developer’s all the prerequisites of all the projects he contribute to, is
  84. always a good choice.</p>
  85. <p>The scripts from PR <a class="reference external" href="https://github.com/searx/searx/pull/1803">#1803</a> can divide in those to install and maintain
  86. software:</p>
  87. <ul class="simple">
  88. <li><p><a class="reference internal" href="../utils/searx.sh.html#searx-sh"><span class="std std-ref">utils/searx.sh</span></a></p></li>
  89. <li><p><a class="reference internal" href="../utils/filtron.sh.html#filtron-sh"><span class="std std-ref">utils/filtron.sh</span></a></p></li>
  90. <li><p><a class="reference internal" href="../utils/morty.sh.html#morty-sh"><span class="std std-ref">utils/morty.sh</span></a></p></li>
  91. </ul>
  92. <p>and the script <a class="reference internal" href="../utils/lxc.sh.html#lxc-sh"><span class="std std-ref">utils/lxc.sh</span></a>, with we can scale our installation, maintenance or
  93. even development tasks over a stack of containers, what we call: <em>Searx’s lxc
  94. suite</em>.</p>
  95. </section>
  96. <section id="gentlemen-start-your-engines">
  97. <h2><a class="toc-backref" href="#id2" role="doc-backlink">Gentlemen, start your engines!</a><a class="headerlink" href="#gentlemen-start-your-engines" title="Permalink to this heading">¶</a></h2>
  98. <p>Before you can start with containers, you need to install and initiate <a class="reference external" href="https://linuxcontainers.org/lxd/introduction/">LXD</a>
  99. once:</p>
  100. <div class="sphinx-tabs docutils container">
  101. <div aria-label="Tabbed content" class="closeable" role="tablist"><button aria-controls="panel-0-ZGVza3RvcA==" aria-selected="true" class="sphinx-tabs-tab group-tab" id="tab-0-ZGVza3RvcA==" name="ZGVza3RvcA==" role="tab" tabindex="0">desktop</button></div><div aria-labelledby="tab-0-ZGVza3RvcA==" class="sphinx-tabs-panel group-tab" id="panel-0-ZGVza3RvcA==" name="ZGVza3RvcA==" role="tabpanel" tabindex="0"><div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ snap install lxd
  102. $ lxd init --auto
  103. </pre></div>
  104. </div>
  105. </div></div>
  106. <p>And you need to clone from origin or if you have your own fork, clone from your
  107. fork:</p>
  108. <div class="sphinx-tabs docutils container">
  109. <div aria-label="Tabbed content" class="closeable" role="tablist"><button aria-controls="panel-1-ZGVza3RvcA==" aria-selected="true" class="sphinx-tabs-tab group-tab" id="tab-1-ZGVza3RvcA==" name="ZGVza3RvcA==" role="tab" tabindex="0">desktop</button></div><div aria-labelledby="tab-1-ZGVza3RvcA==" class="sphinx-tabs-panel group-tab" id="panel-1-ZGVza3RvcA==" name="ZGVza3RvcA==" role="tabpanel" tabindex="0"><div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ <span class="nb">cd</span> ~/Downloads
  110. $ git clone https://github.com/searx/searx.git
  111. $ <span class="nb">cd</span> searx
  112. </pre></div>
  113. </div>
  114. </div></div>
  115. <p>The <a class="reference internal" href="../utils/lxc.sh.html#lxc-searx-env"><span class="std std-ref">searx suite</span></a> consists of several images, see <code class="docutils literal notranslate"><span class="pre">export</span>
  116. <span class="pre">LXC_SUITE=(...</span></code> near by <a class="reference external" href="https://github.com/searx/searx/blob/master/utils/lxc-searx.env#L19">Origin: utils/lxc-searx.env#L19</a>. For this blog post
  117. we exercise on a <a class="reference external" href="https://www.archlinux.org/">archlinux</a> image. The container of this image is named
  118. <code class="docutils literal notranslate"><span class="pre">searx-archlinux</span></code>. Lets build the container, but be sure that this container
  119. does not already exists, so first lets remove possible old one:</p>
  120. <div class="sphinx-tabs docutils container">
  121. <div aria-label="Tabbed content" class="closeable" role="tablist"><button aria-controls="panel-2-ZGVza3RvcA==" aria-selected="true" class="sphinx-tabs-tab group-tab" id="tab-2-ZGVza3RvcA==" name="ZGVza3RvcA==" role="tab" tabindex="0">desktop</button></div><div aria-labelledby="tab-2-ZGVza3RvcA==" class="sphinx-tabs-panel group-tab" id="panel-2-ZGVza3RvcA==" name="ZGVza3RvcA==" role="tabpanel" tabindex="0"><div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ sudo -H ./utils/lxc.sh remove searx-archlinux
  122. $ sudo -H ./utils/lxc.sh build searx-archlinux
  123. </pre></div>
  124. </div>
  125. </div></div>
  126. <aside class="sidebar">
  127. <p class="sidebar-title">The <code class="docutils literal notranslate"><span class="pre">searx-archlinux</span></code> container</p>
  128. <p>is the base of all our exercises here.</p>
  129. </aside>
  130. <p>In this container we install all services <a class="reference internal" href="../utils/lxc.sh.html#lxc-sh-install-suite"><span class="std std-ref">including searx, morty &amp; filtron</span></a> in once:</p>
  131. <div class="sphinx-tabs docutils container">
  132. <div aria-label="Tabbed content" class="closeable" role="tablist"><button aria-controls="panel-3-ZGVza3RvcA==" aria-selected="true" class="sphinx-tabs-tab group-tab" id="tab-3-ZGVza3RvcA==" name="ZGVza3RvcA==" role="tab" tabindex="0">desktop</button></div><div aria-labelledby="tab-3-ZGVza3RvcA==" class="sphinx-tabs-panel group-tab" id="panel-3-ZGVza3RvcA==" name="ZGVza3RvcA==" role="tabpanel" tabindex="0"><div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ sudo -H ./utils/lxc.sh install suite searx-archlinux
  133. </pre></div>
  134. </div>
  135. </div></div>
  136. <p>To proxy HTTP from filtron and morty in the container to the outside of the
  137. container, install nginx into the container. Once for the bot blocker filtron:</p>
  138. <div class="sphinx-tabs docutils container">
  139. <div aria-label="Tabbed content" class="closeable" role="tablist"><button aria-controls="panel-4-ZGVza3RvcA==" aria-selected="true" class="sphinx-tabs-tab group-tab" id="tab-4-ZGVza3RvcA==" name="ZGVza3RvcA==" role="tab" tabindex="0">desktop</button></div><div aria-labelledby="tab-4-ZGVza3RvcA==" class="sphinx-tabs-panel group-tab" id="panel-4-ZGVza3RvcA==" name="ZGVza3RvcA==" role="tabpanel" tabindex="0"><div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ sudo -H ./utils/lxc.sh cmd searx-archlinux <span class="se">\</span>
  140. ./utils/filtron.sh nginx install
  141. ...
  142. INFO: got <span class="m">429</span> from http://10.174.184.156/searx
  143. </pre></div>
  144. </div>
  145. </div></div>
  146. <p>and once for the content sanitizer (content proxy morty):</p>
  147. <div class="sphinx-tabs docutils container">
  148. <div aria-label="Tabbed content" class="closeable" role="tablist"><button aria-controls="panel-5-ZGVza3RvcA==" aria-selected="true" class="sphinx-tabs-tab group-tab" id="tab-5-ZGVza3RvcA==" name="ZGVza3RvcA==" role="tab" tabindex="0">desktop</button></div><div aria-labelledby="tab-5-ZGVza3RvcA==" class="sphinx-tabs-panel group-tab" id="panel-5-ZGVza3RvcA==" name="ZGVza3RvcA==" role="tabpanel" tabindex="0"><div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ sudo -H ./utils/lxc.sh cmd searx-archlinux <span class="se">\</span>
  149. ./utils/morty.sh nginx install
  150. ...
  151. INFO: got <span class="m">200</span> from http://10.174.184.156/morty/
  152. </pre></div>
  153. </div>
  154. </div></div>
  155. <aside class="sidebar">
  156. <p class="sidebar-title">Fully functional searx suite</p>
  157. <p>From here on you have a fully functional searx suite running with bot blocker
  158. (filtron) and Web content sanitizer (content proxy morty) needed for a
  159. <em>privacy protecting</em> search engine.</p>
  160. </aside>
  161. <p>On your system, the IP of your <code class="docutils literal notranslate"><span class="pre">searx-archlinux</span></code> container differs from
  162. <a class="reference external" href="http://10.174.184.156/searx">http://10.174.184.156/searx</a>, just open the URL reported in your installation
  163. protocol in your WEB browser from the desktop to test the instance from outside
  164. of the container.</p>
  165. <p>In such a searx suite admins can maintain and access the debug log of the
  166. different services quite easy.</p>
  167. </section>
  168. <section id="in-containers-work-as-usual">
  169. <span id="working-in-containers"></span><h2><a class="toc-backref" href="#id3" role="doc-backlink">In containers, work as usual</a><a class="headerlink" href="#in-containers-work-as-usual" title="Permalink to this heading">¶</a></h2>
  170. <p>Usually you open a root-bash using <code class="docutils literal notranslate"><span class="pre">sudo</span> <span class="pre">-H</span> <span class="pre">bash</span></code>. In case of LXC containers
  171. open the root-bash in the container using <code class="docutils literal notranslate"><span class="pre">./utils/lxc.sh</span> <span class="pre">cmd</span>
  172. <span class="pre">searx-archlinux</span></code>:</p>
  173. <div class="sphinx-tabs docutils container">
  174. <div aria-label="Tabbed content" class="closeable" role="tablist"><button aria-controls="panel-6-ZGVza3RvcA==" aria-selected="true" class="sphinx-tabs-tab group-tab" id="tab-6-ZGVza3RvcA==" name="ZGVza3RvcA==" role="tab" tabindex="0">desktop</button></div><div aria-labelledby="tab-6-ZGVza3RvcA==" class="sphinx-tabs-panel group-tab" id="panel-6-ZGVza3RvcA==" name="ZGVza3RvcA==" role="tabpanel" tabindex="0"><div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ sudo -H ./utils/lxc.sh cmd searx-archlinux bash
  175. INFO: <span class="o">[</span>searx-archlinux<span class="o">]</span> bash
  176. <span class="o">[</span>root@searx-archlinux searx<span class="o">]</span><span class="c1"># pwd</span>
  177. /share/searx
  178. </pre></div>
  179. </div>
  180. </div></div>
  181. <p>The prompt <code class="docutils literal notranslate"><span class="pre">[root&#64;searx-archlinux</span> <span class="pre">...]</span></code> signals, that you are the root user in
  182. the searx-container. To debug the running searx instance use:</p>
  183. <div class="sphinx-tabs docutils container">
  184. <div aria-label="Tabbed content" class="closeable" role="tablist"><button aria-controls="panel-7-cm9vdEBzZWFyeC1hcmNobGludXg=" aria-selected="true" class="sphinx-tabs-tab group-tab" id="tab-7-cm9vdEBzZWFyeC1hcmNobGludXg=" name="cm9vdEBzZWFyeC1hcmNobGludXg=" role="tab" tabindex="0"><a class="reference external" href="mailto:root&#37;&#52;&#48;searx-archlinux">root<span>&#64;</span>searx-archlinux</a></button></div><div aria-labelledby="tab-7-cm9vdEBzZWFyeC1hcmNobGludXg=" class="sphinx-tabs-panel group-tab" id="panel-7-cm9vdEBzZWFyeC1hcmNobGludXg=" name="cm9vdEBzZWFyeC1hcmNobGludXg=" role="tabpanel" tabindex="0"><div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ ./utils/searx.sh inspect service
  185. ...
  186. use <span class="o">[</span>CTRL-C<span class="o">]</span> to stop monitoring the log
  187. ...
  188. </pre></div>
  189. </div>
  190. </div></div>
  191. <p>Back in the browser on your desktop open the service <a class="reference external" href="http://10.174.184.156/searx">http://10.174.184.156/searx</a>
  192. and run your application tests while the debug log is shown in the terminal from
  193. above. You can stop monitoring using <code class="docutils literal notranslate"><span class="pre">CTRL-C</span></code>, this also disables the <em>“debug
  194. option”</em> in searx’s settings file and restarts the searx uwsgi application. To
  195. debug services from filtron and morty analogous use:</p>
  196. <div class="sphinx-tabs docutils container">
  197. <div aria-label="Tabbed content" class="closeable" role="tablist"><button aria-controls="panel-8-cm9vdEBzZWFyeC1hcmNobGludXg=" aria-selected="true" class="sphinx-tabs-tab group-tab" id="tab-8-cm9vdEBzZWFyeC1hcmNobGludXg=" name="cm9vdEBzZWFyeC1hcmNobGludXg=" role="tab" tabindex="0"><a class="reference external" href="mailto:root&#37;&#52;&#48;searx-archlinux">root<span>&#64;</span>searx-archlinux</a></button></div><div aria-labelledby="tab-8-cm9vdEBzZWFyeC1hcmNobGludXg=" class="sphinx-tabs-panel group-tab" id="panel-8-cm9vdEBzZWFyeC1hcmNobGludXg=" name="cm9vdEBzZWFyeC1hcmNobGludXg=" role="tabpanel" tabindex="0"><div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ ./utils/filtron.sh inspect service
  198. $ ./utils/morty.sh inspect service
  199. </pre></div>
  200. </div>
  201. </div></div>
  202. <p>Another point we have to notice is that each service (<a class="reference internal" href="../utils/searx.sh.html#searx-sh"><span class="std std-ref">searx</span></a>,
  203. <a class="reference internal" href="../utils/filtron.sh.html#filtron-sh"><span class="std std-ref">filtron</span></a> and <a class="reference internal" href="../utils/morty.sh.html#morty-sh"><span class="std std-ref">morty</span></a>) runs under dedicated
  204. system user account with the same name (compare <a class="reference internal" href="../admin/installation-searx.html#create-searx-user"><span class="std std-ref">Create user</span></a>). To
  205. get a shell from these accounts, simply call one of the scripts:</p>
  206. <div class="sphinx-tabs docutils container">
  207. <div aria-label="Tabbed content" class="closeable" role="tablist"><button aria-controls="panel-9-cm9vdEBzZWFyeC1hcmNobGludXg=" aria-selected="true" class="sphinx-tabs-tab group-tab" id="tab-9-cm9vdEBzZWFyeC1hcmNobGludXg=" name="cm9vdEBzZWFyeC1hcmNobGludXg=" role="tab" tabindex="0"><a class="reference external" href="mailto:root&#37;&#52;&#48;searx-archlinux">root<span>&#64;</span>searx-archlinux</a></button></div><div aria-labelledby="tab-9-cm9vdEBzZWFyeC1hcmNobGludXg=" class="sphinx-tabs-panel group-tab" id="panel-9-cm9vdEBzZWFyeC1hcmNobGludXg=" name="cm9vdEBzZWFyeC1hcmNobGludXg=" role="tabpanel" tabindex="0"><div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ ./utils/searx.sh shell
  208. $ ./utils/filtron.sh shell
  209. $ ./utils/morty.sh shell
  210. </pre></div>
  211. </div>
  212. </div></div>
  213. <p>To get in touch, open a shell from the service user (<a class="reference external" href="mailto:searx&#37;&#52;&#48;searx-archlinux">searx<span>&#64;</span>searx-archlinux</a>):</p>
  214. <div class="sphinx-tabs docutils container">
  215. <div aria-label="Tabbed content" class="closeable" role="tablist"><button aria-controls="panel-10-ZGVza3RvcA==" aria-selected="true" class="sphinx-tabs-tab group-tab" id="tab-10-ZGVza3RvcA==" name="ZGVza3RvcA==" role="tab" tabindex="0">desktop</button></div><div aria-labelledby="tab-10-ZGVza3RvcA==" class="sphinx-tabs-panel group-tab" id="panel-10-ZGVza3RvcA==" name="ZGVza3RvcA==" role="tabpanel" tabindex="0"><div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ sudo -H ./utils/lxc.sh cmd searx-archlinux <span class="se">\</span>
  216. ./utils/searx.sh shell
  217. // <span class="nb">exit</span> with <span class="o">[</span>CTRL-D<span class="o">]</span>
  218. <span class="o">(</span>searx-pyenv<span class="o">)</span> <span class="o">[</span>searx@searx-archlinux ~<span class="o">]</span>$ ...
  219. </pre></div>
  220. </div>
  221. </div></div>
  222. <p>The prompt <code class="docutils literal notranslate"><span class="pre">[searx&#64;searx-archlinux]</span></code> signals that you are logged in as system
  223. user <code class="docutils literal notranslate"><span class="pre">searx</span></code> in the <code class="docutils literal notranslate"><span class="pre">searx-archlinux</span></code> container and the python <em>virtualenv</em>
  224. <code class="docutils literal notranslate"><span class="pre">(searx-pyenv)</span></code> environment is activated.</p>
  225. <div class="sphinx-tabs docutils container">
  226. <div aria-label="Tabbed content" class="closeable" role="tablist"><button aria-controls="panel-11-c2VhcnhAc2VhcngtYXJjaGxpbnV4" aria-selected="true" class="sphinx-tabs-tab group-tab" id="tab-11-c2VhcnhAc2VhcngtYXJjaGxpbnV4" name="c2VhcnhAc2VhcngtYXJjaGxpbnV4" role="tab" tabindex="0"><a class="reference external" href="mailto:searx&#37;&#52;&#48;searx-archlinux">searx<span>&#64;</span>searx-archlinux</a></button></div><div aria-labelledby="tab-11-c2VhcnhAc2VhcngtYXJjaGxpbnV4" class="sphinx-tabs-panel group-tab" id="panel-11-c2VhcnhAc2VhcngtYXJjaGxpbnV4" name="c2VhcnhAc2VhcngtYXJjaGxpbnV4" role="tabpanel" tabindex="0"><div class="highlight-sh notranslate"><div class="highlight"><pre><span></span><span class="o">(</span>searx-pyenv<span class="o">)</span> <span class="o">[</span>searx@searx-archlinux ~<span class="o">]</span>$ <span class="nb">pwd</span>
  227. /usr/local/searx
  228. </pre></div>
  229. </div>
  230. </div></div>
  231. </section>
  232. <section id="wrap-production-into-developer-suite">
  233. <h2><a class="toc-backref" href="#id4" role="doc-backlink">Wrap production into developer suite</a><a class="headerlink" href="#wrap-production-into-developer-suite" title="Permalink to this heading">¶</a></h2>
  234. <p>In this section we will see how to change the <em>“Fully functional searx suite”</em>
  235. from a LXC container (which is quite ready for production) into a developer
  236. suite. For this, we have to keep an eye on the <a class="reference internal" href="../admin/installation-searx.html#installation-basic"><span class="std std-ref">Step by step installation</span></a>:</p>
  237. <ul class="simple">
  238. <li><p>searx setup in: <code class="docutils literal notranslate"><span class="pre">/etc/searx/settings.yml</span></code></p></li>
  239. <li><p>searx user’s home: <code class="docutils literal notranslate"><span class="pre">/usr/local/searx</span></code></p></li>
  240. <li><p>virtualenv in: <code class="docutils literal notranslate"><span class="pre">/usr/local/searx/searx-pyenv</span></code></p></li>
  241. <li><p>searx software in: <code class="docutils literal notranslate"><span class="pre">/usr/local/searx/searx-src</span></code></p></li>
  242. </ul>
  243. <p>The searx software is a clone of the <code class="docutils literal notranslate"><span class="pre">git_url</span></code> (see <a class="reference internal" href="../admin/settings.html#settings-global"><span class="std std-ref">Global Settings</span></a>) and
  244. the working tree is checked out from the <code class="docutils literal notranslate"><span class="pre">git_branch</span></code>. With the use of the
  245. <a class="reference internal" href="../utils/searx.sh.html#searx-sh"><span class="std std-ref">utils/searx.sh</span></a> the searx service was installed as <a class="reference internal" href="../admin/installation-uwsgi.html#searx-uwsgi"><span class="std std-ref">uWSGI application</span></a>. To maintain this service, we can use <code class="docutils literal notranslate"><span class="pre">systemctl</span></code> (compare
  246. <a class="reference internal" href="../admin/installation-uwsgi.html#uwsgi-configuration"><span class="std std-ref">service architectures on distributions</span></a>).</p>
  247. <div class="sphinx-tabs docutils container">
  248. <div aria-label="Tabbed content" class="closeable" role="tablist"><button aria-controls="panel-12-ZGVza3RvcA==" aria-selected="true" class="sphinx-tabs-tab group-tab" id="tab-12-ZGVza3RvcA==" name="ZGVza3RvcA==" role="tab" tabindex="0">desktop</button></div><div aria-labelledby="tab-12-ZGVza3RvcA==" class="sphinx-tabs-panel group-tab" id="panel-12-ZGVza3RvcA==" name="ZGVza3RvcA==" role="tabpanel" tabindex="0"><div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ sudo -H ./utils/lxc.sh cmd searx-archlinux <span class="se">\</span>
  249. systemctl stop uwsgi@searx
  250. </pre></div>
  251. </div>
  252. </div></div>
  253. <p>With the command above, we stopped the searx uWSGI-App in the archlinux
  254. container.</p>
  255. <p>The uWSGI-App for the archlinux dsitros is configured in
  256. <a class="reference external" href="https://github.com/searx/searx/blob/master/utils/templates/etc/uwsgi/apps-archlinux/searx.ini">Origin: utils/templates/etc/uwsgi/apps-archlinux/searx.ini</a>, from where at
  257. least you should attend the settings of <code class="docutils literal notranslate"><span class="pre">uid</span></code>, <code class="docutils literal notranslate"><span class="pre">chdir</span></code>, <code class="docutils literal notranslate"><span class="pre">env</span></code> and
  258. <code class="docutils literal notranslate"><span class="pre">http</span></code>:</p>
  259. <div class="highlight-none notranslate"><div class="highlight"><pre><span></span>env = SEARX_SETTINGS_PATH=/etc/searx/settings.yml
  260. http = 127.0.0.1:8888
  261. chdir = /usr/local/searx/searx-src/searx
  262. virtualenv = /usr/local/searx/searx-pyenv
  263. pythonpath = /usr/local/searx/searx-src
  264. </pre></div>
  265. </div>
  266. <p>If you have read the <a class="reference internal" href="../utils/lxc.sh.html#lxc-sh"><span class="std std-ref">“Good to know section”</span></a> you remember, that
  267. each container shares the root folder of the repository and the command
  268. <code class="docutils literal notranslate"><span class="pre">utils/lxc.sh</span> <span class="pre">cmd</span></code> handles relative path names <strong>transparent</strong>. To wrap the
  269. searx installation into a developer one, we simple have to create a smylink to
  270. the <strong>transparent</strong> reposetory from the desktop. Now lets replace the
  271. repository at <code class="docutils literal notranslate"><span class="pre">searx-src</span></code> in the container with the working tree from outside
  272. of the container:</p>
  273. <div class="sphinx-tabs docutils container">
  274. <div aria-label="Tabbed content" class="closeable" role="tablist"><button aria-controls="panel-13-Y29udGFpbmVyIGJlY29tZXMgYSBkZXZlbG9wZXIgc3VpdGU=" aria-selected="true" class="sphinx-tabs-tab group-tab" id="tab-13-Y29udGFpbmVyIGJlY29tZXMgYSBkZXZlbG9wZXIgc3VpdGU=" name="Y29udGFpbmVyIGJlY29tZXMgYSBkZXZlbG9wZXIgc3VpdGU=" role="tab" tabindex="0">container becomes a developer suite</button></div><div aria-labelledby="tab-13-Y29udGFpbmVyIGJlY29tZXMgYSBkZXZlbG9wZXIgc3VpdGU=" class="sphinx-tabs-panel group-tab" id="panel-13-Y29udGFpbmVyIGJlY29tZXMgYSBkZXZlbG9wZXIgc3VpdGU=" name="Y29udGFpbmVyIGJlY29tZXMgYSBkZXZlbG9wZXIgc3VpdGU=" role="tabpanel" tabindex="0"><div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ sudo -H ./utils/lxc.sh cmd searx-archlinux <span class="se">\</span>
  275. mv /usr/local/searx/searx-src /usr/local/searx/searx-src.old
  276. $ sudo -H ./utils/lxc.sh cmd searx-archlinux <span class="se">\</span>
  277. ln -s /share/searx/ /usr/local/searx/searx-src
  278. </pre></div>
  279. </div>
  280. </div></div>
  281. <p>Now we can develop as usual in the working tree of our desktop system. Every
  282. time the software was changed, you have to restart the searx service (in the
  283. container):</p>
  284. <div class="sphinx-tabs docutils container">
  285. <div aria-label="Tabbed content" class="closeable" role="tablist"><button aria-controls="panel-14-ZGVza3RvcA==" aria-selected="true" class="sphinx-tabs-tab group-tab" id="tab-14-ZGVza3RvcA==" name="ZGVza3RvcA==" role="tab" tabindex="0">desktop</button></div><div aria-labelledby="tab-14-ZGVza3RvcA==" class="sphinx-tabs-panel group-tab" id="panel-14-ZGVza3RvcA==" name="ZGVza3RvcA==" role="tabpanel" tabindex="0"><div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ sudo -H ./utils/lxc.sh cmd searx-archlinux <span class="se">\</span>
  286. systemctl restart uwsgi@searx
  287. </pre></div>
  288. </div>
  289. </div></div>
  290. <p>Remember: <a class="reference internal" href="#working-in-containers"><span class="std std-ref">In containers, work as usual</span></a> .. here are just some examples from my
  291. daily usage:</p>
  292. <div class="sphinx-tabs docutils container">
  293. <div aria-label="Tabbed content" class="closeable" role="tablist"><button aria-controls="panel-15-ZGVza3RvcA==" aria-selected="true" class="sphinx-tabs-tab group-tab" id="tab-15-ZGVza3RvcA==" name="ZGVza3RvcA==" role="tab" tabindex="0">desktop</button></div><div aria-labelledby="tab-15-ZGVza3RvcA==" class="sphinx-tabs-panel group-tab" id="panel-15-ZGVza3RvcA==" name="ZGVza3RvcA==" role="tabpanel" tabindex="0"><p>To <em>inspect</em> the searx instance (already described above):</p>
  294. <div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ sudo -H ./utils/lxc.sh cmd searx-archlinux <span class="se">\</span>
  295. ./utils/searx.sh inspect service
  296. </pre></div>
  297. </div>
  298. <p>Run <a class="reference internal" href="../dev/makefile.html#makefile"><span class="std std-ref">Makefile</span></a>, e.g. to test inside the container:</p>
  299. <div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ sudo -H ./utils/lxc.sh cmd searx-archlinux <span class="se">\</span>
  300. make <span class="nb">test</span>
  301. </pre></div>
  302. </div>
  303. <p>To install all prerequisites needed for a <a class="reference internal" href="../admin/buildhosts.html#buildhosts"><span class="std std-ref">Buildhosts</span></a>:</p>
  304. <div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ sudo -H ./utils/lxc.sh cmd searx-archlinux <span class="se">\</span>
  305. ./utils/searx.sh install buildhost
  306. </pre></div>
  307. </div>
  308. <p>To build the docs on a buildhost <a class="reference internal" href="../admin/buildhosts.html#buildhosts"><span class="std std-ref">Buildhosts</span></a>:</p>
  309. <div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ sudo -H ./utils/lxc.sh cmd searx-archlinux <span class="se">\</span>
  310. make docs.html
  311. </pre></div>
  312. </div>
  313. </div></div>
  314. </section>
  315. <section id="abstract">
  316. <span id="blog-lxcdev-202006-abstract"></span><h2><a class="toc-backref" href="#id5" role="doc-backlink">Abstract</a><a class="headerlink" href="#abstract" title="Permalink to this heading">¶</a></h2>
  317. <p>We build up a fully functional searx suite in a archlinux container:</p>
  318. <div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ sudo -H ./utils/lxc.sh install suite searx-archlinux
  319. </pre></div>
  320. </div>
  321. <p>To access HTTP from the desktop we installed nginx for the services inside the
  322. container:</p>
  323. <div class="sphinx-tabs docutils container">
  324. <div aria-label="Tabbed content" class="closeable" role="tablist"><button aria-controls="panel-16-W3Jvb3RAc2VhcngtYXJjaGxpbnV4XQ==" aria-selected="true" class="sphinx-tabs-tab group-tab" id="tab-16-W3Jvb3RAc2VhcngtYXJjaGxpbnV4XQ==" name="W3Jvb3RAc2VhcngtYXJjaGxpbnV4XQ==" role="tab" tabindex="0">[<a class="reference external" href="mailto:root&#37;&#52;&#48;searx-archlinux">root<span>&#64;</span>searx-archlinux</a>]</button></div><div aria-labelledby="tab-16-W3Jvb3RAc2VhcngtYXJjaGxpbnV4XQ==" class="sphinx-tabs-panel group-tab" id="panel-16-W3Jvb3RAc2VhcngtYXJjaGxpbnV4XQ==" name="W3Jvb3RAc2VhcngtYXJjaGxpbnV4XQ==" role="tabpanel" tabindex="0"><div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ ./utils/filtron.sh nginx install
  325. $ ./utils/morty.sh nginx install
  326. </pre></div>
  327. </div>
  328. </div></div>
  329. <p>To wrap the suite into a developer one, we created a symbolic link to the
  330. repository which is shared <strong>transparent</strong> from the desktop’s file system into
  331. the container :</p>
  332. <div class="sphinx-tabs docutils container">
  333. <div aria-label="Tabbed content" class="closeable" role="tablist"><button aria-controls="panel-17-W3Jvb3RAc2VhcngtYXJjaGxpbnV4XQ==" aria-selected="true" class="sphinx-tabs-tab group-tab" id="tab-17-W3Jvb3RAc2VhcngtYXJjaGxpbnV4XQ==" name="W3Jvb3RAc2VhcngtYXJjaGxpbnV4XQ==" role="tab" tabindex="0">[<a class="reference external" href="mailto:root&#37;&#52;&#48;searx-archlinux">root<span>&#64;</span>searx-archlinux</a>]</button></div><div aria-labelledby="tab-17-W3Jvb3RAc2VhcngtYXJjaGxpbnV4XQ==" class="sphinx-tabs-panel group-tab" id="panel-17-W3Jvb3RAc2VhcngtYXJjaGxpbnV4XQ==" name="W3Jvb3RAc2VhcngtYXJjaGxpbnV4XQ==" role="tabpanel" tabindex="0"><div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ mv /usr/local/searx/searx-src /usr/local/searx/searx-src.old
  334. $ ln -s /share/searx/ /usr/local/searx/searx-src
  335. $ systemctl restart uwsgi@searx
  336. </pre></div>
  337. </div>
  338. </div></div>
  339. <p>To get remarks from the suite of the archlinux container we can use:</p>
  340. <div class="sphinx-tabs docutils container">
  341. <div aria-label="Tabbed content" class="closeable" role="tablist"><button aria-controls="panel-18-ZGVza3RvcA==" aria-selected="true" class="sphinx-tabs-tab group-tab" id="tab-18-ZGVza3RvcA==" name="ZGVza3RvcA==" role="tab" tabindex="0">desktop</button></div><div aria-labelledby="tab-18-ZGVza3RvcA==" class="sphinx-tabs-panel group-tab" id="panel-18-ZGVza3RvcA==" name="ZGVza3RvcA==" role="tabpanel" tabindex="0"><div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ sudo -H ./utils/lxc.sh show suite searx-archlinux
  342. ...
  343. <span class="o">[</span>searx-archlinux<span class="o">]</span> INFO: <span class="o">(</span>eth0<span class="o">)</span> filtron: http://10.174.184.156:4004/ http://10.174.184.156/searx
  344. <span class="o">[</span>searx-archlinux<span class="o">]</span> INFO: <span class="o">(</span>eth0<span class="o">)</span> morty: http://10.174.184.156:3000/
  345. <span class="o">[</span>searx-archlinux<span class="o">]</span> INFO: <span class="o">(</span>eth0<span class="o">)</span> docs.live: http://10.174.184.156:8080/
  346. <span class="o">[</span>searx-archlinux<span class="o">]</span> INFO: <span class="o">(</span>eth0<span class="o">)</span> IPv6: http://<span class="o">[</span>fd42:573b:e0b3:e97e:216:3eff:fea5:9b65<span class="o">]</span>
  347. ...
  348. </pre></div>
  349. </div>
  350. </div></div>
  351. </section>
  352. </section>
  353. <div class="clearer"></div>
  354. </div>
  355. </div>
  356. </div>
  357. <span id="sidebar-top"></span>
  358. <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
  359. <div class="sphinxsidebarwrapper">
  360. <p class="logo"><a href="../index.html">
  361. <img class="logo" src="../_static/searx_logo_small.png" alt="Logo"/>
  362. </a></p>
  363. <h3>Project Links</h3>
  364. <ul>
  365. <li><a href="https://searx.github.io/searx/blog/index.html">Blog</a>
  366. <li><a href="https://github.com/searx/searx">Source</a>
  367. <li><a href="https://github.com/searx/searx/wiki">Wiki</a>
  368. <li><a href="https://twitter.com/Searx_engine">Twitter</a>
  369. <li><a href="https://github.com/searx/searx/issues">Issue Tracker</a>
  370. </ul><h3>Navigation</h3>
  371. <ul>
  372. <li><a href="../index.html">Overview</a>
  373. <ul>
  374. <li><a href="index.html">Blog</a>
  375. <ul>
  376. <li>Previous: <a href="command-line-engines.html" title="previous chapter">Running shell commands to fetch results</a>
  377. <li>Next: <a href="private-engines.html" title="next chapter">Limit access to your searx engines</a></ul>
  378. </li>
  379. </ul>
  380. </li>
  381. </ul>
  382. <div id="searchbox" style="display: none" role="search">
  383. <h3 id="searchlabel">Quick search</h3>
  384. <div class="searchformwrapper">
  385. <form class="search" action="../search.html" method="get">
  386. <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
  387. <input type="submit" value="Go" />
  388. </form>
  389. </div>
  390. </div>
  391. <script>document.getElementById('searchbox').style.display = "block"</script>
  392. </div>
  393. </div>
  394. <div class="clearer"></div>
  395. </div>
  396. <div class="footer" role="contentinfo">
  397. &#169; Copyright 2015-2022, Adam Tauber, Noémi Ványi.
  398. Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 5.3.0.
  399. </div>
  400. <script src="../_static/version_warning_offset.js"></script>
  401. </body>
  402. </html>