方寸 Portal

AI Engineer Portal

Your personal operating system for career transition.

Private mode

Exercise

Write a multi-stage Dockerfile for an LLM application

Write a multi-stage Dockerfile for a Python LLM application that:

  1. Uses a builder stage to install Python dependencies from requirements.txt
  2. Copies only the installed packages into a slim runtime stage
  3. Runs as a non-root user named appuser
  4. Exposes port 8000
  5. Adds a HEALTHCHECK that probes http://localhost:8000/health using Python's urllib.request
  6. Sets the default command to start a uvicorn server at src.main:app

Your answer should be a complete, valid Dockerfile. Include comments explaining each stage.

Bonus: Add a .dockerignore snippet that excludes __pycache__, .env files, and any .gguf or .bin model weight files.

Deployment / medium / Step 1 of 6

Practice stage

General drill

Hint

Keep the solution explicit and reviewable.

Success criteria

Make the solution explicit, debuggable, and easy to explain.

Review checklist

Review where the boundary is, what gets validated, and what would be hard to debug later.

Practice

Generate a variation

Generate a new exercise variation to deepen understanding or practice a related concept.

Attempt history

Recent submissions

Before you submit, decide what a strong answer should make obvious to the reviewer.

No attempts yet.