diff --git a/.github/workflows/release.docker.yml b/.github/workflows/release.docker.yml new file mode 100644 index 0000000..1321909 --- /dev/null +++ b/.github/workflows/release.docker.yml @@ -0,0 +1,56 @@ +on: + release: + types: + - published + pull_request: + types: + - opened + - synchronize + - reopened + branches-ignore: + - "dependabot/**" + +name: Release (Docker) +jobs: + docker: + runs-on: ubuntu-latest + strategy: + matrix: + include: + - platform: linux/amd64 + - platform: linux/arm64 + + env: + 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: ${{ matrix.platform }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + LITESTREAM_VERSION=${{ env.VERSION }} diff --git a/.github/workflows/release.linux.yml b/.github/workflows/release.linux.yml index aff5e84..d45c111 100644 --- a/.github/workflows/release.linux.yml +++ b/.github/workflows/release.linux.yml @@ -1,7 +1,7 @@ on: release: types: - - created + - published pull_request: types: - opened @@ -132,4 +132,3 @@ jobs: run: sleep 60 && gh workflow run deploy.yml -R benbjohnson/litestream-test-runner -f run_id=${{ github.run_id }} -f litestream_version=${{ github.sha }} env: GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }} - 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"]