Browse Source

pref: build docker image locally (#464)

Shuyoou 1 year ago
parent
commit
e0e2b94be3

+ 1 - 1
.github/workflows/ci.yml

@@ -26,7 +26,7 @@ jobs:
         uses: docker/build-push-action@v5
         uses: docker/build-push-action@v5
         with:
         with:
           context: .
           context: .
-          platforms: linux/amd64,linux/arm64
+          platforms: linux/amd64
           tags: zilliz/attu:dev
           tags: zilliz/attu:dev
           build-args: VERSION=dev
           build-args: VERSION=dev
           push: false
           push: false

+ 1 - 1
.github/workflows/dev.yml

@@ -47,7 +47,7 @@ jobs:
         uses: docker/build-push-action@v5
         uses: docker/build-push-action@v5
         with:
         with:
           context: .
           context: .
-          platforms: linux/amd64,linux/arm64
+          platforms: linux/amd64
           tags: zilliz/attu:dev
           tags: zilliz/attu:dev
           build-args: VERSION=dev
           build-args: VERSION=dev
           push: true
           push: true

+ 1 - 1
.github/workflows/release.yml

@@ -30,7 +30,7 @@ jobs:
         uses: docker/build-push-action@v5
         uses: docker/build-push-action@v5
         with:
         with:
           context: .
           context: .
-          platforms: linux/amd64,linux/arm64
+          platforms: linux/amd64
           tags: |
           tags: |
             zilliz/attu:${{ github.event.release.tag_name }},zilliz/attu:latest
             zilliz/attu:${{ github.event.release.tag_name }},zilliz/attu:latest
           build-args: VERSION=${{ github.event.release.tag_name }}
           build-args: VERSION=${{ github.event.release.tag_name }}

+ 5 - 0
README.md

@@ -88,6 +88,11 @@ Make sure that the Attu pod can access the Milvus service. In the example provid
 
 
 If you prefer to use a desktop application, you can download the [desktop version of Attu](https://github.com/zilliztech/attu/releases/).
 If you prefer to use a desktop application, you can download the [desktop version of Attu](https://github.com/zilliztech/attu/releases/).
 
 
+### Build Docker Image Locally
+
+- Dev: `yarn run build:dev`
+- Release: `yarn run build:release`
+
 ## FAQ
 ## FAQ
 
 
 - I can't log into the system
 - I can't log into the system

+ 5 - 0
package.json

@@ -11,6 +11,11 @@
       "{name: 'beta', prerelease: true}"
       "{name: 'beta', prerelease: true}"
     ]
     ]
   },
   },
+  "scripts": {
+    "build:ci": "scripts/build-ci.sh",
+    "build:dev": "scripts/build-dev.sh",
+    "build:release": "scripts/build-release.sh"
+  },
   "private": true,
   "private": true,
   "dependencies": {
   "dependencies": {
     "react-router-dom": "^6.20.0"
     "react-router-dom": "^6.20.0"

+ 11 - 0
scripts/build-ci.sh

@@ -0,0 +1,11 @@
+#!/bin/sh
+
+source scripts/prepare.sh
+
+command docker buildx build \
+  --platform linux/arm64,linux/amd64 \
+  --tag zilliz/attu:dev \
+  --build-arg VERSION=dev \
+  --file Dockerfile .
+
+command docker buildx rm multiarch

+ 15 - 0
scripts/build-dev.sh

@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# login docker hub
+source scripts/login.sh
+
+# prepare environment
+source scripts/prepare.sh
+
+command docker buildx build \
+  --platform linux/arm64,linux/amd64 \
+  --tag zilliz/attu:dev \
+  --build-arg VERSION=dev \
+  --file Dockerfile --push .
+
+command docker buildx rm multiarch

+ 15 - 0
scripts/build-release.sh

@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# login docker hub
+source scripts/login.sh
+
+# prepare environment
+source scripts/prepare.sh
+
+command docker buildx build \
+  --platform linux/arm64,linux/amd64 \
+  --tag zilliz/attu:${TAG_NAME},zilliz/attu:latest \
+  --build-arg VERSION=${TAG_NAME} \
+  --file Dockerfile --push .
+
+command docker buildx rm multiarch

+ 7 - 0
scripts/login.sh

@@ -0,0 +1,7 @@
+#!/bin/bash
+
+read -p "Enter your Docker Hub username: " DOCKER_USERNAME
+read -sp "Enter your Docker Hub password: " DOCKER_PASSWORD
+echo
+
+echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin

+ 9 - 0
scripts/prepare.sh

@@ -0,0 +1,9 @@
+#!/bin/sh
+
+PACKAGE_VERSION=$(grep version package.json | awk -F \" '{print $4}')
+TAG_NAME=$(git describe --tags --abbrev=0)
+
+echo version:${PACKAGE_VERSION}
+echo tag:${TAG_NAME}
+
+command docker buildx create --use --name multiarch --driver-opt network=host --buildkitd-flags '--allow-insecure-entitlement network.host'