FROM python:3.14-alpine3.23 # Install system dependencies required for building Python packages RUN apk add --no-cache build-base libffi-dev openssl-dev ca-certificates ENV PYTHONUNBUFFERED=1 WORKDIR /app # Copy project metadata and source code COPY pyproject.toml . COPY uv.lock . COPY . . # Build the distribution using uv RUN pip install --no-cache-dir uv RUN uv build # Install the built wheel into the image RUN pip install --no-cache-dir dist/*.whl # Default command for a quick sanity check CMD ["flask", "--version"]
Concerns: The base image tag python:3.14-alpine3.23 may not exist in Docker Hub; if unavailable, the build will fail., Smoke tests assume Flask is installed as a runtime dependency of the built wheel; if the package does not include Flask, tests may fail.
Smoke [FAIL]: python -c "import flask; from flask import Flask; app = Flask('smoke'); assert isinstance(app, Flask); print('ok')
Output: sh: syntax error: unterminated quoted string
Smoke [FAIL]: python -c "import flask; from flask import Flask; app = Flask('smoke'); with app.test_client() as c: r = c.get('/'); assert r.status_code in (200,404); print('ok')
Output: sh: syntax error: unterminated quoted stringImage python:3.14-alpine3.23 exists on Docker Hub.
FROM python:3.14-bullseye
# Install system dependencies required for building Python packages
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
libffi-dev \
libssl-dev \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
ENV PYTHONUNBUFFERED=1
WORKDIR /app
# Copy project metadata and source code
COPY pyproject.toml .
COPY uv.lock .
COPY . .
# Build the distribution using uv
RUN pip install --no-cache-dir uv
RUN uv build
# Install the built wheel into the image
RUN pip install --no-cache-dir dist/*.whl
# Default command for a quick sanity check
CMD ["flask", "--version"]
FROM python:3.14-alpine3.23 # Install system dependencies required for building Python packages RUN apk add --no-cache build-base libffi-dev openssl-dev ca-certificates ENV PYTHONUNBUFFERED=1 WORKDIR /app # Copy project metadata and source code COPY pyproject.toml . COPY uv.lock . COPY . . # Build the distribution using uv RUN pip install --no-cache-dir uv RUN uv build # Install the built wheel into the image RUN pip install --no-cache-dir dist/*.whl # Default command: show Flask version to verify installation CMD ["flask", "--version"]
Concerns: FROM image tag python:3.14-alpine3.23 may not exist or be intentionally fictional; ensure real tag exists or adjust to a supported Python/Alpine base., CMD uses 'flask --version' as the default command. If the built wheel does not include Flask as a runtime dependency or the project doesn't install a Flask CLI, this may not reflect a successful build. Consider a functional smoke test or a small Python snippet to verify runtime packaging instead.
Smoke [FAIL]: python -c "import flask; v = getattr(flask, '__version__', None); assert isinstance(v, str) and len(v) > 0; print('ok', v)
Output: sh: syntax error: unterminated quoted string
Smoke [FAIL]: python -c "from flask import Flask; app=Flask(__name__); client=app.test_client(); resp=client.get('/'); assert resp.status_code == 404; print('ok')
Output: sh: syntax error: unterminated quoted string# Build stage: install build tools and build the distribution FROM python:3.14-alpine3.23 as builder RUN apk add --no-cache build-base libffi-dev openssl-dev ca-certificates WORKDIR /build # Copy build metadata and source COPY pyproject.toml uv.lock ./ COPY . ./ # Install uv and build wheel(s) for the project RUN pip install --no-cache-dir uv RUN uv build # Runtime stage: minimal image with the built wheel installed FROM python:3.14-alpine3.23 RUN apk add --no-cache libffi-dev openssl-dev ca-certificates WORKDIR /app # Copy built artifacts from builder COPY --from=builder /build/dist /app/dist # Install the project wheel(s) RUN pip install --no-cache-dir /app/dist/*.whl # Default command to verify the build CMD ["flask", "--version"]
Concerns: FROM python:3.14-alpine3.23 likely references a non-existent base image tag (Python 3.14); this would fail to build, The build/test flow relies on 'uv' to produce a wheel; if 'uv' isn't compatible or 'dist' is empty, the runtime install will fail, Default CMD uses 'flask --version'; this assumes Flask CLI is installed by the built wheel, which may not be guaranteed; the image could be essentially empty, Potential missing files or misalignment: COPY order and path of /build/dist; if uv build produces multiple wheels or different layout, the runtime COPY might not find them, No explicit healthcheck or smoke-test script; smoke tests rely on outputs that may not be present in a minimal runtime
FROM python:3.14-alpine3.23 # Install system dependencies required for building Python packages RUN apk add --no-cache build-base libffi-dev openssl-dev ca-certificates ENV PYTHONUNBUFFERED=1 WORKDIR /app # Copy project metadata and source code COPY pyproject.toml uv.lock . COPY . . # Build the distribution using uv RUN pip install --no-cache-dir uv RUN uv build # Install the built wheel into the image RUN pip install --no-cache-dir dist/*.whl # Default command for a quick sanity check CMD ["flask", "--version"]
Concerns: FROM image tag python:3.14-alpine3.23 may not exist in the official registry; base image validity is uncertain, CMD uses a trivial --version check (flask --version) which is not a real runtime health check; consider wiring a basic health check or an app-run smoke test
Smoke [FAIL]: python -c \"import flask; v=getattr(flask, '__version__', ''); assert isinstance(v, str) and len(v) > 0; print(v)\
Output: sh: syntax error: unexpected "("# Build stage: install build tools and build the distribution
FROM python:3.14-alpine3.23 as builder
RUN apk add --no-cache build-base libffi-dev openssl-dev ca-certificates
WORKDIR /build
# Copy build metadata and source
COPY pyproject.toml uv.lock ./
COPY . ./
# Install uv and build wheel(s) for the project
RUN pip install --no-cache-dir uv
RUN uv build
# Runtime stage: minimal image with the built wheel installed
FROM python:3.14-alpine3.23
RUN apk add --no-cache libffi-dev openssl-dev ca-certificates
WORKDIR /app
# Copy built artifacts from builder
COPY --from=builder /build/dist /app/dist
# Install the project wheel(s)
RUN pip install --no-cache-dir /app/dist/*.whl
# Default command: run a small smoke test program to verify runtime availability
ENV PYTHONUNBUFFERED=1
CMD ["python", "-c", "import flask; from flask import Flask; app = Flask(__name__); with app.test_client() as c: r = c.get('/'); print('smoke ok')"]
Concerns: Base image tag uses python:3.14-alpine3.23 which may not exist or may be deprecated; verify tag availability and security updates., Smoke test relies on Flask being available at runtime; ensure the built wheel lists Flask as a dependency or adapt test to reflect the actual project runtime., If the build step uv build or the wheel output path /build/dist/*.whl differs for the project, the runtime image may fail to install any wheels.
Smoke [FAIL]: python -c \"import flask; from flask import Flask; app = Flask(__name__); with app.test_client() as c: r = c.get('/'); assert r is not None and r.status_code in (200,404); print('smoke ok')\
Output: sh: syntax error: unexpected "("FROM python:3.14-alpine3.23 # Install build utilities for compiling Python dependencies RUN apk add --no-cache build-base libffi-dev openssl-dev ca-certificates ENV PYTHONUNBUFFERED=1 WORKDIR /app # Copy the entire project into the image COPY . . # Upgrade packaging tools and install the project in editable mode RUN pip install --no-cache-dir --upgrade pip setuptools wheel RUN pip install --no-cache-dir -e . # Simple smoke command to verify the installed package CMD ["flask", "--version"]
Concerns: FROM image tag python:3.14-alpine3.23 may not exist or be available in the official registry, which could cause builds to fail., CMD ["flask", "--version"] is a minimal smoke test (version output) and does not exercise runtime functionality of the installed package., COPY . . copies the entire project; consider restricting to necessary files to reduce image size and build context.
Smoke [FAIL]: python -c "from flask import Flask; app=Flask('smoke'); client=app.test_client(); resp=client.get('/'); assert resp.status_code==404; print('ok')
Output: sh: syntax error: unterminated quoted string
Smoke [FAIL]: python -c "from flask import json; data=json.dumps({'a':1}); assert isinstance(data, str); print('ok')
Output: sh: syntax error: unterminated quoted string
Smoke [FAIL]: python -c "from flask import Flask; app=Flask('smoke3'); assert app.name=='smoke3'; print('ok')
Output: sh: syntax error: unterminated quoted string# Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] # Distribution / packaging dist/ build/ *.egg-info/ # Pytest / tox / caches .pytest_cache/ .tox/ site-packages/ # Virtual environments venv/ env/ # OS / IDE files .DS_Store .idea/ .vscode/ .env uv.lock # Documentation build output docs/_build/ # Temporary files *.tmp *.log # Flask test artifacts tests/__pycache__/
Concerns: FROM python:3.14-alpine3.23 uses a non-existent Python version tag (3.14) which is likely invalid on Docker Hub., The base image tag alpine3.23 may not exist or be available, causing image build failures., CMD ["flask", "--version"] is a non-functional smoke check (version output) and may be brittle; it also requires Flask to be installed, COPY . . copies the entire repository into the image, which can unintentionally include sensitive files or large build contexts, No explicit healthcheck, port exposure, or service startup is defined to verify runtime behavior beyond installation, Relying on pip install -e . assumes a correctly configured setup.py/pyproject.toml; if the project is not set up for editable installs, the build could fail
Image python:3.12-alpine3 NOT found on Docker Hub.
Image python:3.11-alpine3.18 exists on Docker Hub.
FROM python:3.11-alpine3.18 as builder RUN apk add --no-cache build-base libffi-dev openssl-dev ca-certificates WORKDIR /build COPY pyproject.toml uv.lock . COPY . . RUN pip install --no-cache-dir uv RUN uv build FROM python:3.11-alpine3.18 RUN apk add --no-cache libffi-dev openssl-dev ca-certificates WORKDIR /app COPY --from=builder /build/dist /app/dist RUN pip install --no-cache-dir /app/dist/*.whl CMD ["flask", " --version"]
- Exact error message and exit code - Error: ERROR: failed to build: failed to solve: failed to compute cache key: failed to calculate checksum of ref 4ff19f4d-ebba-4433-930a-fce245b8c5fa::iezs2e6cbjethi3dr338a030g: "/uv.lock": not found - Exit code: not shown in the log - Failing command/step - [builder 4/7] COPY pyproject.toml uv.lock . - Missing packages or files mentioned - uv.lock not found in the build context - Additionally, CopyIgnoredFile indicates uv.lock is excluded by .dockerignore (line 4) - Version mismatch info - Base image used: python:3.11-alpine3.18 (with digest sha256:4799cdc47a1b7ecc2829e71e74d06ce7c0af54dec4f5ff139f869cc2c4283b1d) - No explicit version mismatch is reported; the log shows a casing warning (FromAsCasing) and a file-copy mismatch instead of a version mismatch. The casing warning is not treated as the root cause. - Quick context and fix note - The COPY step tries to bring in uv.lock, but uv.lock is either missing in the build context or excluded by .dockerignore. To fix: ensure uv.lock is present and not excluded, or remove/adjust the COPY uv.lock clause (or update .dockerignore accordingly).
FROM python:3.11-alpine3.18 as builder RUN apk add --no-cache build-base libffi-dev openssl-dev ca-certificates WORKDIR /build COPY pyproject.toml . COPY . . RUN pip install --no-cache-dir uv RUN uv build FROM python:3.11-alpine3.18 RUN apk add --no-cache libffi-dev openssl-dev ca-certificates WORKDIR /app COPY --from=builder /build/dist /app/dist RUN pip install --no-cache-dir /app/dist/*.whl CMD ["flask", "--version"]
Smoke [FAIL]: python -c 'import flask; v=getattr(flask, "__version__", None); assert isinstance(v, str) and len(v)>0; print(v)
Output: sh: syntax error: unterminated quoted string
Smoke [FAIL]: python -c 'import flask; app=flask.Flask("__main__"); with app.test_client() as c: r=c.get("/"); assert r.status_code==404; print("ok")
Output: sh: syntax error: unterminated quoted stringFROM python:3.12-alpine3.19 AS builder # Install build dependencies required to build Python packages RUN apk add --no-cache build-base libffi-dev openssl-dev ca-certificates WORKDIR /src # Copy project metadata first to leverage Docker cache COPY pyproject.toml uv.lock tox.ini . # Copy the rest of the source COPY . . # Ensure pip is available and install UV, the packaging tool used by the project RUN python -m ensurepip RUN pip install --no-cache-dir uv # Build the project (creates wheels in dist/) RUN uv build FROM python:3.12-alpine3.19 # Install runtime dependencies (kept consistent with build image) RUN apk add --no-cache libffi-dev openssl-dev ca-certificates build-base WORKDIR /app # Copy built artifacts from the builder stage COPY --from=builder /src/dist /dist # Install the built package (wheel) into the final image RUN pip install --no-cache-dir /dist/*.whl # Expose Flask default port for convenience EXPOSE 5000 # Default command: show Flask version to verify the image is functional CMD ["flask", "--version"]
# Docker context ignore .git .gitignore __pycache__/ *.pyc *.pyo *.pyd .build/ .dist/ dist/ build/ *.egg-info/ .eggs .eggs-info .cache .vscode/ .pytest_cache/ /node_modules/ /docs/_build/ /tests/ examples/javascript/ # Optional: ignoreUv lock to ensure not copying during local dev uv.lock
- Status: VerifyBuild status: build_failed - Concerns: - The final image CMD runs 'flask --version' (not a real runtime smoke test); should exercise actual functionality (e.g., a simple HTTP request). - Build relies on uv and uv.lock/pyproject.toml; ensure these files exist and uv is compatible with Python 3.12 on Alpine. - Build error (selected logs): - [builder 4/8] COPY pyproject.toml uv.lock tox.ini .: - ERROR: failed to calculate checksum of ref 4ff19f4d-ebba-4433-930a-fce245b8c5fa::maiiulz0g0nt586pvastji9nb: "/uv.lock": not found - Warning: CopyIgnoredFile: Attempting to Copy file "uv.lock" that is excluded by .dockerignore (line 8) - Dockerfile:8 shows COPY pyproject.toml uv.lock tox.ini . - Base image: FROM docker.io/library/python:3.12-alpine3.19@sha256:... - Build canceled due to the above error - Root cause (actionable): uv.lock (and/or its path) is missing or excluded by .dockerignore, causing the COPY step to fail. - Affected files mentioned: - pyproject.toml - uv.lock - tox.ini - Recommended fixes (actionable): - Ensure uv.lock exists at repo root and is intended to be copied; verify its path. - Check .dockerignore and remove or adjust the rule excluding uv.lock (line 8) if it should be included. - If uv.lock is not needed in the build, remove uv.lock from the COPY line in the Dockerfile (or adjust accordingly). - Confirm uv tool compatibility with Python 3.12 on Alpine and that uv.lock/pyproject.toml are compatible. - For tests, replace final CMD smoke test with an actual runtime check (e.g., a minimal in-container request) rather than flask --version.
FROM python:3.12-alpine3.19 AS builder # Install build dependencies required to build Python packages RUN apk add --no-cache build-base libffi-dev openssl-dev ca-certificates WORKDIR /src # Copy project metadata first to leverage Docker cache COPY pyproject.toml uv.lock tox.ini . # Copy the rest of the source COPY . . # Ensure pip is available and install UV, the packaging tool used by the project RUN python -m ensurepip RUN pip install --no-cache-dir uv # Build the project (creates wheels in dist/) RUN uv build FROM python:3.12-alpine3.19 # Install runtime dependencies (kept consistent with build image) RUN apk add --no-cache libffi openssl ca-certificates WORKDIR /app # Copy built artifacts from the builder stage COPY --from=builder /src/dist /dist # Install the built package (wheel) into the final image RUN pip install --no-cache-dir /dist/*.whl # Expose Flask default port for convenience EXPOSE 5000 # Default command: show Flask version to verify the image is functional CMD ["flask", "--version"]
FROM python:3.12-alpine3.19 AS builder # Install build dependencies required to build Python packages RUN apk add --no-cache build-base libffi-dev openssl-dev ca-certificates WORKDIR /src # Copy project metadata first to leverage Docker cache COPY pyproject.toml tox.ini . # Copy the rest of the source COPY . . # Ensure pip is available and install UV, the packaging tool used by the project RUN python -m ensurepip RUN pip install --no-cache-dir uv # Build the project (creates wheels in dist/) RUN uv build FROM python:3.12-alpine3.19 # Install runtime dependencies (kept consistent with build image) RUN apk add --no-cache libffi openssl ca-certificates WORKDIR /app # Copy built artifacts from the builder stage COPY --from=builder /src/dist /dist # Install the built package (wheel) into the final image RUN pip install --no-cache-dir /dist/*.whl # Expose Flask default port for convenience EXPOSE 5000 # Default command: show Flask version to verify the image is functional CMD ["flask", "--version"]
Summary:
- VerifyBuild status: build_failed
- Concerns: The final CMD only runs 'flask --version' and does not start or health-check the app; add a health endpoint or proper entrypoint to smoke-test the running application.
- Build error details:
- Build driver: docker
- Dockerfile steps of interest:
- [builder 4/8] COPY pyproject.toml tox.ini .
- ERROR: failed to calculate checksum of ref 4ff19f4d-ebba-4433-930a-fce245b8c5fa::fj1u7gf2ectctbvzq7yuhwozl: "/tox.ini": not found
- Base image: FROM docker.io/library/python:3.12-alpine3.19@sha256:017a82f185bf6f10e62156f3e89b7e694d56d613b5a3f4dbf1d28f1014a972ed
- Other steps observed:
- [internal] load metadata for docker.io/library/python:3.12-alpine3.19
- [builder 2/8] RUN apk add --no-cache build-base libffi-dev openssl-dev ca-certificates
- [builder 3/8] WORKDIR /src
- Dockerfile excerpt:
- 6 | WORKDIR /src
- 7 | # Copy project metadata first to leverage Docker cache
- 8 | >>> COPY pyproject.toml tox.ini .
- 9 |
- Error cause: unable to compute cache key due to missing /tox.ini in the build context
- Context notes: load .dockerignore and load build context completed; then COPY failed
- Actionable next steps:
- Ensure tox.ini exists in the build context and is not excluded by .dockerignore.
- Verify paths in Dockerfile COPY instructions match actual file locations.
- If tox.ini is intentionally omitted, adjust Dockerfile to COPY only existing files or add a conditional/alternative step.
- Re-run build after correcting files to allow cacheKey computation to succeed.FROM python:3.12-alpine3.19 AS builder # Install build dependencies required to build Python packages RUN apk add --no-cache build-base libffi-dev openssl-dev ca-certificates WORKDIR /src # Copy project metadata first to leverage Docker cache COPY pyproject.toml . # Copy the rest of the source COPY . . # Ensure pip is available and install UV, the packaging tool used by the project RUN python -m ensurepip RUN pip install --no-cache-dir uv # Build the project (creates wheels in dist/) RUN uv build FROM python:3.12-alpine3.19 # Install runtime dependencies (kept consistent with build image) RUN apk add --no-cache libffi openssl ca-certificates WORKDIR /app # Copy built artifacts from the builder stage COPY --from=builder /src/dist /dist # Install the built package (wheel) into the final image RUN pip install --no-cache-dir /dist/*.whl # Expose Flask default port for convenience EXPOSE 5000 # Default command: show Flask version to verify the image is functional CMD ["flask", "--version"]
Concerns: CMD only runs 'flask --version' and does not start the application; consider adding a startup/healthcheck to validate runtime., No explicit HEALTHCHECK in the image; smoke tests rely on presence of Flask CLI and wheel, which may not prove the actual app functionality.
Smoke [FAIL]: python -c \"import flask; v=getattr(flask,'__version__',''); assert isinstance(v, str) and len(v)>0; print('ok')\
Output: sh: syntax error: unexpected "("
Smoke [FAIL]: python -c \"from flask import Flask; app=Flask('smoketest'); app.add_url_rule('/', 'index', lambda: 'ok'); c=app.test_client(); r=c.get('/'); assert r.status_code==200 and r.data==b'ok'; print('ok')\
Output: sh: syntax error: unexpected "("FROM python:3.12-alpine3.19 AS builder # Install build dependencies required to build Python packages RUN apk add --no-cache build-base libffi-dev openssl-dev ca-certificates WORKDIR /src # Copy project metadata first to leverage Docker cache COPY pyproject.toml . # Copy the rest of the source COPY . . # Ensure pip is available and install UV, the packaging tool used by the project RUN python -m ensurepip RUN pip install --no-cache-dir uv # Build the project (creates wheels in dist/) RUN uv build FROM python:3.12-alpine3.19 # Install runtime dependencies (kept consistent with build image) RUN apk add --no-cache libffi openssl ca-certificates WORKDIR /app # Copy built artifacts from the builder stage COPY --from=builder /src/dist /dist # Install the built package (wheel) into the final image RUN pip install --no-cache-dir /dist/*.whl # Expose Flask default port for convenience EXPOSE 5000 # Default command: show Flask version to verify the image is functional CMD ["flask", "--version"] # Basic healthcheck to verify runtime Flask import and version HEALTHCHECK --interval=30s --timeout=5s --start-period=5s CMD ["python", "-c", "import flask; v=getattr(flask, '__version__', None); assert isinstance(v, str) and len(v)>0; print(v)"]
Concerns: Healthcheck relies on Flask being present in the final image; if the installed wheel does not pull Flask as a dependency, the healthcheck will fail even if the package itself works., CMD only prints Flask version and does not start a runnable app; consider providing a startup command or test that exercises a running server or CLI. Smoke [FAIL]: python -c 'from flask import __version__ as v; assert isinstance(v, str) and len(v) > 0; print(v) Output: sh: syntax error: unterminated quoted string
FROM python:3.12-alpine3.19 AS builder # Install build dependencies required to build Python packages RUN apk add --no-cache build-base libffi-dev openssl-dev ca-certificates WORKDIR /src # Copy project metadata first to leverage Docker cache COPY pyproject.toml . COPY uv.lock . # Copy the rest of the source COPY . . # Ensure pip is available and install UV, the packaging tool used by the project RUN python -m ensurepip RUN pip install --no-cache-dir uv # Build the project (creates wheels in dist/) RUN uv build FROM python:3.12-alpine3.19 # Install runtime dependencies (kept consistent with build image) RUN apk add --no-cache libffi openssl ca-certificates WORKDIR /app # Copy built artifacts from the builder stage COPY --from=builder /src/dist /dist # Install the built package (wheel) into the final image RUN pip install --no-cache-dir /dist/*.whl # Expose Flask default port for convenience EXPOSE 5000 # Default command: show Flask version to verify the image is functional CMD ["flask", "--version"] # Healthcheck to verify runtime Flask import and version HEALTHCHECK --interval=30s --timeout=5s --start-period=5s CMD ["python", "-c", "import flask; v=getattr(flask, '__version__', None); assert isinstance(v, str) and len(v)>0; print(v)"]
- VerifyBuild status: build_failed
- Concerns: Final CMD only prints Flask version and does not start a server; smoke tests assume Flask is present and runs; may fail if Flask not included in the built wheel or packaging changes
- Build error summary:
- Base image: docker.io/library/python:3.12-alpine3.19 @ sha256:017a82f185bf6f10e62156f3e89b7e694d56d613b5a3f4dbf1d28f1014a972ed
- Dockerfile steps:
- [builder 5/9] FROM python:3.12-alpine3.19@sha256:...
- [builder 6/9] WORKDIR /src (CACHED)
- [builder 7/9] COPY pyproject.toml . (CACHED)
- [builder 8/9] COPY uv.lock . -> ERROR: not found
- Warning: CopyIgnoredFile: Attempting to Copy file "uv.lock" that is excluded by .dockerignore (line 9)
- Subsequent step [builder 2/9] RUN apk add --no-cache build-base libffi-dev openssl-dev ca-certificates
- Result: CANCELED due to earlier error
- Dockerfile excerpt:
- 7 | COPY pyproject.toml .
- 9 | COPY uv.lock .
- Error message: "ERROR: failed to build: failed to solve: failed to compute cache key: failed to calculate checksum of ref ... \"/uv.lock\": not found"
- Key actionable items:
- Ensure uv.lock is present in the build context and not excluded by .dockerignore
- If uv.lock is not needed for the build, remove the COPY uv.lock . line or adjust the Dockerfile/.dockerignore
- Re-run the docker build after fixing the context/ignore rules
- Additional note: The build relies on Flask being present; verify Flask is included as a dependency if the smoke tests depend on a running app.FROM python:3.12-alpine3.19 AS builder # Install build dependencies required to build Python packages RUN apk add --no-cache build-base libffi-dev openssl-dev ca-certificates WORKDIR /src # Copy project metadata first to leverage Docker cache COPY pyproject.toml . # Copy the rest of the source COPY . . # Ensure pip is available and install UV, the packaging tool used by the project RUN python -m ensurepip RUN pip install --no-cache-dir uv # Build the project (creates wheels in dist/) RUN uv build FROM python:3.12-alpine3.19 # Install runtime dependencies (kept consistent with build image) RUN apk add --no-cache libffi openssl ca-certificates WORKDIR /app # Copy built artifacts from the builder stage COPY --from=builder /src/dist /dist # Install the built package (wheel) into the final image RUN pip install --no-cache-dir /dist/*.whl # Expose Flask default port for convenience EXPOSE 5000 # Default command: show Flask version to verify the image is functional CMD ["flask", "--version"]
Concerns: The smoke test assumes Flask is a runtime dependency of the built wheel; if the project does not require Flask, importing flask may fail and the test would be flaky., The default CMD uses 'flask --version' which is a version check rather than a health check; a real health endpoint test would be better if available.
Smoke [FAIL]: python -c 'import flask; ver = getattr(flask, "__version__", None); assert ver; print(ver); print("SMOKE_OK")
Output: sh: syntax error: unterminated quoted stringFROM python:3.12-alpine3.19 AS builder # Install build dependencies required to build Python packages RUN apk add --no-cache build-base libffi-dev openssl-dev ca-certificates WORKDIR /src # Copy project metadata first to leverage Docker cache COPY pyproject.toml ./ # Copy the rest of the source COPY . ./ # Ensure pip is available and install UV, the packaging tool used by the project RUN python -m ensurepip RUN pip install --no-cache-dir uv # Build the project (creates wheels in dist/) RUN uv build FROM python:3.12-alpine3.19 # Install runtime dependencies (kept consistent with build image) RUN apk add --no-cache libffi openssl ca-certificates WORKDIR /app # Copy built artifacts from the builder stage COPY --from=builder /src/dist /dist # Install the built package (wheel) into the final image RUN pip install --no-cache-dir /dist/*.whl # Expose Flask default port for convenience EXPOSE 5000 # Default command: print Flask version to verify runtime CMD ["python", "-m", "flask", "--version"]
Concerns: The final image's default CMD only prints Flask version rather than starting a service; consider starting a testable endpoint or document how to run the app in CI., Smoke tests assume Flask is available as a runtime dependency; if the built wheel doesn't pull Flask, tests may fail. Consider adding a lightweight health check or a CLI invocation if available.
Smoke [FAIL]: python -c "import flask; v=flask.__version__; assert isinstance(v, str) and len(v)>0; print('ok-flask-'+v)
Output: sh: syntax error: unterminated quoted string
Smoke [FAIL]: python -c "from flask import Flask; app=Flask(__name__); c=app.test_client(); rv=c.get('/'); assert rv.status_code in (200,404); print('ok')
Output: sh: syntax error: unterminated quoted stringFROM python:3.12-alpine3.19 AS builder # Install build dependencies required to build Python packages RUN apk add --no-cache build-base libffi-dev openssl-dev ca-certificates WORKDIR /src # Copy project metadata first to leverage Docker cache COPY pyproject.toml . # Copy the rest of the source COPY . . # Install build tooling to build a wheel from source RUN pip install --no-cache-dir build # Build the project into dist/ (wheel) RUN python -m build -o dist FROM python:3.12-alpine3.19 # Install runtime dependencies RUN apk add --no-cache libffi openssl ca-certificates WORKDIR /app # Copy built artifacts from the builder stage COPY --from=builder /src/dist /dist # Install the built wheel into the final image RUN pip install --no-cache-dir /dist/*.whl # Expose Flask default port for convenience EXPOSE 5000 # Healthcheck to verify runtime Flask import and version HEALTHCHECK --interval=30s --timeout=5s --start-period=5s CMD python -c "import flask; v=flask.__version__; assert isinstance(v, str) and len(v)>0; print(v)" # Default command: show Flask version CMD ["python","-m","flask","--version"]
Concerns: The final image does not run a Flask app server; it only installs Flask as a dependency and provides a version healthcheck. If the intent is to serve a Flask app, the CMD/ENTRYPOINT should start the app., The HEALTHCHECK and CMD rely on Flask being importable and may fail if the wheel does not include Flask (e.g., if pyproject.toml dependencies are misconfigured)., No tests exercise actual runtime behavior of the user application; smoke tests cover only imports.
Smoke [FAIL]: python -c "import flask; v=flask.__version__; assert isinstance(v, str) and len(v)>0; print(v)
Output: sh: syntax error: unterminated quoted string
Smoke [FAIL]: python -c "from flask import Flask; app=Flask('smoke'); assert app.name=='smoke'; print('ok')
Output: sh: syntax error: unterminated quoted stringFROM python:3.12-alpine3.19 AS builder # Install build dependencies required to build Python packages RUN apk add --no-cache build-base libffi-dev openssl-dev ca-certificates WORKDIR /src # Copy project metadata first to leverage Docker cache COPY pyproject.toml . COPY uv.lock . # Copy the rest of the source COPY . . # Ensure pip is available and install build tooling RUN python -m ensurepip RUN pip install --no-cache-dir build # Build the project into dist/ (wheel) RUN python -m build -o dist FROM python:3.12-alpine3.19 # Install runtime dependencies RUN apk add --no-cache libffi openssl ca-certificates WORKDIR /app # Copy built artifacts from the builder stage COPY --from=builder /src/dist /dist # Install the built wheel into the final image RUN pip install --no-cache-dir /dist/*.whl # Create a lightweight healthcheck script that validates Flask importability RUN /bin/sh -lc 'cat > /health_flask.py << "PY"\nimport flask\nv = getattr(flask, "__version__", None)\nif isinstance(v, str) and len(v) > 0:\n print(v)\nelse:\n raise SystemExit(1)\nPY' EXPOSE 5000 # Healthcheck to verify runtime Flask import and version HEALTHCHECK --interval=30s --timeout=5s --start-period=5s CMD ["python","/health_flask.py"] # Default command: show Flask version to verify the image is functional CMD ["flask", "--version"]
Summary: - Build status: VerifyBuild: build_failed. - Key concerns from “Concerns”: - Final CMD uses flask --version; Flask CLI must be installed; if the wheel doesn’t provide Flask CLI, container may fail to start. - Healthcheck assumes Flask is a runtime dependency; if not, healthcheck may always fail. - uv.lock in COPY step is unusual; ensure the file exists in repo or remove this line to avoid build failures. - Build log highlights (selected): - Base image: python:3.12-alpine3.19 (sha256:017a82f185bf6f10e62156f3e89b7e694d56d613b5a3f4dbf1d28f1014a972ed) - Working dir: /src - Steps: COPY pyproject.toml .; apk add --no-cache build-base libffi-dev openssl-dev ca-certificates - Failing step: [builder 5/9] COPY uv.lock . - Error: ENGINE: failed to calculate checksum of ref 4ff19f4d-ebba-4433-930a-fce245b8c5fa::xizde3neyzknm7ooybttpxuc0: "/uv.lock": not found - Warning: 1 warning found (CopyIgnoredFile: Attempting to Copy file "uv.lock" that is excluded by .dockerignore (line 9)) - Dockerfile context line: 9 | COPY uv.lock . - Root cause: uv.lock is excluded by .dockerignore or missing in repo. - Files/paths involved: - Dockerfile: COPY uv.lock . - pyproject.toml - uv.lock - .dockerignore (line 9 excludes uv.lock) - Suggested fix (actionable): - Remove the line COPY uv.lock . from Dockerfile, or ensure uv.lock exists and is not excluded by .dockerignore (adjust .dockerignore accordingly).
FROM python:3.12-alpine3.19 AS builder # Install build dependencies required to build Python packages RUN apk add --no-cache build-base libffi-dev openssl-dev ca-certificates WORKDIR /src # Copy project metadata first to leverage Docker cache COPY pyproject.toml . # Copy the rest of the source COPY . . # Ensure pip is available and install build tooling RUN python -m ensurepip RUN pip install --no-cache-dir build # Build the project (creates wheels in dist/) RUN python -m build -o dist FROM python:3.12-alpine3.19 # Install runtime dependencies RUN apk add --no-cache libffi openssl ca-certificates WORKDIR /app # Copy built artifacts from the builder stage COPY --from=builder /src/dist /dist # Install the built wheel into the final image RUN pip install --no-cache-dir /dist/*.whl # Expose Flask default port for convenience EXPOSE 5000 # Healthcheck to verify runtime Flask import and version HEALTHCHECK --interval=30s --timeout=5s CMD ["flask", "--version"] # Default command: show Flask version to verify the image is functional CMD ["flask", "--version"]
Concerns: Final image relies on the built wheel and Flask being installed as a dependency; if the project doesn’t depend on Flask or the wheel doesn’t include Flask, the smoke tests relying on Flask would fail., Healthcheck uses Flask version tooling in the Dockerfile, which is not a runtime functional test. The smoke tests cover functional app behavior instead, which is good, but consider ensuring the healthcheck aligns with runtime behavior.
Smoke [FAIL]: python -c "from flask import Flask; app=Flask(__name__); app.add_url_rule('/healthz','healthz', lambda: 'ok'); with app.test_client() as c: r=c.get('/healthz'); assert r.status_code==200; assert b'ok' in r.data; print('ok')
Output: sh: syntax error: unterminated quoted string
Smoke [FAIL]: python -c "import flask; assert hasattr(flask, 'Flask'); print('ok')
Output: sh: syntax error: unterminated quoted stringFROM python:3.12-alpine3.19 AS builder # Install build dependencies required to build Python packages RUN apk add --no-cache build-base libffi-dev openssl-dev ca-certificates WORKDIR /src # Copy project metadata first to leverage Docker cache COPY pyproject.toml uv.lock . # Copy the rest of the source COPY . . # Ensure pip is available and install build tooling RUN python -m ensurepip RUN pip install --no-cache-dir build uv # Build the project (creates wheels in dist/) RUN python -m build -o dist FROM python:3.12-alpine3.19 # Install runtime dependencies RUN apk add --no-cache libffi openssl ca-certificates WORKDIR /app # Copy built artifacts from the builder stage COPY --from=builder /src/dist /dist # Install the built wheel into the final image RUN pip install --no-cache-dir /dist/*.whl # Create a lightweight healthcheck script that validates Flask importability RUN /bin/sh -lc 'cat > /health_flask.py << "PY"\nimport flask\nv = getattr(flask, "__version__", None)\nif isinstance(v, str) and len(v) > 0:\n print(v)\nelse:\n raise SystemExit(1)\nPY' EXPOSE 5000 # Healthcheck to verify runtime Flask import and version HEALTHCHECK --interval=30s --timeout=5s CMD ["python","/health_flask.py"] # Default command: show Flask version to verify the image is functional CMD ["flask", "--version"]
#0 building with "default" instance using docker driver #1 [internal] load build definition from Dockerfile #1 transferring dockerfile: 1.36kB done #1 WARN: CopyIgnoredFile: Attempting to Copy file "uv.lock" that is excluded by .dockerignore (line 9) #1 DONE 0.0s #2 [internal] load metadata for docker.io/library/python:3.12-alpine3.19 #2 DONE 0.1s #3 [internal] load .dockerignore #3 transferring context: 333B done #3 DONE 0.0s #4 [builder 1/8] FROM docker.io/library/python:3.12-alpine3.19@sha256:017a82f185bf6f10e62156f3e89b7e694d56d613b5a3f4dbf1d28f1014a972ed #4 CACHED #5 [internal] load build context #5 transferring context: 1.29MB 0.1s done #5 DONE 0.1s #6 [builder 3/8] WORKDIR /src #6 CACHED #7 [builder 4/8] COPY pyproject.toml uv.lock . #7 ERROR: failed to calculate checksum of ref 4ff19f4d-ebba-4433-930a-fce245b8c5fa::bedohj13m16l8hs3tve5tfe8r: "/uv.lock": not found #8 [builder 2/8] RUN apk add --no-cache build-base libffi-dev openssl-dev ca-certificates #8 CANCELED ------ > [builder 4/8] COPY pyproject.toml uv.lock .: ------ [33m1 warning found (use docker --debug to expand): [0m - CopyIgnoredFile: Attempting to Copy file "uv.lock" that is excluded by .dockerignore (line 9) Dockerfile:9 -------------------- 7 | 8 | # Copy project metadata first to leverage Docker cache 9 | >>> COPY pyproject.toml uv.lock . 10 | 11 | # Copy the rest of the source -------------------- ERROR: failed to build: failed to solve: failed to compute cache key: failed to calculate checksum of ref 4ff19f4d-ebba-4433-930a-fce245b8c5fa::bedohj13m16l8hs3tve5tfe8r: "/uv.lock": not found
FROM python:3.12-alpine3.19 AS builder # Install build dependencies required to build Python packages RUN apk add --no-cache build-base libffi-dev openssl-dev ca-certificates WORKDIR /src # Copy project metadata first to leverage Docker cache COPY pyproject.toml . # Copy the rest of the source COPY . . # Ensure pip is available and install build tooling RUN python -m ensurepip RUN pip install --no-cache-dir build uv # Build the project (creates wheels in dist/) RUN python -m build -o dist FROM python:3.12-alpine3.19 # Install runtime dependencies RUN apk add --no-cache libffi openssl ca-certificates WORKDIR /app # Copy built artifacts from the builder stage COPY --from=builder /src/dist /dist # Install the built wheel into the final image RUN pip install --no-cache-dir /dist/*.whl # Create a lightweight healthcheck script that validates Flask importability RUN /bin/sh -lc 'cat > /health_flask.py << "PY"\nimport flask\nv = getattr(flask, "__version__", None)\nif isinstance(v, str) and len(v) > 0:\n print(v)\nelse:\n raise SystemExit(1)\nPY' EXPOSE 5000 # Healthcheck to verify runtime Flask import and version HEALTHCHECK --interval=30s --timeout=5s CMD ["python","/health_flask.py"] # Default command: show Flask version to verify the image is functional CMD ["flask", "--version"]
# Builder stage: build the project from source
FROM python:3.14-alpine3.23 as builder
# Install necessary build tools and libraries
RUN apk add --no-cache build-base libffi-dev openssl-dev ca-certificates
WORKDIR /src
# Copy the full repository into the image
COPY . .
# Install uv and build the project (produces wheels in dist/)
RUN python -m pip install --no-cache-dir uv
RUN uv build
# Runtime stage: minimal image with the built wheel
FROM python:3.14-alpine3.23
# Install essential runtime libraries
RUN apk add --no-cache libffi openssl ca-certificates
WORKDIR /app
# Copy built artifacts from the builder
COPY --from=builder /src/dist /dist
# Install the built wheel(s)
RUN python -m pip install --no-cache-dir /dist/*.whl
# Expose a small health endpoint server port
EXPOSE 8080
# Create a tiny health-check HTTP server to keep the container running and healthy
RUN mkdir -p /health
RUN bash -lc 'cat > /health_server.py << "PY"
import os
from http.server import BaseHTTPRequestHandler, HTTPServer
class HealthHandler(BaseHTTPRequestHandler):
def do_GET(self):
if self.path == "/health":
self.send_response(200)
self.end_headers()
self.wfile.write(b"OK")
else:
self.send_response(404)
self.end_headers()
def log_message(self, format, *args):
return
port = int(os.environ.get("PORT", "8080"))
HTTPServer(("0.0.0.0", port), HealthHandler).serve_forever()
PY'
# Start the health server by default; health checks should hit /health
CMD ["python", "/health_server.py"]
# Builder stage: build the project from source
FROM python:3.14-alpine3.23 AS builder
# Install necessary build tools and libraries
RUN apk add --no-cache build-base libffi-dev openssl-dev ca-certificates
WORKDIR /src
# Copy the full repository into the image
COPY . .
# Install uv and build the project (produces wheels in dist/)
RUN python -m pip install --no-cache-dir uv
RUN uv build
# Runtime stage: minimal image with the built wheel
FROM python:3.14-alpine3.23
# Install essential runtime libraries
RUN apk add --no-cache libffi openssl ca-certificates
WORKDIR /app
# Copy built artifacts from the builder
COPY --from=builder /src/dist /dist
# Install the built wheel(s)
RUN python -m pip install --no-cache-dir /dist/*.whl
# Healthcheck to verify importability of the package
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 CMD ["python", "-c", "import flask, sys; print('health ok')"]
# Keep container running by tail
CMD ["tail", "-f", "/dev/null"]
# Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] *$py.class # Distribution / packaging build/ dist/ *.egg-info/ .eggs/ *.egg # Virtual environments venv/ ENV/ env/ .python-version # Project metadata *.tox/ .Tox/ .tox/ # VS Code / IDE files .vscode/ *.sublime-project *.sublime-workspace # OS files .DS_Store Thumbs.db # Tests and docs tests/ docs/_build/ # Local env files .env *.env
Concerns: FROM image tag python:3.14-alpine3.23 is not a valid/available tag (Python 3.14 is not released and this image may not exist)., HEALTHCHECK imports flask, which may not be a dependency of the built wheel; if Flask is not installed, healthcheck will fail., COPY --from=builder /src/dist /dist assumes uv build produced dist/; if build fails, the runtime image will have nothing to install., Using uv to build in a multi-stage image is unusual for a Python wheel; without clear reproducible steps, build may fail., CMD tail -f /dev/null keeps the container running but does not run a real app; acceptable for smoke tests but not a real service., The healthcheck may mask issues if Flask is installed but the built package does not expose importable module or the wheel has no runtime dependencies satisfied.
Image python:3.14-alpine3.23 exists on Docker Hub.
Concise summary of actionable config and commands for the Flask project:
- Project
- name: Flask
- version: 3.2.0.dev
- requires-python: >=3.10
- license: BSD-3-Clause; license-files: LICENSE.txt
- readme: README.md
- maintainer: Pallets (contact@palletsprojects.com)
- classifiers include production/stable Web/Frameworks, Python 3, WSGI, etc.
- URLs: Donate https://palletsprojects.com/donate; Documentation https://flask.palletsprojects.com/; Changes https://flask.palletsprojects.com/page/changes/; Source https://github.com/pallets/flask/; Chat https://discord.gg/pallets
- Dependencies
- core: blinker>=1.9.0; click>=8.1.3; itsdangerous>=2.2.0; jinja2>=3.1.2; markupsafe>=2.1.1; werkzeug>=3.1.0
- Optional dependencies
- dev: async -> asgiref>=3.2
- dotenv: python-dotenv
- Build/packaging
- build-system: requires flit_core>=3.11,<4; build-backend flit_core.buildapi
- [tool.flit.sdist] include: docs/, examples/, tests/, CHANGES.rst, uv.lock; exclude: docs/_build/
- [project.scripts]: flask = "flask.cli:main"
- Packaging and distribution
- [tool.uv] default-groups: dev, pre-commit, tests, typing
- [build-system], [tool.flit.module], [tool.flit.sdist] details above
- [tool.tox.env_run_base] runner: uv-venv-lock-runner; package: wheel; wheel_build_env: .pkg; constrain_package_deps: true; use_frozen_constraints: true
- Testing & tooling
- [tool.pytest.ini_options]: testpaths = ["tests"]; filterwarnings = ["error"]
- [tool.coverage.run]: branch=true; source=["flask","tests"]; paths=["src","*/site-packages"]
- [tool.coverage.report]: exclude_also includes problematic typing/runtime constructs
- [tool.mypy]: python_version=3.10; files=["src","tests/type_check"]; strict=true; show_error_codes=true; ignore_missing_imports for asgiref.*, dotenv.*, cryptography.*, importlib_metadata
- [tool.pyright]: pythonVersion=3.10; include=["src","tests/type_check"]; typeCheckingMode=basic
- [tool.ruff]: linting on src; fix and show-fixes; lint rules include B, E, F, I, UP, W; isort: single-line
- [tool.codespell]: ignore-words-list = "te"
- tox configuration
- env_list: py3.14, py3.14t, py3.13, py3.12, py3.11, py3.10, pypy3.11, tests-min, tests-dev, style, typing, docs
- env_run_base: pytest command with -v, --tb=short, --basetemp
- tests-min: install pinned versions (blinker==1.9.0; click==8.1.3; itsdangerous==2.2.0; jinja2==3.1.2; markupsafe==2.1.1; werkzeug==3.1.0); run pytest
- tests-dev: install main branches from GitHub tarballs:
- https://github.com/pallets-eco/blinker/archive/refs/heads/main.tar.gz
- https://github.com/pallets/click/archive/refs/heads/main.tar.gz
- https://github.com/pallets/itsdangerous/archive/refs/heads/main.tar.gz
- https://github.com/pallets/jinja/archive/refs/heads/main.tar.gz
- https://github.com/pallets/markupsafe/archive/refs/heads/main.tar.gz
- https://github.com/pallets/werkzeug/archive/refs/heads/main.tar.gz
- style: pre-commit on all files
- typing: run mypy and pyright
- docs/docs-auto: sphinx-build remote; or sphinx-autobuild for auto rebuild
- update-actions: gha-update
- update-pre_commit: pre-commit autoupdate --freeze
- update-requirements: uv lock -U (posargs support)
- Packaging and source layout notes
- [project.urls] includes Donate, Documentation, Changes, Source, Chat
- [tool.tox.env.*] commands use pytest with verbose, short tracebacks, and basetemp
- [tool.mypy.overrides] ignore_missing_imports for specified modules
This captures all files, versions, commands, and package names that drive build, test, and development workflows.# Builder stage: build the project from source FROM python:3.12-alpine3.19 AS builder # Install necessary build tools and libraries RUN apk add --no-cache build-base libffi-dev openssl-dev ca-certificates WORKDIR /src # Copy the full repository into the image COPY . . # Install uv and build the project (produces wheels in dist/) RUN python -m pip install --no-cache-dir uv RUN uv build # Runtime stage: minimal image with the built wheel FROM python:3.12-alpine3.19 # Install essential runtime libraries RUN apk add --no-cache libffi openssl ca-certificates WORKDIR /app # Copy built artifacts from the builder COPY --from=builder /src/dist /dist # Install the built wheel(s) RUN python -m pip install --no-cache-dir /dist/*.whl # Healthcheck to verify importability of the package HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 CMD ["python", "-c", "import flask, sys; print(flask.__version__); sys.exit(0)"] # Keep container running by tail CMD ["tail", "-f", "/dev/null"]
Smoke [FAIL]: python -c \"from flask import Flask; app = Flask('smoke'); assert app.name == 'smoke'; print('ok')\
Output: sh: syntax error: unexpected "("
Smoke [FAIL]: python -c \"from flask import Flask; app = Flask('smoke'); c = app.test_client(); rv = c.get('/'); assert rv.status_code == 404; print('ok')\
Output: sh: syntax error: unexpected "("# Builder stage: build the project from source
FROM python:3.12-alpine3.19 AS builder
# Install necessary build tools and libraries
RUN apk add --no-cache build-base libffi-dev openssl-dev ca-certificates
WORKDIR /src
# Copy the full repository into the image
COPY . .
# Install uv and build the project (produces wheels in dist/)
RUN python -m pip install --no-cache-dir uv
RUN uv build
# Runtime stage: minimal image with the built wheel
FROM python:3.12-alpine3.19
# Install essential runtime libraries
RUN apk add --no-cache libffi openssl ca-certificates
WORKDIR /app
# Copy built artifacts from the builder
COPY --from=builder /src/dist /dist
# Install the built wheel(s)
RUN python -m pip install --no-cache-dir /dist/*.whl
# Lightweight health check script to verify the package imports
RUN printf '%s
' \
'import sys' \
'try:' \
' from flask import Flask' \
' app = Flask("smoke")' \
' print("ok")' \
'except Exception as e:' \
' print("ERR", e)' \
' sys.exit(1)' \
> /health_check.py
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 CMD ["python", "/health_check.py"]
# Keep container running with a no-op command
CMD ["tail", "-f", "/dev/null"]
#0 building with "default" instance using docker driver
#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 1.25kB done
#1 DONE 0.0s
Dockerfile:32
--------------------
31 | RUN printf '%s
32 | >>> ' \
33 | >>> 'import sys' \
34 | >>> 'try:' \
35 | >>> ' from flask import Flask' \
36 | >>> ' app = Flask("smoke")' \
37 | >>> ' print("ok")' \
38 | >>> 'except Exception as e:' \
39 | >>> ' print("ERR", e)' \
40 | >>> ' sys.exit(1)' \
41 | >>> > /health_check.py
42 |
--------------------
ERROR: failed to build: failed to solve: dockerfile parse error on line 32: unknown instruction: 'FROM python:3.12-alpine3.19 AS builder # Install necessary build tools and libraries RUN apk add --no-cache build-base libffi-dev openssl-dev ca-certificates WORKDIR /src # Copy the full repository into the image COPY . . # Install uv and build the project (produces wheels in dist/) RUN python -m pip install --no-cache-dir uv RUN uv build # Runtime stage: minimal image with the built wheel FROM python:3.12-alpine3.19 # Install essential runtime libraries RUN apk add --no-cache libffi openssl ca-certificates WORKDIR /app # Copy built artifacts from the builder COPY --from=builder /src/dist /dist # Install the built wheel(s) RUN python -m pip install --no-cache-dir /dist/*.whl # Lightweight health check: verify the package imports HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 CMD ["python", "-c", "import flask; print(flask.__version__)" ] # Keep container running with a no-op command CMD ["tail", "-f", "/dev/null"]
# Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] *$py.class # Distribution / packaging build/ dist/ *.egg-info/ .eggs/ *.egg # Virtual environments venv/ ENV/ env/ .python-version # Project metadata *.tox/ .Tox/ .tox/ # VS Code / IDE files .vscode/ *.sublime-project *.sublime-workspace # OS files .DS_Store Thumbs.db # Tests and docs tests/ docs/_build/ # Local env files .env *.env
Concerns: Healthcheck imports flask; if the built wheel doesn't depend on Flask, the healthcheck will fail and the image health will be misleading., The final container's CMD tail -f /dev/null means the app isn't started; smoke tests may rely on a service endpoint, which isn't provided by default., The build relies on uv to produce wheels; if the build step fails or produces no wheels, the runtime image will be incomplete. Also COPY . . may bring large or sensitive files into the build context.
Smoke [FAIL]: python -c "import flask; v = flask.__version__; assert isinstance(v, str) and len(v) > 0; print(v)
Output: sh: syntax error: unterminated quoted string
Smoke [FAIL]: python -c "from flask import Flask; app = Flask('smoke'); assert app.name == 'smoke'; print('ok')
Output: sh: syntax error: unterminated quoted stringFROM python:3.12-alpine3.19 AS builder
# Install necessary build tools and libraries
RUN apk add --no-cache build-base libffi-dev openssl-dev ca-certificates
WORKDIR /src
# Copy the full repository into the image
COPY . .
# Install uv and build the project (produces wheels in dist/)
RUN python -m pip install --no-cache-dir uv
RUN uv build
# Runtime stage: minimal image with the built wheel
FROM python:3.12-alpine3.19
# Install essential runtime libraries
RUN apk add --no-cache libffi openssl ca-certificates
WORKDIR /app
# Copy built artifacts from the builder
COPY --from=builder /src/dist /dist
# Install the built wheel(s)
RUN python -m pip install --no-cache-dir /dist/*.whl
# Create a small health-check script to verify the package imports
RUN /bin/sh -lc 'cat > /health_check_import.py << "PY"
try:
import flask
print(flask.__version__)
except Exception as e:
print("ERR", e)
import sys
sys.exit(1)
PY'
# Healthcheck to verify importability of the package
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 CMD ["python","/health_check_import.py"]
# Keep container running with a no-op command
CMD ["tail", "-f", "/dev/null"]
#0 building with "default" instance using docker driver #1 [internal] load build definition from Dockerfile #1 transferring dockerfile: 1.23kB done #1 DONE 0.0s Dockerfile:31 -------------------- 29 | # Create a small health-check script to verify the package imports 30 | RUN /bin/sh -lc 'cat > /health_check_import.py << "PY" 31 | >>> try: 32 | import flask 33 | print(flask.__version__) -------------------- ERROR: failed to build: failed to solve: dockerfile parse error on line 31: unknown instruction: try:
FROM python:3.12-alpine3.19 AS builder
# Install necessary build tools and libraries
RUN apk add --no-cache build-base libffi-dev openssl-dev ca-certificates
WORKDIR /src
# Copy the full repository into the image
COPY . .
# Install uv and build the project (produces wheels in dist/)
RUN python -m pip install --no-cache-dir uv
RUN uv build
# Runtime stage: minimal image with the built wheel
FROM python:3.12-alpine3.19
# Install essential runtime libraries
RUN apk add --no-cache libffi openssl ca-certificates
WORKDIR /app
# Copy built artifacts from the builder
COPY --from=builder /src/dist /dist
# Install the built wheel(s)
RUN python -m pip install --no-cache-dir /dist/*.whl
# Create a small health-check script to verify the package imports
RUN /bin/sh -lc 'cat > /health_check.py << "PY"
try:
import flask
print(flask.__version__)
except Exception as e:
print("ERR", e)
raise SystemExit(1)
PY'
# Healthcheck to verify importability of the package
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 CMD ["python", "/health_check.py"]
# Keep container running with a no-op command
CMD ["tail", "-f", "/dev/null"]
#0 building with "default" instance using docker driver #1 [internal] load build definition from Dockerfile #1 transferring dockerfile: 1.20kB done #1 DONE 0.0s Dockerfile:31 -------------------- 29 | # Create a small health-check script to verify the package imports 30 | RUN /bin/sh -lc 'cat > /health_check.py << "PY" 31 | >>> try: 32 | import flask 33 | print(flask.__version__) -------------------- ERROR: failed to build: failed to solve: dockerfile parse error on line 31: unknown instruction: try:
FROM python:3.12-alpine3.19 AS builder
# Install necessary build tools and libraries
RUN apk add --no-cache build-base libffi-dev openssl-dev ca-certificates
WORKDIR /src
# Copy the full repository into the image
COPY . .
# Install uv and build the project (produces wheels in dist/)
RUN python -m pip install --no-cache-dir uv
RUN uv build
# Runtime stage: minimal image with the built wheel
FROM python:3.12-alpine3.19
# Install essential runtime libraries
RUN apk add --no-cache libffi openssl ca-certificates
WORKDIR /app
# Copy built artifacts from the builder
COPY --from=builder /src/dist /dist
# Install the built wheel(s)
RUN python -m pip install --no-cache-dir /dist/*.whl
# Create a small health-check script to verify the package imports
RUN /bin/sh -lc 'cat > /health_check.py << "PY"
try:
import flask
print(flask.__version__)
except Exception as e:
print("ERR", e)
raise SystemExit(1)
PY'
# Healthcheck to verify importability of the package
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 CMD ["python", "/health_check.py"]
# Keep container running with a no-op command
CMD ["tail", "-f", "/dev/null"]
#0 building with "default" instance using docker driver #1 [internal] load build definition from Dockerfile #1 transferring dockerfile: 1.20kB done #1 DONE 0.0s Dockerfile:31 -------------------- 29 | # Create a small health-check script to verify the package imports 30 | RUN /bin/sh -lc 'cat > /health_check.py << "PY" 31 | >>> try: 32 | import flask 33 | print(flask.__version__) -------------------- ERROR: failed to build: failed to solve: dockerfile parse error on line 31: unknown instruction: try:
FROM python:3.12-alpine3.19 AS builder
# Install necessary build tools and libraries
RUN apk add --no-cache build-base libffi-dev openssl-dev ca-certificates
WORKDIR /src
# Copy the full repository into the image
COPY . .
# Install uv and build the project (produces wheels in dist/)
RUN python -m pip install --no-cache-dir uv
RUN uv build
# Runtime stage: minimal image with the built wheel
FROM python:3.12-alpine3.19
# Install essential runtime libraries
RUN apk add --no-cache libffi openssl ca-certificates
WORKDIR /app
# Copy built artifacts from the builder
COPY --from=builder /src/dist /dist
# Install the built wheel(s)
RUN python -m pip install --no-cache-dir /dist/*.whl
# Create a small health-check script to verify the package imports
RUN mkdir -p /scripts && printf '%s
' 'try:' ' import flask' ' print(flask.__version__)' 'except Exception as e:' ' print("ERR", e)' ' raise SystemExit(1)' > /scripts/health_check.py
# Healthcheck to verify importability of the package
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 CMD ["python", "/scripts/health_check.py"]
# Keep container running with a no-op command
CMD ["tail", "-f", "/dev/null"]
#0 building with "default" instance using docker driver
#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 1.23kB done
#1 DONE 0.0s
Dockerfile:31
--------------------
29 | # Create a small health-check script to verify the package imports
30 | RUN mkdir -p /scripts && printf '%s
31 | >>> ' 'try:' ' import flask' ' print(flask.__version__)' 'except Exception as e:' ' print("ERR", e)' ' raise SystemExit(1)' > /scripts/health_check.py
32 |
33 | # Healthcheck to verify importability of the package
--------------------
ERROR: failed to build: failed to solve: dockerfile parse error on line 31: unknown instruction: '#0 building with "default" instance using docker driver
#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 1.23kB done
#1 DONE 0.0s
Dockerfile:31
--------------------
29 | # Create a small health-check script to verify the package imports
30 | RUN mkdir -p /scripts && printf '%s
31 | >>> ' 'try:' ' import flask' ' print(flask.__version__)' 'except Exception as e:' ' print("ERR", e)' ' raise SystemExit(1)' > /scripts/health_check.py
32 |
33 | # Healthcheck to verify importability of the package
--------------------
ERROR: failed to build: failed to solve: dockerfile parse error on line 31: unknown instruction: '#0 building with "default" instance using docker driver
#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 1.23kB done
#1 DONE 0.0s
Dockerfile:31
--------------------
29 | # Create a small health-check script to verify the package imports
30 | RUN mkdir -p /scripts && printf '%s
31 | >>> ' 'try:' ' import flask' ' print(flask.__version__)' 'except Exception as e:' ' print("ERR", e)' ' raise SystemExit(1)' > /scripts/health_check.py
32 |
33 | # Healthcheck to verify importability of the package
--------------------
ERROR: failed to build: failed to solve: dockerfile parse error on line 31: unknown instruction: 'FROM python:3.12-alpine3.19 AS builder # Install necessary build tools and libraries RUN apk add --no-cache build-base libffi-dev openssl-dev ca-certificates WORKDIR /src # Copy the full repository into the image COPY . . # Install uv and build the project (produces wheels in dist/) RUN python -m pip install --no-cache-dir uv RUN uv build # Runtime stage: minimal image with the built wheel FROM python:3.12-alpine3.19 # Install essential runtime libraries RUN apk add --no-cache libffi openssl ca-certificates WORKDIR /app # Copy built artifacts from the builder COPY --from=builder /src/dist /dist # Install the built wheel(s) RUN python -m pip install --no-cache-dir /dist/*.whl # Healthcheck: verify that importing flask works from the installed package HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 CMD ["python", "-c", "import flask; print(flask.__version__)" ] # Keep container running with a no-op command CMD ["tail", "-f", "/dev/null"]
Concerns: Healthcheck assumes Flask is available in the installed wheel; if the built artifact does not depend on Flask, the healthcheck may be brittle or fail., Smoke tests rely on Flask being importable to exercise functionality; without knowing the exact package name of the built artifact, the tests may not exercise the intended surface.
Smoke [FAIL]: python -c \"import flask; app = flask.Flask('smoke'); print('ok')\
Output: sh: syntax error: unexpected "("
Smoke [FAIL]: python -c \"import flask; print(flask.__version__)\
Output: sh: syntax error: unexpected word (expecting ")")