<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Tools | Cyrille Froehlich</title>
    <link>https://cyrille.hazeliris.com/category/tools/</link>
      <atom:link href="https://cyrille.hazeliris.com/category/tools/index.xml" rel="self" type="application/rss+xml" />
    <description>Tools</description>
    <generator>Wowchemy (https://wowchemy.com)</generator><language>en-us</language><lastBuildDate>Sat, 20 Mar 2021 10:45:24 +0000</lastBuildDate>
    <image>
      <url>https://cyrille.hazeliris.com/media/icon_hua2ec155b4296a9c9791d015323e16eb5_11927_512x512_fill_lanczos_center_2.png</url>
      <title>Tools</title>
      <link>https://cyrille.hazeliris.com/category/tools/</link>
    </image>
    
    <item>
      <title>Gitea ARM crossbuild (with GoModules)</title>
      <link>https://cyrille.hazeliris.com/post/2021/03/22/gitea-arm-crossbuild-with-go-modules/</link>
      <pubDate>Sat, 20 Mar 2021 10:45:24 +0000</pubDate>
      <guid>https://cyrille.hazeliris.com/post/2021/03/22/gitea-arm-crossbuild-with-go-modules/</guid>
      <description>&lt;p&gt;Upgrading to Gitea 1.13.4 didn&amp;rsquo;t go as planned and it failed to
compile the go-sqlite3 module &lt;a href=&#34;https://cyrille.hazeliris.com/post/2019/12/27/gitea-arm-crossbuild/&#34;&gt;with my previous setup&lt;/a&gt;. While crossbuilding, the CGO parameter is
automatically disabled (i.e. compiling is done with CGO_ENABLED=0) but
the go-sqlite3 module won&amp;rsquo;t build anymore if this option is not set
(probably require some optimisation in C and a pure Go implementation
won&amp;rsquo;t fit anymore). As a consequence of enabling this option, setting
the environment variable CC to the C cross-compiler explicitly is now
mandatory to ensure modules don&amp;rsquo;t target the wrong platform.&lt;/p&gt;
&lt;p&gt;A recent Go compiler will also have the Go Modules support enabled,
thus we can now simplify the build process with a more usual
checkout/make pattern.&lt;/p&gt;
&lt;p&gt;Dockerfile sample:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;FROM golang:latest

RUN dpkg --add-architecture armhf

RUN apt-get update
RUN apt-get install -y --no-install-recommends curl git build-essential crossbuild-essential-armhf

SHELL [ &amp;quot;/bin/bash&amp;quot;, &amp;quot;--login&amp;quot;, &amp;quot;-c&amp;quot; ]

ARG NVM_VERSION=&amp;quot;0.37.2&amp;quot;
RUN\
  ( export PROFILE=$HOME/.profile;\
    /usr/bin/curl -o- &amp;quot;https://raw.githubusercontent.com/creationix/nvm/v${NVM_VERSION}/install.sh&amp;quot; | /bin/bash )

ARG NODE_VERSION=&amp;quot;14.15.3&amp;quot;
RUN\
  nvm install &amp;quot;${NODE_VERSION}&amp;quot; &amp;amp;&amp;amp;\
  nvm use &amp;quot;v${NODE_VERSION}&amp;quot; &amp;amp;&amp;amp;\
  nvm alias default &amp;quot;v${NODE_VERSION}&amp;quot;

ARG YARN_VERSION=&amp;quot;1.22.10&amp;quot;
RUN\
  ( export PROFILE=$HOME/.profile;\
    /usr/bin/curl -o- -L &amp;quot;https:/yarnpkg.com/install.sh&amp;quot; | /bin/bash -s -- --version ${YARN_VERSION})

RUN\
  ( echo ;\
    echo &#39;source $HOME/.nvm/nvm.sh&#39;;\
    echo &#39;export PATH=/go/bin:/usr/local/go/bin:${PATH}&#39;; ) &amp;gt;&amp;gt; $HOME/.profile

WORKDIR /go

ENV GOARM=7
ENV GOARCH=arm
ENV GOOS=linux
ENV CGO_ENABLED=1
ENV CC=arm-linux-gnueabihf-gcc

ARG GITEA_VERSION=&amp;quot;v1.13.4&amp;quot;
RUN git clone --shallow-submodules --recurse-submodules --branch &amp;quot;${GITEA_VERSION}&amp;quot; --depth 1 https://github.com/go-gitea/gitea.git gitea

ENV TAGS=&amp;quot;bindata sqlite sqlite_unlock_notify&amp;quot;
RUN cd gitea &amp;amp;&amp;amp; make build
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Which we can run with (replace the host_output_dir with some folder on the host):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;docker build -t gitea-arm-builder .
docker run --rm -v [host_output_dir]:/output gitea-arm-builder cp /go/src/code.gitea.io/gitea/gitea /output/gitea-1.13.4-arm-linux
&lt;/code&gt;&lt;/pre&gt;
</description>
    </item>
    
    <item>
      <title>GPU Support With Docker Compose</title>
      <link>https://cyrille.hazeliris.com/post/2021/01/01/gpu-support-with-docker-compose/</link>
      <pubDate>Fri, 01 Jan 2021 03:52:55 +0000</pubDate>
      <guid>https://cyrille.hazeliris.com/post/2021/01/01/gpu-support-with-docker-compose/</guid>
      <description>&lt;p&gt;I use Docker quite a lot as it allows me to install, test, remove libraries or components without
any risk to break my main system. VM is another option but even if a linux install is now just
a few clicks in &lt;em&gt;virt-manager&lt;/em&gt; GUI, it takes time and I don&amp;rsquo;t need the full isolation provided
for this use-case. One thing that is quite difficult to setup in docker is the host GPU sharing.
Same issue with the VM, unless having 2 cards installed in the host, giving access to the guest
system either have an heavy performance impact, either require unlinking the card from the host
to bind it to the guest system (and the host is now headless in the meantime, so hope the switch
works without fail or you&amp;rsquo;ll be blind-fixing the issue in front of a dark screen).&lt;/p&gt;
&lt;p&gt;It is usually not a problem as most of the containers are running services, and my emacs can
easily be displayed on the host Xserver even when running inside a container. A Jupyter notebook
with Tensorflow and GPU support or an instance of Leela to review a Go game is another story&amp;hellip;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;nvidia-docker&lt;/em&gt;, &lt;em&gt;nvidia-docker2&lt;/em&gt; or &lt;em&gt;nvidia-container&lt;/em&gt; provided somewhat working solutions but
replacing the default docker runtime broke some of my other containers, some were ok with nvidia-docker
while others only with nvidia-container, and docker-compose was not usable with them at all. Of course,
switching between the different approach required to uninstall/install the correct set of packages
with matching versions. I had to rely to wrapper scripts to run the correct docker commands, which
is basically the job of docker-compose&amp;hellip; Somewhat working, but quite a messy solution.&lt;/p&gt;
&lt;p&gt;GPU support was discussed for a long time and it seems we&amp;rsquo;re near fixing all of this
&lt;em&gt;docker-compose&lt;/em&gt; 1.28.0-rc1 is announcing &amp;ldquo;Support for Nvidia GPUs via device requests&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;I&amp;rsquo;ll update this with a more detailled setup when 1.28 is released, as things may change.
The first part is the setup described &lt;a href=&#34;https://cyrille.hazeliris.com/post/2019/12/18/tensorflow-gpu-on-debian-buster/&#34;&gt;here&lt;/a&gt;,
moved to a container. The rest is a few lines to add to the compose yaml&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;My docker daemon config only move docker files out of /var and define a local registry:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;gt; cat /etc/docker/daemon.json
{
  &amp;quot;data-root&amp;quot;: &amp;quot;/home/docker&amp;quot;,
  &amp;quot;registry-mirrors&amp;quot;: [ &amp;quot;https://192.168.1.178:5000&amp;quot; ]
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;On the host the buster-backports nvidia-driver and nvidia-container-runtime are installed.
In the Dockerfile, install &lt;em&gt;nvidia-cuda-dev&lt;/em&gt; from buster-backports (thus we match the host driver version).&lt;/p&gt;
&lt;p&gt;Tensorflow require cuDNN, so install the matching &lt;em&gt;libcudnn8&lt;/em&gt; too. I have a copy of this in a local
debian repository: adding a source.list file to the image then apt-get install is faster than pushing
it from the docker context (these libraries are huge).&lt;/p&gt;
&lt;p&gt;In the docker-compose yaml, add:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;jupyter:
  ...
  deploy:
    resources:
      reservations:
        devices:
        - &#39;driver&#39;: &#39;nvidia&#39;
          &#39;count&#39;: 1
          &#39;capabilities&#39;: [&#39;gpu&#39;, &#39;utility&#39;]
  devices:
    - /dev/nvidia-uvm:/dev/nvidia-uvm
    - /dev/nvidia-uvm-tools:/dev/nvidia-uvm-tools
  ...
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The deploy parameters will act as the &amp;ndash;gpus option. The &lt;em&gt;nvidia-uvm&lt;/em&gt; module is not always loaded, running
modprobe beforehand (or force loading the module at boottime) may be required. Cuda will fail to initialize
if these &lt;a href=&#34;https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#runfile-verifications&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;devices are not present&lt;/a&gt;.
Once the devices are available on the host, &lt;em&gt;nvidia-container&lt;/em&gt; doesn&amp;rsquo;t map them into the container, so we
manually add them in the compose yaml.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Save last kernel used as grub&#39;s default</title>
      <link>https://cyrille.hazeliris.com/post/2020/12/25/set-grub-default-kernel/</link>
      <pubDate>Fri, 25 Dec 2020 03:01:15 +0000</pubDate>
      <guid>https://cyrille.hazeliris.com/post/2020/12/25/set-grub-default-kernel/</guid>
      <description>&lt;p&gt;The Nvidia driver currently available in buster-backport (450.80) seems to have issues with
the 5.9 kernel, resulting in an unavailable uvm module.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[ 8883.526038] nvidia_uvm: module uses symbols from proprietary module nvidia, inheriting taint.
[ 8883.526306] nvidia_uvm: Unknown symbol radix_tree_preloads (err -2)
[ 8883.526339] nvidia_uvm: Unknown symbol set_cpus_allowed_ptr (err -2)
[ 8883.526380] nvidia_uvm: Unknown symbol mmu_notifier_unregister (err -2)
[ 8883.526485] nvidia_uvm: Unknown symbol __mmu_notifier_register (err -2)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The next release (455.+) was said to fix this but has yet to reach the backports repository.
In the meantime, sticking to the 5.8 kernel is the easiest workaround. But I keep forgetting
to change the selection at boot time: power on the computer, untangle the mouse cord, look at
the screen and it&amp;rsquo;s already on the login. Speedy NVMe are great but better not blink .
Thus, I first thought of forcing grub to use the second entry as default and found these lines:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;gt; grep DEFAULT /etc/grub.d/*
...
if [ &amp;quot;x${GRUB_DEFAULT}&amp;quot; = &amp;quot;x&amp;quot; ] ; then GRUB_DEFAULT=0 ; fi
if [ &amp;quot;x${GRUB_DEFAULT}&amp;quot; = &amp;quot;xsaved&amp;quot; ] ; then GRUB_DEFAULT=&#39;${saved_entry}&#39; ; fi
...
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So instead of hardcoding a value, it turns out we can also load a previously saved entry, just
by setting the two following variables in &lt;em&gt;/etc/default/grub&lt;/em&gt; and running &lt;em&gt;update-grub&lt;/em&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The first line enable the default selection based on the saved value, the second set the default
value on the current selection (thus a manual change on the grub menu is all that&amp;rsquo;s required to update
the saved default). Looking in the &lt;em&gt;/boot/grub/grub.cfg&lt;/em&gt;, we can see the additional command &lt;em&gt;savedefault&lt;/em&gt;
at the beginning of each menuentry section.&lt;/p&gt;
&lt;p&gt;Probably not a recent feature, but it is neat to find out your odd use-case is already handled nicely
in the configuration files.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Tensorflow with GPU acceleration on Debian Buster</title>
      <link>https://cyrille.hazeliris.com/post/2019/12/18/tensorflow-gpu-on-debian-buster/</link>
      <pubDate>Wed, 18 Dec 2019 04:23:17 +0000</pubDate>
      <guid>https://cyrille.hazeliris.com/post/2019/12/18/tensorflow-gpu-on-debian-buster/</guid>
      <description>&lt;p&gt;A bit early for christmas presents, but I got myself a new machine (AMD Ryzen 3900X / 32G / RTX2060 Super,
by the way Ryzen CPUs are real monsters). Now, let&amp;rsquo;s try to make use of this.&lt;/p&gt;
&lt;h1 id=&#34;nvidia-drivers-and-tools&#34;&gt;Nvidia drivers and tools&lt;/h1&gt;
&lt;p&gt;Assuming the Debian backports are configured, we can choose to use a more up to date driver version.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;gt; cat /etc/apt/sources.list.d/backports.list
deb http://deb.debian.org/debian buster-backports main contrib non-free
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Install the &lt;em&gt;nvidia-driver&lt;/em&gt; (currently 450.80) and the &lt;em&gt;nvidia-cuda-toolkit&lt;/em&gt; (currently 11.1)&lt;/p&gt;
&lt;h1 id=&#34;cudnn-packages&#34;&gt;cuDNN packages&lt;/h1&gt;
&lt;p&gt;Tensorflow require the cuDNN components but they are not available in the usual repository so we have to
download the packages from &lt;a href=&#34;https://developer.nvidia.com/cudnn-download-survey&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Nvidia&lt;/a&gt;. cuDNN is not available
for the Debian distribution but Ubuntu ones are compatible enough. The packages we need are :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;libcudnn8_8.0.5.39-1+cuda11.1_amd64.deb&lt;/li&gt;
&lt;li&gt;libcudnn8-dev_8.0.5.39-1+cuda11.1_amd64.deb&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We&amp;rsquo;ll install them manually with a &lt;em&gt;dpkg -i&lt;/em&gt; as configuring the Nvidia repository will probably fetch
conflicting packages too.&lt;/p&gt;
&lt;h1 id=&#34;jupyter-notebook&#34;&gt;Jupyter notebook&lt;/h1&gt;
&lt;p&gt;Most of the documentation on the internet related to machine learning is using the python API,&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;gt; python3 -mvenv jupyter-env
&amp;gt; cd jupyter-env
&amp;gt; . ./bin/activate
&amp;gt; pip install -U pip setuptools wheel
&amp;gt; pip install jupyterlab tensorflow-gpu
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then check if the GPU is available to Tensorflow :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;gt; python3
&amp;gt;&amp;gt;&amp;gt; import tensorflow as tf
2020-12-26 11:19:12.763644: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.11.0
&amp;gt;&amp;gt;&amp;gt; tf.config.list_physical_devices()
2020-12-26 11:19:50.377149: I tensorflow/compiler/jit/xla_cpu_device.cc:41] Not creating XLA devices, tf_xla_enable_xla_devices not set
2020-12-26 11:19:50.382895: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcuda.so.1
2020-12-26 11:19:50.471910: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:941] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2020-12-26 11:19:50.472295: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 0 with properties:
pciBusID: 0000:0a:00.0 name: GeForce RTX 2060 SUPER computeCapability: 7.5
coreClock: 1.695GHz coreCount: 34 deviceMemorySize: 7.79GiB deviceMemoryBandwidth: 417.29GiB/s
2020-12-26 11:19:50.472310: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.11.0
2020-12-26 11:19:50.485168: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcublas.so.11
2020-12-26 11:19:50.485199: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcublasLt.so.11
2020-12-26 11:19:50.491058: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcufft.so.10
2020-12-26 11:19:50.494631: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcurand.so.10
2020-12-26 11:19:50.494706: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library &#39;libcusolver.so.10&#39;; dlerror: libcusolver.so.10: cannot open shared object file: No such file or directory
2020-12-26 11:19:50.498531: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcusparse.so.11
2020-12-26 11:19:50.498616: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudnn.so.8
2020-12-26 11:19:50.498625: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1757] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.
Skipping registering GPU devices...
[PhysicalDevice(name=&#39;/physical_device:CPU:0&#39;, device_type=&#39;CPU&#39;)]
&amp;gt;&amp;gt;&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And, we failed ! cuDNN was loaded, GPU is detected but Tensorflow wants an older version of libcusolver:
nvidia-cuda-toolkit installed the version 11 but we need the version 10 (no idea why as other libraries use cuda11,
which is the &lt;a href=&#34;https://www.tensorflow.org/install/source#gpu_support_2&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;correct version for tensorflow 2.4&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;&lt;del&gt;Not a big issue as a &lt;em&gt;libcusolver10&lt;/em&gt; package is available in the backports. Let&amp;rsquo;s install that then give it another try:&lt;/del&gt;&lt;/p&gt;
&lt;p&gt;Update: Now, libcusolver11 is no longer available in the buster-backports and tensorflow-gpu keep requesting the v10, it will
probably be fixed in next tensorflow or nvidia drivers release but in the meantime, it seems the &lt;a href=&#34;https://github.com/tensorflow/tensorflow/issues/43947&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;workaround&lt;/a&gt;
is to use the cuda11 library through a symlink:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cd /usr/lib/x86_64-linux-gnu
ln -sf libcusolver.so.11 libcusolver.so.10
ldconfig


...
2020-12-26 11:21:28.182053: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1862] Adding visible gpu devices: 0
[PhysicalDevice(name=&#39;/physical_device:CPU:0&#39;, device_type=&#39;CPU&#39;), PhysicalDevice(name=&#39;/physical_device:GPU:0&#39;, device_type=&#39;GPU&#39;)]
&amp;gt;&amp;gt;&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now launch a notebook with &lt;em&gt;jupyter lab&lt;/em&gt;, and run some tutorial code&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;...
2020-12-26 11:27:51.811618: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1406] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 6736 MB memory) -&amp;gt; physical GPU (device: 0, name: GeForce RTX 2060 SUPER, pci bus id: 0000:0a:00.0, compute capability: 7.5)
...
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Yep, seems good now.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Gitea ARM crossbuild</title>
      <link>https://cyrille.hazeliris.com/post/2019/12/27/gitea-arm-crossbuild/</link>
      <pubDate>Sun, 03 Nov 2019 12:45:24 +0000</pubDate>
      <guid>https://cyrille.hazeliris.com/post/2019/12/27/gitea-arm-crossbuild/</guid>
      <description>&lt;p&gt;Instead of building the &lt;a href=&#34;https://gitea.io/&#34; title=&#34;Self-hosting git server&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Gitea&lt;/a&gt; binary
on a Raspberry PI, we can speed up things a bit by crossbuilding from some other computer
with more punch. Recent version of &lt;em&gt;Gitea&lt;/em&gt; will need nodejs/npm to be available at build time,
so we&amp;rsquo;ll install this too.&lt;/p&gt;
&lt;p&gt;Dockerfile sample:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;FROM golang:latest

RUN dpkg --add-architecture armhf

RUN apt-get update
RUN apt-get install -y --no-install-recommends curl git build-essential crossbuild-essential-armhf

SHELL [ &amp;quot;/bin/bash&amp;quot;, &amp;quot;--login&amp;quot;, &amp;quot;-c&amp;quot; ]

ARG NVM_VERSION=&amp;quot;0.37.2&amp;quot;
RUN\
  ( export PROFILE=$HOME/.profile;\
    /usr/bin/curl -o- &amp;quot;https://raw.githubusercontent.com/creationix/nvm/v${NVM_VERSION}/install.sh&amp;quot; | /bin/bash )

ARG NODE_VERSION=&amp;quot;14.15.3&amp;quot;
RUN\
  nvm install &amp;quot;${NODE_VERSION}&amp;quot; &amp;amp;&amp;amp;\
  nvm use &amp;quot;v${NODE_VERSION}&amp;quot; &amp;amp;&amp;amp;\
  nvm alias default &amp;quot;v${NODE_VERSION}&amp;quot;

ARG YARN_VERSION=&amp;quot;1.22.10&amp;quot;
RUN\
  ( export PROFILE=$HOME/.profile;\
    /usr/bin/curl -o- -L &amp;quot;https:/yarnpkg.com/install.sh&amp;quot; | /bin/bash -s -- --version ${YARN_VERSION})

RUN\
  ( echo ;\
    echo &#39;source $HOME/.nvm/nvm.sh&#39;;\
    echo &#39;export PATH=/go/bin:/usr/local/go/bin:${PATH}&#39;; ) &amp;gt;&amp;gt; $HOME/.profile

WORKDIR /go

ENV GOARM=7
ENV GOARCH=arm
ENV GOOS=linux

ARG GITEA_VERSION=&amp;quot;v1.12.6&amp;quot;

RUN go get -d -u code.gitea.io/gitea

RUN cd /go/src/code.gitea.io/gitea &amp;amp;&amp;amp; git checkout ${GITEA_VERSION}

RUN cd /go/src/code.gitea.io/gitea &amp;amp;&amp;amp; TAGS=&amp;quot;bindata sqlite sqlite_unlock_notify&amp;quot; make build
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Which we can run with (replace the host_output_dir with some folder on the host):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;docker build -t gitea-arm-builder .
docker run --rm -v [host_output_dir]:/output gitea-arm-builder cp /go/src/code.gitea.io/gitea/gitea /output/gitea-1.12.5-arm-linux
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;My real setup is a little bit more involved as it uses Docker-Compose and multi-staged Dockerfiles
to share the nodejs install and optimize the build.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Gitea ARM7 build (Raspberry PI 2)</title>
      <link>https://cyrille.hazeliris.com/post/2019/11/03/build-gitea-rpi/</link>
      <pubDate>Sun, 03 Nov 2019 12:45:24 +0000</pubDate>
      <guid>https://cyrille.hazeliris.com/post/2019/11/03/build-gitea-rpi/</guid>
      <description>&lt;p&gt;I&amp;rsquo;m hosting my projects code on a &lt;a href=&#34;https://gitea.io/&#34; title=&#34;Self-hosting git server&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Gitea&lt;/a&gt;
instance running on a Raspberry PI. Thing is, the last Raspbian update broke the gitea
binary: probably some change in the kernel or libc. The official gitea build for ARM
kept crashing with a segmentation fault before even entering the main. Of course, latest
gitea builds were also broken. Only building Gitea from source eventually fixed the issue.&lt;/p&gt;
&lt;p&gt;I had to bump the swapfile size a bit as the build process burst to 1.2Go of memory
(RPI2 have 1Go, and default swap was set to 100Mo&amp;hellip; Murphy strikes again) :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ dphys-swapfile swapoff
# Edit the size in /etc/dphys-swapfile
# Then recreate the swap
$ dphys-swapfile setup
$ dphys-swapfile swapon
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Grab an up-to-date golang compiler:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ docker pull golang
$ docker run -it golang bash
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, inside the container, retrieve the source and build:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;% export GOOS=linux GOARCH=arm GOARM=7
% go get -d -u code.gitea.io/gitea
% cd $GOPATH/src/code.gitea.io/gitea
% git checkout v1.12.5
% TAGS=&amp;quot;bindata sqlite sqlite_unlock_notify&amp;quot; make build
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Retrieve the file:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ docker cp [your container name]:/go/src/code.gitea.io/gitea/gitea gitea-1.12.5-linux-arm-7
# My service file references the gitea symlimk, just point to the new file
$ ln -sf gitea-1.12.5-linux-arm-7 gitea
$ systemctl restart gitea
&lt;/code&gt;&lt;/pre&gt;
</description>
    </item>
    
  </channel>
</rss>
