Skip to content

Commit

Permalink
Merge pull request #11 from GreptimeTeam/ci/add-dockerfile
Browse files Browse the repository at this point in the history
ci: add ci to build tsbs image
  • Loading branch information
evenyag authored Dec 4, 2023
2 parents 0b0159a + 6df3b64 commit 893165d
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 6 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Build tsbs docker image manually

on:
workflow_dispatch:

jobs:
docker:
name: Build and push image
runs-on: ubuntu-22.04
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Install skopeo
run: |
sudo apt update && sudo apt install -y skopeo
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Configure build image tag
shell: bash
run: |
commitShortSHA=`echo ${GITHUB_SHA} | cut -c1-8`
buildTime=`date +%Y%m%d%H%M%S`
IMAGE_TAG="$commitShortSHA-$buildTime"
echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV
- name: Build and push image
uses: docker/build-push-action@v3
with:
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
docker.io/greptime/tsbs:${{ env.IMAGE_TAG }}
- name: Sync images to ACR
shell: bash
env:
DST_REGISTRY_USERNAME: ${{ secrets.ALICLOUD_USERNAME }}
DST_REGISTRY_PASSWORD: ${{ secrets.ALICLOUD_PASSWORD }}
run: |
docker run quay.io/skopeo/stable:latest copy -a docker://docker.io/greptime/tsbs:${{ env.IMAGE_TAG }} \
--dest-creds "$DST_REGISTRY_USERNAME":"$DST_REGISTRY_PASSWORD" \
docker://greptime-registry.cn-hangzhou.cr.aliyuncs.com/greptime/tsbs:${{ env.IMAGE_TAG }}
6 changes: 3 additions & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.15
go-version: 1.21

- name: Test
run: go test -v -race ./...
run: make test
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Build stage
FROM golang:1.13.1-alpine AS builder
FROM golang:1.21.4-alpine AS builder
WORKDIR /tsbs
COPY ./ ./
RUN apk update && apk add --no-cache git
RUN go mod download && go install ./...

# Final stage
FROM alpine:3.8.5
FROM alpine:3.18.5
RUN apk update && apk add --no-cache bash
COPY --from=builder /go/bin /
COPY --from=builder /tsbs/scripts /
Expand Down
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,14 @@ runners: tsbs_run_queries_akumuli \
tsbs_run_queries_questdb

test:
$(GOTEST) -v ./...
$(GOTEST) -v -race \
./cmd/tsbs_generate_data \
./cmd/tsbs_generate_queries \
./cmd/tsbs_load \
./cmd/tsbs_load_greptime \
./internal/... \
./load/... \
./pkg/...

coverage:
$(GOTEST) -race -coverprofile=coverage.txt -covermode=atomic ./...
Expand Down

0 comments on commit 893165d

Please sign in to comment.