Skip to content

Commit

Permalink
Add Docker pipeline (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
sj14 committed May 7, 2023
1 parent 8c9e42c commit 1312513
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 11 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Docker
on:
push:
tags:
- "*"
branches: # necessary, otherwise it won't trigger on "paths" changes
- '**'
paths:
- Dockerfile
- go.mod
- go.sum
- "**.go"
- ".github/workflows/docker.yaml"
jobs:
docker:
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/sj14/dbbench
tags: |
type=schedule
type=ref,event=tag
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
2 changes: 1 addition & 1 deletion .github/workflows/go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: "^1.19"
go-version: "^1.20"
- name: Check out code into the Go module directory
uses: actions/checkout@v3
- name: Get dependencies
Expand Down
7 changes: 3 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
FROM golang:1.20-alpine3.17 AS build
FROM golang:1-alpine AS build

WORKDIR /app

COPY . .
RUN go mod download

RUN go get -v -t -d ./...
RUN go mod download
RUN go build -v ./cmd/dbbench/...

## Deploy
FROM alpine:3.17
FROM gcr.io/distroless/static-debian11

WORKDIR /app

Expand Down
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

## Table of Contents

- [Description](#Description)
- [Description](#description)
- [Example](#example)
- [Installation](#installation)
- [Supported Databases](#Supported-Databases-/-Driver)
- [Supported Databases](#supported-Databases-/-Driver)
- [Usage](#usage)
- [Custom Scripts](#custom-scripts)
- [Troubeshooting](#troubleshooting)
- [Development](#development)
- [Acknowledgements](#Acknowledgements)
- [Acknowledgements](#acknowledgements)

## Description

Expand Down Expand Up @@ -43,18 +43,26 @@ Binaries are available for all major platforms. See the [releases](https://githu

Using the [Homebrew](https://brew.sh/) package manager for macOS:

``` text
```console
brew install sj14/tap/dbbench
```

### Manually

It's also possible to install the current development snapshot with `go get` (not recommended):

``` text
```console
go get -u github.com/sj14/dbbench/cmd/dbbench
```

### Docker

```console
docker run ghcr.io/sj14/dbbench:latest
```

Check [here](https://github.com/sj14/dbbench/pkgs/container/dbbench) for available images.

## Supported Databases / Driver

Databases | Driver
Expand Down Expand Up @@ -283,4 +291,4 @@ dbbench tidb --pass '' --port 4000

Thanks to the authors of Go and those of the directly and indirectly used libraries, especially the driver developers. It wouldn't be possible without all your work.

This tool was highly inspired by the snippet from user [Fale](https://github.com/cockroachdb/cockroach/issues/23061#issue-300012178) and the tool [pgbench](https://www.postgresql.org/docs/current/pgbench.html). Later, also inspired by [MemSQL's dbbench](https://github.com/memsql/dbbench) which had the name and a similar idea before.
This tool was highly inspired by the snippet from user [Fale](https://github.com/cockroachdb/cockroach/issues/23061#issue-300012178) and the tool [pgbench](https://www.postgresql.org/docs/current/pgbench.html). Later, also inspired by [MemSQL's dbbench](https://github.com/memsql/dbbench) which had the name and a similar idea before.

0 comments on commit 1312513

Please sign in to comment.