diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml index 4845ddce7..e9240f0c4 100644 --- a/.github/workflows/build-docker-image.yml +++ b/.github/workflows/build-docker-image.yml @@ -8,6 +8,7 @@ on: required: true type: string push: + branches: [ main ] tags: [ "v*.*.*" ] env: @@ -52,14 +53,24 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Log in to Docker Hub + uses: docker/login-action@v4 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@v6 with: - images: ${{ env.REGISTRY }}/${{ steps.image-name.outputs.image }} + images: | + ${{ env.REGISTRY }}/${{ steps.image-name.outputs.image }} + docker.io/${{ secrets.DOCKERHUB_USERNAME }}/openviking tags: | type=raw,value=${{ github.event.inputs.version }},enable=${{ github.event_name == 'workflow_dispatch' }} type=ref,event=tag,enable=${{ github.ref_type == 'tag' }} + type=raw,value=latest,enable=${{ github.ref_type == 'tag' }} + type=raw,value=main,enable=${{ github.ref == 'refs/heads/main' }} - name: Set up Docker Buildx uses: docker/setup-buildx-action@v4 @@ -70,7 +81,9 @@ jobs: with: context: . platforms: ${{ matrix.platform }} - outputs: type=image,name=${{ env.REGISTRY }}/${{ steps.image-name.outputs.image }},push-by-digest=true,name-canonical=true,push=true + outputs: | + type=image,name=${{ env.REGISTRY }}/${{ steps.image-name.outputs.image }},push-by-digest=true,name-canonical=true,push=true + type=image,name=docker.io/${{ secrets.DOCKERHUB_USERNAME }}/openviking,push-by-digest=true,name-canonical=true,push=true labels: ${{ steps.meta.outputs.labels }} build-args: | # fallback to 0.0.0 if no version is provided @@ -117,14 +130,24 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Log in to Docker Hub + uses: docker/login-action@v4 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@v6 with: - images: ${{ env.REGISTRY }}/${{ steps.image-name.outputs.image }} + images: | + ${{ env.REGISTRY }}/${{ steps.image-name.outputs.image }} + docker.io/${{ secrets.DOCKERHUB_USERNAME }}/openviking tags: | type=raw,value=${{ github.event.inputs.version }},enable=${{ github.event_name == 'workflow_dispatch' }} type=ref,event=tag,enable=${{ github.ref_type == 'tag' }} + type=raw,value=latest,enable=${{ github.ref_type == 'tag' }} + type=raw,value=main,enable=${{ github.ref == 'refs/heads/main' }} - name: Set up Docker Buildx uses: docker/setup-buildx-action@v4 @@ -140,20 +163,33 @@ jobs: env: SOURCE_TAGS: ${{ steps.meta.outputs.tags }} run: | - image_refs=() + # Collect image references for both registries + ghcr_image_refs=() + dockerhub_image_refs=() for digest_file in /tmp/digests/*; do [ -e "$digest_file" ] || continue - image_refs+=("${{ env.REGISTRY }}/${{ steps.image-name.outputs.image }}@sha256:$(basename "$digest_file")") + digest="sha256:$(basename "$digest_file")" + ghcr_image_refs+=("${{ env.REGISTRY }}/${{ steps.image-name.outputs.image }}@${digest}") + dockerhub_image_refs+=("docker.io/${{ secrets.DOCKERHUB_USERNAME }}/openviking@${digest}") done - [ ${#image_refs[@]} -gt 0 ] || { + [ ${#ghcr_image_refs[@]} -gt 0 ] || { echo "No image digests found" >&2 exit 1 } + # Create manifests for all tags while IFS= read -r tag; do [ -n "$tag" ] || continue - docker buildx imagetools create \ - --tag "$tag" \ - "${image_refs[@]}" + + # Determine which registry this tag belongs to + if [[ "$tag" == ghcr.io/* ]]; then + docker buildx imagetools create \ + --tag "$tag" \ + "${ghcr_image_refs[@]}" + elif [[ "$tag" == docker.io/* ]]; then + docker buildx imagetools create \ + --tag "$tag" \ + "${dockerhub_image_refs[@]}" + fi done <<< "$SOURCE_TAGS" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ec9c51d12..045de4d58 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -197,13 +197,22 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Log in to Docker Hub + uses: docker/login-action@v4 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@v6 with: - images: ghcr.io/${{ steps.image-name.outputs.image }} + images: | + ghcr.io/${{ steps.image-name.outputs.image }} + docker.io/${{ secrets.DOCKERHUB_USERNAME }}/openviking tags: | type=raw,value=${{ github.event.release.tag_name }} + type=raw,value=latest - name: Set up Docker Buildx uses: docker/setup-buildx-action@v4 @@ -214,7 +223,9 @@ jobs: with: context: . platforms: ${{ matrix.platform }} - outputs: type=image,name=ghcr.io/${{ steps.image-name.outputs.image }},push-by-digest=true,name-canonical=true,push=true + outputs: | + type=image,name=ghcr.io/${{ steps.image-name.outputs.image }},push-by-digest=true,name-canonical=true,push=true + type=image,name=docker.io/${{ secrets.DOCKERHUB_USERNAME }}/openviking,push-by-digest=true,name-canonical=true,push=true labels: ${{ steps.meta.outputs.labels }} build-args: | OPENVIKING_VERSION=${{ github.event.release.tag_name }} @@ -263,13 +274,22 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Log in to Docker Hub + uses: docker/login-action@v4 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@v6 with: - images: ghcr.io/${{ steps.image-name.outputs.image }} + images: | + ghcr.io/${{ steps.image-name.outputs.image }} + docker.io/${{ secrets.DOCKERHUB_USERNAME }}/openviking tags: | type=raw,value=${{ github.event.release.tag_name }} + type=raw,value=latest - name: Set up Docker Buildx uses: docker/setup-buildx-action@v4 @@ -285,20 +305,33 @@ jobs: env: SOURCE_TAGS: ${{ steps.meta.outputs.tags }} run: | - image_refs=() + # Collect image references for both registries + ghcr_image_refs=() + dockerhub_image_refs=() for digest_file in /tmp/digests/*; do [ -e "$digest_file" ] || continue - image_refs+=("ghcr.io/${{ steps.image-name.outputs.image }}@sha256:$(basename "$digest_file")") + digest="sha256:$(basename "$digest_file")" + ghcr_image_refs+=("ghcr.io/${{ steps.image-name.outputs.image }}@${digest}") + dockerhub_image_refs+=("docker.io/${{ secrets.DOCKERHUB_USERNAME }}/openviking@${digest}") done - [ ${#image_refs[@]} -gt 0 ] || { + [ ${#ghcr_image_refs[@]} -gt 0 ] || { echo "No image digests found" >&2 exit 1 } + # Create manifests for all tags while IFS= read -r tag; do [ -n "$tag" ] || continue - docker buildx imagetools create \ - --tag "$tag" \ - "${image_refs[@]}" + + # Determine which registry this tag belongs to + if [[ "$tag" == ghcr.io/* ]]; then + docker buildx imagetools create \ + --tag "$tag" \ + "${ghcr_image_refs[@]}" + elif [[ "$tag" == docker.io/* ]]; then + docker buildx imagetools create \ + --tag "$tag" \ + "${dockerhub_image_refs[@]}" + fi done <<< "$SOURCE_TAGS" diff --git a/docs/en/guides/03-deployment.md b/docs/en/guides/03-deployment.md index 8d63b33a4..e7cbba92b 100644 --- a/docs/en/guides/03-deployment.md +++ b/docs/en/guides/03-deployment.md @@ -194,6 +194,7 @@ curl http://localhost:1933/api/v1/fs/ls?uri=viking:// \ ### Docker OpenViking provides pre-built Docker images published to GitHub Container Registry: +> ~/.openviking/ov.conf need to be configured correctly first. ```bash docker run -d \ @@ -203,7 +204,7 @@ docker run -d \ -v ~/.openviking/ov.conf:/app/ov.conf \ -v /var/lib/openviking/data:/app/data \ --restart unless-stopped \ - ghcr.io/volcengine/openviking:main + ghcr.io/volcengine/openviking:latest ``` By default, the Docker image starts: @@ -221,7 +222,7 @@ docker run -d \ -v ~/.openviking/ov.conf:/app/ov.conf \ -v /var/lib/openviking/data:/app/data \ --restart unless-stopped \ - ghcr.io/volcengine/openviking:main \ + ghcr.io/volcengine/openviking:latest \ --without-bot ```