<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: potterwhite</title>
    <description>The latest articles on DEV Community by potterwhite (@potterwhite).</description>
    <link>https://dev.to/potterwhite</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3847235%2Fc4187486-a2d4-4274-85b3-e3b338cebb76.jpeg</url>
      <title>DEV Community: potterwhite</title>
      <link>https://dev.to/potterwhite</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/potterwhite"/>
    <language>en</language>
    <item>
      <title>How I Automated Multi-Platform Docker Image Builds for Embedded SoCs (RK3588, RV1126, RK3568)</title>
      <dc:creator>potterwhite</dc:creator>
      <pubDate>Sat, 28 Mar 2026 08:09:04 +0000</pubDate>
      <link>https://dev.to/potterwhite/how-i-automated-multi-platform-docker-image-builds-for-embedded-socs-rk3588-rv1126-rk3568-4jbo</link>
      <guid>https://dev.to/potterwhite/how-i-automated-multi-platform-docker-image-builds-for-embedded-socs-rk3588-rv1126-rk3568-4jbo</guid>
      <description>&lt;h2&gt;
  
  
  How I Automated Multi-Platform Docker Image Builds for Embedded SoCs
&lt;/h2&gt;

&lt;p&gt;If you work with embedded Linux boards — RK3588, RV1126, RK3568, or similar ARM SoCs — you've probably hit these problems:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Five different Dockerfiles, diverging more with every Ubuntu release&lt;/li&gt;
&lt;li&gt;Port collisions when running containers for multiple platforms at the same time&lt;/li&gt;
&lt;li&gt;Ubuntu 24.04 broke your apt mirror setup, pip installs, and UID assignments all at once&lt;/li&gt;
&lt;li&gt;Image push to Harbor requires glue scripts nobody maintains&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I spent months dealing with this and eventually built a tool called &lt;a href="https://github.com/potterwhite/HarborPilot" rel="noopener noreferrer"&gt;HarborPilot&lt;/a&gt; to solve it. Here's what I learned.&lt;/p&gt;




&lt;h3&gt;
  
  
  The Core Problems
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Problem 1: Multiple Dockerfiles That Drift Apart
&lt;/h4&gt;

&lt;p&gt;When you start, one Dockerfile per platform seems fine. After 6 months, the RK3588 file has fixes that never made it to the RK3568 file, and Ubuntu 24.04 support requires changes that would break 20.04.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution&lt;/strong&gt;: One monolithic 5-stage Dockerfile. Platform-specific behaviour is injected via &lt;code&gt;ARG&lt;/code&gt;/&lt;code&gt;ENV&lt;/code&gt; at build time.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Stage 1: base OS (apt sources, packages, user creation)
Stage 2: dev tools (cmake, gdb, CUDA, OpenCV, Node.js)
Stage 3: SDK init (git, symlinks, helper scripts)
Stage 4: env config (proxy, profile variables)
Stage 5: workspace + entrypoint + smoke tests
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Problem 2: Port Collisions
&lt;/h4&gt;

&lt;p&gt;When you run Docker containers for RK3588 and RK3568 simultaneously, they'll both try to use port 2109 for SSH. You either document this manually (error-prone) or automate it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution&lt;/strong&gt;: &lt;code&gt;PORT_SLOT&lt;/code&gt; — a single integer that derives all port mappings:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;CLIENT_SSH_PORT &lt;span class="o"&gt;=&lt;/span&gt; 2109 + PORT_SLOT × 10
GDB_PORT &lt;span class="o"&gt;=&lt;/span&gt; 2345 + PORT_SLOT × 10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set &lt;code&gt;PORT_SLOT=0&lt;/code&gt; for RK3588, &lt;code&gt;PORT_SLOT=2&lt;/code&gt; for RK3568. Done. Zero conflicts, no documentation needed.&lt;/p&gt;

&lt;h4&gt;
  
  
  Problem 3: Supporting Three Ubuntu Versions Without Breaking Any
&lt;/h4&gt;

