diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..1c25011 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,49 @@ +name: Docker Build + +on: + workflow_call: + inputs: + version: + default: "" + required: true + type: string + workflow_dispatch: + inputs: + version: + default: "" + required: true + type: string + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + # Needed for ARM64 Docker builds + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to dockerhub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and push API + uses: docker/build-push-action@v5 + with: + file: ./Dockerfile + context: . + push: true + pull: true + platforms: 'linux/amd64,linux/arm64/v8' + target: production + cache-from: type=gha + cache-to: type=gha,mode=max + tags: scylladb/gemini:${{ inputs.version }} diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 019e8b0..be86ef1 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -28,14 +28,13 @@ jobs: needs: [build] runs-on: ubuntu-latest strategy: - max-parallel: 4 matrix: gemini-features: ["basic", "normal", "all"] - gemini-concurrency: [16] + gemini-concurrency: [4] duration: ["5m"] dataset-size: [large, small] oracle-scylla-version: ["6.1"] - test-scylla-version: ["6.1"] + test-scylla-version: ["6.2"] fail-fast: false steps: - uses: actions/checkout@v4 @@ -69,4 +68,4 @@ jobs: name: results-${{ matrix.gemini-features }}-${{ matrix.gemini-concurrency }}-${{ matrix.duration }}-${{ matrix.dataset-size }}-${{ matrix.test-scylla-version }}-${{ matrix.oracle-scylla-version }}-${{ github.run_number }} path: ./results if-no-files-found: error - retention-days: 30 + retention-days: 1 diff --git a/.goreleaser.yml b/.goreleaser.yml index 5157e23..894db27 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -57,6 +57,7 @@ dockers: id: gemini-amd64 build_flag_templates: - '--platform=linux/amd64' + - '--target=production-goreleaser' - image_templates: - scylladb/gemini:{{ .Version }}-arm64v8 @@ -65,6 +66,7 @@ dockers: goos: linux build_flag_templates: - '--platform=linux/arm64/v8' + - '--target=production-goreleaser' docker_manifests: - name_template: 'scylladb/gemini:{{ .Version }}' diff --git a/Dockerfile b/Dockerfile index 25b812a..705440a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,32 @@ -FROM busybox +FROM golang:1.23-bookworm AS build + +ENV GO111MODULE=on +ENV CGO_ENABLED=0 +ENV GOAMD64=v3 +ENV GOARM64=v8.0,crypto +ENV CFLAGS="-O3" +ENV CXXFLAGS="-O3" + +WORKDIR /gemini + +COPY . . + +RUN apt-get update \ + && apt-get install -y build-essential ca-certificates \ + && make build + +FROM busybox AS production + +WORKDIR /gemini + +COPY --from=build gemini . + +ENV PATH="/gemini:${PATH}" + +ENTRYPOINT ["gemini"] + + +FROM busybox AS production-goreleaser WORKDIR /gemini diff --git a/Makefile b/Makefile index cda02c4..ec11010 100644 --- a/Makefile +++ b/Makefile @@ -39,10 +39,10 @@ fix: $(GOBIN)/golangci-lint .PHONY: build build: - @CGO_ENABLED=0 go build -o bin/gemini ./cmd/gemini + @CGO_ENABLED=0 go build -ldflags="-s -w" -o bin/gemini ./cmd/gemini debug-build: - @CGO_ENABLED=0 go build -ldflags="-asan" -gcflags "all=-N -l" -o bin/gemini ./cmd/gemini + @CGO_ENABLED=0 go build -gcflags "all=-N -l" -o bin/gemini ./cmd/gemini .PHONY: build-docker build-docker: