FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y --no-install-recommends \
python3 \
python3-pip \
build-essential \
python3-dev \
libjpeg-dev \
zlib1g-dev \
libpng-dev \
libfreetype6-dev \
libxml2-dev \
libxslt1-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy requirements first for cache efficiency
COPY requirements.txt requirements.txt
RUN python3 -m pip install --no-cache-dir -U pip setuptools wheel && \
python3 -m pip install --no-cache-dir -r requirements.txt
# Copy the rest of the application
COPY . .
ENV PYTHONPATH=/app
# Smoke test on container start
CMD ["bash","-lc","python3 -c 'from scratch.linear_algebra import dot; print(dot([1,2,3],[4,5,6]))'"]
# Docker ignore file .git .git/* node_modules __pycache__ *.pyc *.pyo *.pyd *.swp *.swo *.ds_store venv env *.egg-info build dist *.egg *.log .DS_Store first-edition/code-python3/__pycache__ first-edition/__pycache__ scratch/__pycache__
# Docker ignore file .git .git/* node_modules __pycache__ *.pyc *.pyo *.pyd *.swp *.swo *.ds_store venv env *.egg-info build dist *.egg *.log .DS_Store first-edition/code-python3/__pycache__ first-edition/__pycache__ scratch/__pycache__
Concerns: The smoke test relies on the repository providing a importable package at /app/scratch/linear_algebra; if not, the test will fail during startup., The image installs many build and development packages (build-essential, lib*-dev, etc.) which increases image size; consider if all are necessary for runtime.
Smoke [FAIL]: python3 -c 'from scratch.linear_algebra import dot; assert dot([1,2,3],[4,5,6])==32; print("ok")
Output: sh: 1: Syntax error: Unterminated quoted string
Smoke [FAIL]: python3 -c 'from scratch.linear_algebra import dot; assert dot([0,1,0],[0,0,1])==0; print("ok2")
Output: sh: 1: Syntax error: Unterminated quoted stringFROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y --no-install-recommends \
python3 \
python3-pip \
build-essential \
python3-dev \
libjpeg-dev \
zlib1g-dev \
libpng-dev \
libfreetype6-dev \
libxml2-dev \
libxslt1-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy requirements first for cache efficiency
COPY requirements.txt requirements.txt
RUN python3 -m pip install --no-cache-dir -U pip setuptools wheel && \
python3 -m pip install --no-cache-dir -r requirements.txt
# Copy the rest of the application
COPY . .
ENV PYTHONPATH=/app
# Smoke test on container start
CMD ["bash","-lc","python3 -c \"from scratch.linear_algebra import dot; print(dot([1,2,3],[4,5,6]))\""]
Concerns: The build relies on a requirements.txt being present at repo root; if it is missing, the image build will fail., The CMD assumes the module path is scratch.linear_algebra; if the actual package path differs, the smoke test will fail.
Smoke [FAIL]: python3 -c \"from scratch.linear_algebra import dot; assert dot([1,2,3],[4,5,6])==32; print('ok')\
Output: sh: 1: Syntax error: "(" unexpectedfrom scratch.linear_algebra import dot print(dot([1,2,3], [4,5,6]))
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y --no-install-recommends \
python3 \
python3-pip \
build-essential \
python3-dev \
libjpeg-dev \
zlib1g-dev \
libpng-dev \
libfreetype6-dev \
libxml2-dev \
libxslt1-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy requirements first for cache efficiency
COPY requirements.txt requirements.txt
RUN python3 -m pip install --no-cache-dir -U pip setuptools wheel && \
python3 -m pip install --no-cache-dir -r requirements.txt
# Copy the rest of the application
COPY . .
ENV PYTHONPATH=/app
# Smoke test on container start
CMD ["bash","-lc","python3 -m pip install pytest && pytest -q smoke_test.py"]
Concerns: The Dockerfile assumes requirements.txt exists and will be used to install dependencies; if missing, the build will fail., The CMD installs pytest at container startup; if the build context omits pytest from requirements.txt, runtime tests may fail or introduce unnecessary network use., No non-root user is created; container runs as root by default which may be a security concern. Smoke [FAIL]: pytest -q smoke_test.py Output: sh: 1: pytest: not found
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y --no-install-recommends \
python3 \
python3-pip \
build-essential \
python3-dev \
libjpeg-dev \
zlib1g-dev \
libpng-dev \
libfreetype6-dev \
libxml2-dev \
libxslt1-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy requirements first for cache efficiency
COPY requirements.txt requirements.txt
RUN python3 -m pip install --no-cache-dir -U pip setuptools wheel && \
python3 -m pip install --no-cache-dir -r requirements.txt
# Copy the rest of the application
COPY . .
ENV PYTHONPATH=/app
# Smoke test on container start
CMD ["python3", "smoke_test.py"]
Smoke [PASS]: python3 /app/smoke_test.py