Skip to content

Commit

Permalink
ci: refine image building (zilliztech#352)
Browse files Browse the repository at this point in the history
Signed-off-by: zhuwenxing <[email protected]>
  • Loading branch information
zhuwenxing authored May 30, 2024
1 parent 93f9ae0 commit 9ccbc27
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 13 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,8 @@ jobs:
cat configs/backup.yaml || true
go get
go build
bash build_image.sh
- name: Install dependency

timeout-minutes: 5
Expand Down Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
11 changes: 4 additions & 7 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 13 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
12 changes: 12 additions & 0 deletions build/deployment/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -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"
7 changes: 7 additions & 0 deletions build_image.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 9ccbc27

Please sign in to comment.