diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..67e7edb --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,53 @@ +--- +name: docker + +on: + push: + branches: + - '*' + tags: + - v* + pull_request: + branches: + - '*' + workflow_dispatch: {} + +jobs: + build-and-push: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: docker/setup-qemu-action@v3 + with: + # Spurious segfaults when compiling + # https://github.com/docker/setup-qemu-action/issues/188 + image: tonistiigi/binfmt:qemu-v8.1.5 + - uses: docker/setup-buildx-action@v3 + + - uses: docker/metadata-action@v5 + id: meta + with: + flavor: | + latest=false + images: | + name=ghcr.io/${{ github.repository }},enable=${{ github.repository == 'lefcha/imapfilter' }} # publishing to ghcr.io/lefcha/imapfilter + name=ghcr.io/${{ github.actor }}/imapfilter,enable=true # publish to the (PR) author's packages + tags: | + type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }} # set latest tag for releases + type=semver,pattern={{raw}} # uses git tag as image tag + type=ref,event=branch + type=ref,event=pr + type=sha + + - uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - uses: docker/build-push-action@v6 + with: + push: true + tags: ${{ steps.meta.outputs.tags }} + platforms: linux/amd64,linux/arm64,linux/arm/v7 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..36d9941 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +FROM alpine AS builder + +RUN apk --no-cache add make gcc lua lua-dev openssl openssl-dev libc-dev pcre pcre-dev pcre2-dev + +WORKDIR /build + +ADD . /build +RUN make && make install + +FROM alpine + +COPY --from=builder /usr/local/bin/imapfilter /usr/local/bin/imapfilter +COPY --from=builder /usr/local/share/imapfilter /usr/local/share/imapfilter + +RUN apk --no-cache add lua lua-dev openssl pcre git \ + && adduser -D -u 1000 imapfilter + +USER imapfilter + +ENTRYPOINT ["/usr/local/bin/imapfilter"]