&lt;p&gt;Ubuntu 24.04 has three breaking changes compared to 20.04/22.04:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;DEB822 apt format&lt;/strong&gt; — &lt;code&gt;/etc/apt/sources.list&lt;/code&gt; is deprecated&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;UID 1000 pre-occupied&lt;/strong&gt; — the default &lt;code&gt;ubuntu&lt;/code&gt; user already has it&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PEP 668&lt;/strong&gt; — &lt;code&gt;pip install&lt;/code&gt; now refuses without &lt;code&gt;--break-system-packages&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;All three are handled with OS_VERSION conditionals in the relevant scripts.&lt;/p&gt;




&lt;h3&gt;
  
  
  The Three-Layer Config System
&lt;/h3&gt;

&lt;p&gt;The key insight: instead of platform-specific Dockerfiles, use a config inheritance system.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Layer 1: configs/defaults/*.env    ← global defaults (10 domain-scoped files)
Layer 2: configs/common.env        ← project version &amp;amp; constants
Layer 3: configs/platforms/*.env   ← per-platform overrides (≤20 lines)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A real platform file for RK3568 on Ubuntu 20.04:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# configs/platforms/rk3568-rk3568_ubuntu-20.04.env&lt;/span&gt;
&lt;span class="nv"&gt;PRODUCT_NAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"rk3568-rk3568_ubuntu-20-04"&lt;/span&gt;
&lt;span class="nv"&gt;CHIP_FAMILY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"rk3568"&lt;/span&gt;
&lt;span class="nv"&gt;OS_VERSION&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"20.04"&lt;/span&gt;
&lt;span class="nv"&gt;OS_VERSION_ID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"20-04"&lt;/span&gt;
&lt;span class="nv"&gt;PORT_SLOT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;2
&lt;span class="nv"&gt;HOST_VOLUME_DIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"/mnt/disk/volumes/rk3568"&lt;/span&gt;
&lt;span class="nv"&gt;HAS_PROXY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;true
&lt;/span&gt;&lt;span class="nv"&gt;HTTP_PROXY_IP&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"192.168.3.152"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's the complete file. Everything else inherits from Layer 1 defaults.&lt;/p&gt;

&lt;p&gt;Adding a new platform takes 15-20 lines. The wizard handles PORT_SLOT collision detection automatically.&lt;/p&gt;




&lt;h3&gt;
  
  
  One Command to Build, One to Run
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Build a platform image:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./harbor
&lt;span class="c"&gt;# Interactive: pick platform → build → tag → push to Harbor → verify manifest digest&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Start dev container on any Ubuntu host:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./ubuntu_only_entrance.sh start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Create a new platform non-interactively (CI-friendly):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./scripts/create_platform.sh &lt;span class="nt"&gt;--non-interactive&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--name&lt;/span&gt; rk3566-debian12 &lt;span class="nt"&gt;--os&lt;/span&gt; debian &lt;span class="nt"&gt;--os-version&lt;/span&gt; 12 &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--harbor-ip&lt;/span&gt; 192.168.3.68 &lt;span class="nt"&gt;--port-slot&lt;/span&gt; 6
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  What I Wish I'd Done Earlier
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;envsubst&lt;/code&gt; switch was overdue. I originally used &lt;code&gt;sed&lt;/code&gt; for template rendering in the Dockerfile stages — brittle, hard to debug. Replacing it with &lt;code&gt;envsubst&lt;/code&gt; (from &lt;code&gt;gettext-base&lt;/code&gt;) eliminated a whole class of escaping bugs.&lt;/p&gt;

&lt;p&gt;The modular &lt;code&gt;ubuntu_only_entrance.sh&lt;/code&gt; was also worth the refactor. The original was a 400-line monolith. Splitting it into 6 numbered modules made debugging 10x faster.&lt;/p&gt;




&lt;h3&gt;
  
  
  Links
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/potterwhite/HarborPilot" rel="noopener noreferrer"&gt;GitHub: potterwhite/HarborPilot&lt;/a&gt; (MIT)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/potterwhite/HarborPilot/tree/main/docs/en/1-for-ai" rel="noopener noreferrer"&gt;AI agent docs&lt;/a&gt; — codebase map and working rules for LLM coding agents&lt;/li&gt;
&lt;li&gt;Current supported platforms: RK3588/RK3588S, RV1126/RV1126bp, RK3568 on Ubuntu 20.04/22.04/24.04&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Feedback welcome — especially if you're using a different Rockchip or Allwinner SoC.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>embedded</category>
      <category>linux</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
