Skip to content

fix(dockerfile): resolve UndefinedVar warning for LD_LIBRARY_PATH #55

@serabi

Description

@serabi

Problem

The Dockerfile contains an UndefinedVar lint warning:

UndefinedVar: Usage of undefined variable '$LD_LIBRARY_PATH'

This occurs in the ENV directive on line 8 of the Dockerfile:

ENV PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1 \
    FLASK_APP=web_server.py \
    PYTHONPATH="/app" \
    HF_HOME=/data/huggingface \
    LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib/python3.13/site-packages/nvidia/cublas/lib:/usr/local/lib/python3.13/site-packages/nvidia/cudnn/lib"

The issue is that $LD_LIBRARY_PATH is referenced in the ENV directive before it has been defined at that point in the Dockerfile. While Docker expands ENV variables at build time, the linter (Hadolint / Docker BuildKit) flags this as an undefined variable reference.

The build still succeeds, but the warning should be resolved.

Proposed Fix

Set LD_LIBRARY_PATH as a separate, self-contained ENV directive before the multi-line one that references it:

ENV LD_LIBRARY_PATH="/usr/local/lib/python3.13/site-packages/nvidia/cublas/lib:/usr/local/lib/python3.13/site-packages/nvidia/cudnn/lib"
ENV PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1 \
    FLASK_APP=web_server.py \
    PYTHONPATH="/app" \
    HF_HOME=/data/huggingface

Or alternatively, use the full explicit path in the multi-line env and set it separately.

Severity

Low — the build succeeds and the container runs correctly. The LD_LIBRARY_PATH value is still present in the final image. This is primarily a clean-build warning that should be resolved to keep the Dockerfile linter-clean.

Files

  • Dockerfile line 8

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions