소스 검색

Use current git branch for Docker image tag in dw CLI

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
tuanchris 5 달 전
부모
커밋
2ce0b4204b
2개의 변경된 파일18개의 추가작업 그리고 6개의 파일을 삭제
  1. 2 2
      docker-compose.yml
  2. 16 4
      dw

+ 2 - 2
docker-compose.yml

@@ -3,7 +3,7 @@ services:
     build:
       context: ./frontend
       dockerfile: Dockerfile
-    image: ghcr.io/tuanchris/dune-weaver-frontend:main
+    image: ghcr.io/tuanchris/dune-weaver-frontend:${IMAGE_TAG:-main}
     restart: always
     ports:
       - "${FRONTEND_PORT:-80}:80"
@@ -15,7 +15,7 @@ services:
 
   backend:
     build: .
-    image: ghcr.io/tuanchris/dune-weaver:main
+    image: ghcr.io/tuanchris/dune-weaver:${IMAGE_TAG:-main}
     restart: always
     # Pin motion-critical backend to cores 0-2 (Raspberry Pi 4/5 has cores 0-3)
     # This prevents CPU contention from touch app blocking I/O calls

+ 16 - 4
dw

@@ -46,6 +46,13 @@ is_docker_mode() {
     [[ -f "$INSTALL_DIR/docker-compose.yml" ]] && command -v docker &> /dev/null
 }
 
+# Set IMAGE_TAG from current git branch (e.g. feature/foo -> feature-foo)
+set_image_tag() {
+    local branch
+    branch=$(git -C "$INSTALL_DIR" rev-parse --abbrev-ref HEAD)
+    export IMAGE_TAG="${branch//\//-}"
+}
+
 INSTALL_DIR=$(find_install_dir)
 
 # Check if installed
@@ -87,7 +94,8 @@ cmd_start() {
     cd "$INSTALL_DIR"
 
     if is_docker_mode; then
-        sudo docker compose up -d
+        set_image_tag
+        sudo -E docker compose up -d
     else
         sudo systemctl start dune-weaver
     fi
@@ -115,7 +123,8 @@ cmd_restart() {
     cd "$INSTALL_DIR"
 
     if is_docker_mode; then
-        sudo docker compose restart
+        set_image_tag
+        sudo -E docker compose restart
     else
         sudo systemctl restart dune-weaver
     fi
@@ -144,14 +153,17 @@ cmd_update() {
     fi
 
     if is_docker_mode; then
+        set_image_tag
+        echo -e "Image tag: ${BLUE}${IMAGE_TAG}${NC}"
+
         echo "Pulling latest Docker image..."
-        sudo docker compose pull
+        sudo -E docker compose pull
 
         echo "Stopping current container..."
         sudo docker compose down
 
         echo "Starting with new version..."
-        sudo docker compose up -d --remove-orphans
+        sudo -E docker compose up -d --remove-orphans
 
         echo "Cleaning up unused Docker resources..."
         sudo docker image prune -f