|
| 1 | +--- |
| 2 | +name: docker-build |
| 3 | +description: Build an LMDeploy Docker image and push it to the inner registry. |
| 4 | +disable-model-invocation: true |
| 5 | +--- |
| 6 | + |
| 7 | +# Docker Build & Push |
| 8 | + |
| 9 | +Build an LMDeploy Docker image and push it to the inner registry. |
| 10 | + |
| 11 | +## Prerequisites |
| 12 | + |
| 13 | +Before starting, verify all three environment variables are set: |
| 14 | + |
| 15 | +```bash |
| 16 | +echo $LMDEPLOY_REGISTRY # inner registry server address |
| 17 | +echo $REGISTRY_USER # registry login username |
| 18 | +test -n "$REGISTRY_PASSWORD" && echo "<set>" || echo "<missing>" # registry login password |
| 19 | +``` |
| 20 | + |
| 21 | +If any are missing, stop and tell the user to set them before proceeding. |
| 22 | + |
| 23 | +## 1. Determine image tag |
| 24 | + |
| 25 | +```bash |
| 26 | +BRANCH=$(git branch --show-current | sed 's/[^a-zA-Z0-9._-]/-/g') |
| 27 | +SHA=$(git rev-parse --short=7 HEAD) |
| 28 | +TAG="${BRANCH}-${SHA}" |
| 29 | +IMAGE="${LMDEPLOY_REGISTRY}/lmdeploy:${TAG}" |
| 30 | +``` |
| 31 | + |
| 32 | +Print the computed image name so the user can confirm. |
| 33 | + |
| 34 | +## 2. Build |
| 35 | + |
| 36 | +Ask the user which build mode: |
| 37 | + |
| 38 | +- **patch** (default) — uses `docker/Dockerfile_patch`, fast overlay on existing image |
| 39 | +- **full** — uses `docker/Dockerfile`, full multi-stage build from scratch |
| 40 | + |
| 41 | +### Patch build (default) |
| 42 | + |
| 43 | +```bash |
| 44 | +docker build -f docker/Dockerfile_patch \ |
| 45 | + --build-arg BASE_IMAGE=openmmlab/lmdeploy:v0.12.3.post2-cu12.8 \ |
| 46 | + --build-arg BACKEND=pytorch \ |
| 47 | + --build-arg http_proxy=${http_proxy:-} \ |
| 48 | + --build-arg https_proxy=${https_proxy:-} \ |
| 49 | + --build-arg no_proxy=${no_proxy:-} \ |
| 50 | + -t "${IMAGE}" \ |
| 51 | + . |
| 52 | +``` |
| 53 | + |
| 54 | +User can override: |
| 55 | + |
| 56 | +- `BASE_IMAGE` — default `openmmlab/lmdeploy:v0.12.3.post2-cu12.8` |
| 57 | +- `BACKEND` — default `pytorch`; set to `turbomind` to include TurboMind C++ extension |
| 58 | + |
| 59 | +### Full build |
| 60 | + |
| 61 | +```bash |
| 62 | +docker build -f docker/Dockerfile \ |
| 63 | + --build-arg CUDA_VERSION=cu12.8 \ |
| 64 | + --build-arg http_proxy=${http_proxy:-} \ |
| 65 | + --build-arg https_proxy=${https_proxy:-} \ |
| 66 | + --build-arg no_proxy=${no_proxy:-} \ |
| 67 | + -t "${IMAGE}" \ |
| 68 | + . |
| 69 | +``` |
| 70 | + |
| 71 | +User can override `CUDA_VERSION` — default `cu12.8`. |
| 72 | + |
| 73 | +### Verify |
| 74 | + |
| 75 | +```bash |
| 76 | +docker images "${IMAGE}" |
| 77 | +``` |
| 78 | + |
| 79 | +## 3. Push |
| 80 | + |
| 81 | +Skip this step if the user only wants a local build. |
| 82 | + |
| 83 | +### Login |
| 84 | + |
| 85 | +```bash |
| 86 | +echo "${REGISTRY_PASSWORD}" | docker login "${LMDEPLOY_REGISTRY}" -u "${REGISTRY_USER}" --password-stdin |
| 87 | +``` |
| 88 | + |
| 89 | +### Push |
| 90 | + |
| 91 | +```bash |
| 92 | +docker push "${IMAGE}" |
| 93 | +``` |
| 94 | + |
| 95 | +Confirm success via exit code. |
0 commit comments