diff --git a/.github/workflows/release.docker.yml b/.github/workflows/release.docker.yml new file mode 100644 index 0000000..bf49245 --- /dev/null +++ b/.github/workflows/release.docker.yml @@ -0,0 +1,51 @@ +on: + release: + types: + - published + pull_request: + types: + - opened + - synchronize + - reopened + branches-ignore: + - "dependabot/**" + +name: Release (Docker) +jobs: + docker: + runs-on: ubuntu-latest + env: + PLATFORMS: "linux/amd64,linux/arm64,linux/arm/v7" + VERSION: "${{ github.event_name == 'release' && github.event.release.name || github.sha }}" + + steps: + - uses: actions/checkout@v2 + - uses: docker/setup-qemu-action@v1 + - uses: docker/setup-buildx-action@v1 + + - uses: docker/login-action@v1 + with: + username: benbjohnson + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - id: meta + uses: docker/metadata-action@v3 + with: + images: litestream/litestream + tags: | + type=ref,event=branch + type=ref,event=pr + type=sha + type=sha,format=long + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + + - uses: docker/build-push-action@v2 + with: + context: . + push: true + platforms: ${{ env.PLATFORMS }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + LITESTREAM_VERSION=${{ env.VERSION }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 677f27f..c0dd0cc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,15 @@ -FROM golang:1.16 as builder +FROM golang:1.17 as builder + WORKDIR /src/litestream COPY . . + ARG LITESTREAM_VERSION=latest + RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/go/pkg \ go build -ldflags "-s -w -X 'main.Version=${LITESTREAM_VERSION}' -extldflags '-static'" -tags osusergo,netgo,sqlite_omit_load_extension -o /usr/local/bin/litestream ./cmd/litestream + FROM alpine COPY --from=builder /usr/local/bin/litestream /usr/local/bin/litestream ENTRYPOINT ["/usr/local/bin/litestream"]