Skip to content

Commit 1d4f7dd

Browse files
author
yihuiwen
committed
add build image script
1 parent 152ac49 commit 1d4f7dd

2 files changed

Lines changed: 41 additions & 2 deletions

File tree

dockerfiles/Dockerfile_deploy

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
FROM lightx2v/lightx2v:25111101-cu128 AS base
1+
ARG BASE_TAG=26011201-cu128
2+
FROM lightx2v/lightx2v:${BASE_TAG} AS base
23

34
RUN mkdir /workspace/LightX2V
45
WORKDIR /workspace/LightX2V
56
ENV PYTHONPATH=/workspace/LightX2V
67

7-
RUN pip install diffusers==0.37.1
8+
RUN pip install diffusers==0.37.1 librosa
89

910
COPY tools tools
1011
COPY assets assets

dockerfiles/build_deploy.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
5+
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
6+
DOCKERFILE="$SCRIPT_DIR/Dockerfile_deploy"
7+
8+
CURRENT_BRANCH=$(git -C "$REPO_ROOT" rev-parse --abbrev-ref HEAD)
9+
if [[ "$CURRENT_BRANCH" != "main" ]]; then
10+
echo "Error: must be on main branch to build (current: $CURRENT_BRANCH)"
11+
exit 1
12+
fi
13+
14+
AUTO_BASE_TAG=$(grep -oP 'ARG BASE_TAG=\K\S+' "$DOCKERFILE" | head -1)
15+
REGISTRY="lightx2v/lightx2v"
16+
BASE_TAG="$AUTO_BASE_TAG"
17+
18+
while [[ $# -gt 0 ]]; do
19+
case "$1" in
20+
-t|--tag) BASE_TAG="$2"; shift 2 ;;
21+
-r|--registry) REGISTRY="$2"; shift 2 ;;
22+
-h|--help)
23+
echo "Usage: $0 [-t base_tag] [-r registry]"
24+
echo " -t, --tag Base image tag (default: $AUTO_BASE_TAG)"
25+
echo " -r, --registry Registry prefix (default: $REGISTRY)"
26+
exit 0
27+
;;
28+
*) echo "Unknown option: $1"; exit 1 ;;
29+
esac
30+
done
31+
32+
DATE_TAG=$(date +%y%m%d)
33+
GIT_HASH=$(git -C "$REPO_ROOT" rev-parse --short HEAD)
34+
IMAGE_TAG="${REGISTRY}:server-${BASE_TAG}-${DATE_TAG}-${GIT_HASH}"
35+
36+
echo "Base image tag: $BASE_TAG"
37+
echo "Building image: $IMAGE_TAG"
38+
docker buildx build --platform linux/amd64 -f "$DOCKERFILE" -t "$IMAGE_TAG" --build-arg BASE_TAG="$BASE_TAG" "$REPO_ROOT"

0 commit comments

Comments
 (0)