diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index e27e9130..1b78fc6e 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -535,6 +535,8 @@ jobs: cat configs/backup.yaml || true go get go build + bash build_image.sh + - name: Install dependency timeout-minutes: 5 @@ -573,8 +575,11 @@ jobs: - name: Start server timeout-minutes: 5 shell: bash + working-directory: build/deployment run: | - ./milvus-backup server > server.log 2>&1 & + docker-compose up -d + sleep 10 + docker-compose ps -a - name: Run test timeout-minutes: 120 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index ee24d4e7..c9ec2b19 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -20,6 +20,10 @@ jobs: with: go-version: 1.18 cache: true + - uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} - uses: goreleaser/goreleaser-action@v4 with: @@ -30,3 +34,25 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} GITHUB_HOMEBREW_TOKEN: ${{ secrets.HOMEBREW_TOKEN }} + + dockerhub: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - run: git fetch --force --tags + - uses: actions/setup-go@v3 + with: + go-version: 1.18 + cache: true + - uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and push Docker image + shell: bash + run: | + bash build_image.sh + docker push milvusdb/milvus-backup:$(git describe --tags --always) + docker push milvusdb/milvus-backup:latest diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 3660e61f..3227879d 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -30,30 +30,27 @@ archives: {{- else }}{{ .Arch }}{{ end }} {{- if .Arm }}v{{ .Arm }}{{ end }} checksum: - name_template: 'checksums.txt' + name_template: "checksums.txt" snapshot: name_template: "{{ incpatch .Version }}-next" brews: - - - name: milvus-backup + - name: milvus-backup folder: Formula homepage: "https://github.com/zilliztech/milvus-backup" repository: owner: zilliztech name: homebrew-tap token: "{{ .Env.GITHUB_HOMEBREW_TOKEN }}" - changelog: sort: asc use: github filters: exclude: - - '^docs:' - - '^test:' + - "^docs:" + - "^test:" - Merge pull request - # The lines beneath this are called `modelines`. See `:help modeline` # Feel free to remove those if you don't want/use them. # yaml-language-server: $schema=https://goreleaser.com/static/schema.json diff --git a/Dockerfile b/Dockerfile index 6dc78de7..be1d34e3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,25 @@ + FROM golang:1.18 AS builder ENV CGO_ENABLED=0 + +ARG VERSION=0.0.1 +ARG COMMIT=unknown +ARG DATE=unknown + WORKDIR /app +COPY go.mod go.sum ./ +RUN go mod download + COPY . . -RUN go mod tidy -RUN go build -ldflags="-s -w" -o /app/milvus-backup -RUN wget -P /app https://dl.min.io/client/mc/release/linux-amd64/mc -RUN chmod +x /app/mc +RUN go build -ldflags="-X 'main.version=$VERSION' -X 'main.commit=$COMMIT' -X 'main.date=$DATE'" -o /app/milvus-backup FROM alpine:3.17 + WORKDIR /app +RUN apk add --no-cache curl + COPY --from=builder /app/milvus-backup . COPY --from=builder /app/configs ./configs -COPY --from=builder /app/mc . EXPOSE 8080 ENTRYPOINT ["/app/milvus-backup", "server"] diff --git a/build/deployment/docker-compose.yaml b/build/deployment/docker-compose.yaml new file mode 100644 index 00000000..2f145fbc --- /dev/null +++ b/build/deployment/docker-compose.yaml @@ -0,0 +1,12 @@ +version: '3.5' + +services: + milvus-backup: + container_name: milvus-backup + image: milvusdb/milvus-backup:latest + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:8080/api/v1/hello"] + interval: 60s + timeout: 10s + retries: 3 + network_mode: "host" \ No newline at end of file diff --git a/build_image.sh b/build_image.sh new file mode 100644 index 00000000..191d9038 --- /dev/null +++ b/build_image.sh @@ -0,0 +1,7 @@ + +VERSION=$(git describe --tags --always) +COMMIT=$(git rev-parse --short HEAD) +DATA=$(date +'%Y-%m-%dT%H:%M:%S') + +docker build -t milvusdb/milvus-backup:$VERSION --build-arg VERSION=$VERSION --build-arg COMMIT=$COMMIT --build-arg DATA=$DATA . +docker tag milvusdb/milvus-backup:$VERSION milvusdb/milvus-backup:latest \ No newline at end of file