<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[MOTSELL Engineering]]></title><description><![CDATA[Reproducible Linux and Docker deployment notes for developers running websites, APIs and bots. Published by MOTSELL, a self-managed VPS provider in Germany and ]]></description><link>https://motsell.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Wed, 18 Nov 2026 18:18:08 GMT</lastBuildDate><atom:link href="https://motsell.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Why a Next.js page can load while its CSS fails in a non-root Docker container]]></title><description><![CDATA[Reproduce a tar extraction and umask trap, fix permissions on public asset directories, and check file access under the serving container UID.]]></description><link>https://motsell.hashnode.dev/why-a-next-js-page-can-load-while-its-css-fails-in-a-non-root-docker-container</link><guid isPermaLink="true">https://motsell.hashnode.dev/why-a-next-js-page-can-load-while-its-css-fails-in-a-non-root-docker-container</guid><category><![CDATA[Docker]]></category><category><![CDATA[Next.js]]></category><category><![CDATA[Python]]></category><category><![CDATA[Devops]]></category><category><![CDATA[deployment]]></category><dc:creator><![CDATA[MOTSELL]]></dc:creator><pubDate>Wed, 18 Nov 2026 06:54:57 GMT</pubDate><content:encoded><![CDATA[<p>An HTML response can be healthy while every stylesheet fails. In a container that runs as a non-root user, one thing to check is whether that user can traverse the directories above the assets.</p>
<p>This post shows a small packaging failure you can reproduce without changing a running service. It applies to Next.js deployments, but the permission problem is ordinary POSIX filesystem behavior.</p>
<h2>The file is readable. Its parent is not.</h2>
<p>Imagine this extracted artifact:</p>
<pre><code class="language-text">web-assets/          0700  owned by the deploy user
  app.css            0644
</code></pre>
<p>The CSS file has read permission for other users. The directory grants access only to its owner. A container process running under a different UID cannot traverse that directory to open the file. The status shown to a browser depends on how the web server handles the failed read; do not diagnose permissions from a status code alone.</p>
<h2>A minimal Python reproduction</h2>
<p>The archive below records the directory as 0755 and the file as 0644. Extraction uses a private umask of 077 and Python's <code>data</code> filter.</p>
<p>The filter deliberately clears directory permission metadata. A newly created directory therefore follows the process umask. The readable archived file and the inaccessible directory can coexist.</p>
<p>Run this with Python 3.12 or newer in a disposable working environment. It creates a temporary directory and removes only that temporary fixture when it exits.</p>
<pre><code class="language-python">import io
import os
from pathlib import Path
import stat
import tarfile
import tempfile

with tempfile.TemporaryDirectory() as folder:
    root = Path(folder)
    archive = root / "assets.tar"
    with tarfile.open(archive, "w") as tar:
        directory = tarfile.TarInfo("web-assets")
        directory.type = tarfile.DIRTYPE
        directory.mode = 0o755
        tar.addfile(directory)
        css = b"body { color: #111 }\n"
        entry = tarfile.TarInfo("web-assets/app.css")
        entry.mode = 0o644
        entry.size = len(css)
        tar.addfile(entry, io.BytesIO(css))

    target = root / "candidate"
    target.mkdir()
    old_umask = os.umask(0o077)
    try:
        with tarfile.open(archive) as tar:
            tar.extractall(target, filter="data")
    finally:
        os.umask(old_umask)

    for path in [target / "web-assets", target / "web-assets/app.css"]:
        print(path.name, oct(stat.S_IMODE(path.stat().st_mode)))
</code></pre>
<p>In the local reproduction, Python 3.12.10 on macOS produced:</p>
<pre><code class="language-text">web-assets 0o700
app.css 0o644
</code></pre>
<p>That verifies the extracted modes. It is not a Linux container benchmark or a cross-UID runtime test.</p>
<h2>Fix the public artifact boundary</h2>
<p>Keep the archive safety filter. Give explicitly public asset directories the search permissions their serving process needs after extraction. Inside the temporary-directory block, after inspecting the modes and before the block exits, the narrowly scoped change is:</p>
<pre><code class="language-python">(target / "web-assets").chmod(0o755)
</code></pre>
<p>For a real release, inspect the complete parent path too. Apply the policy only to the staged public asset tree. Keep environment files, credentials and private backups outside it, with their private permissions. Normalising every file in an entire release directory would give private files a different policy.</p>
<h2>Check the identity that will serve the files</h2>
<p>After staging, try an actual read using the container UID, rather than relying only on what the deployment account can read. Here is a Node-based check for an example container named <code>web</code> and an example serving UID of 10001:</p>
<pre><code class="language-sh">docker exec --user 10001:10001 web node -e \
  "require('node:fs').readFileSync('/app/web-assets/app.css')"
</code></pre>
<p>Replace the container name, UID and path with those from your own runtime. This example needs Node in the image. On a separate canary, request the HTML and the CSS/JS URLs it references through the web server as well. Opening one file does not prove every retained asset is readable.</p>
<p>For Next.js standalone builds, also check that your packaging includes the public and <code>.next/static</code> directories at the locations expected by the standalone server. File presence and file accessibility are separate checks.</p>
<h2>Sources</h2>
<ul>
<li><a href="https://docs.python.org/3/library/tarfile.html#tarfile.data_filter">Python: extraction filters</a></li>
<li><a href="https://nextjs.org/docs/app/api-reference/config/next-config-js/output">Next.js: standalone output</a></li>
</ul>
<hr />
<p>Published by <strong>MOTSELL</strong>, which provides self-managed European Linux VPS for web apps, APIs and bots. <a href="https://motsell.com/en/vps-vds?utm_source=hashnode&amp;utm_medium=community&amp;utm_campaign=nextjs_permissions_20261118">Current VPS configurations and ordering</a>.</p>
<p>Prepared with AI assistance. The local permission reproduction was executed before publication; no customer infrastructure or private deployment details are included.</p>
]]></content:encoded></item></channel></rss>