Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/push-docker-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Push Docker image

on:
push:
tags: [ 'v*.*.*' ]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
main:
name: Build and push Docker image
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4.1.7

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.4.0

- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3.2.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5.5.1
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v6.3.0
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
55 changes: 55 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Shared layer with dependencies
FROM alpine:3.21.3 AS shared

RUN apk add --no-cache \
lua5.4 \
make \
openssl \
pcre2



# Build dependencies
FROM shared AS build-deps

RUN apk add --no-cache \
alpine-sdk \
lua5.4-dev \
openssl-dev \
pcre2-dev



# Build layer
FROM build-deps AS build

RUN git clone https://github.com/lefcha/imapfilter.git /dist
WORKDIR /dist
RUN make \
INCDIRS=-I/usr/include/lua5.4 \
LDFLAGS='-L/usr/lib/lua5.4' \
LIBLUA=-llua \
LUA_CFLAGS=-I/usr/include/lua5.4



# Final layer with installed imapfilter
FROM shared AS final

COPY --from=build /dist /dist
WORKDIR /dist
RUN make install \
&& rm -rf /dist

RUN addgroup abc \
&& adduser \
--home /home/imapfilter \
--shell /sbin/nologin \
--disabled-password \
--ingroup abc \
abc

USER abc:abc

ENTRYPOINT [ "/usr/local/bin/imapfilter" ]
CMD ["-c", "/config.lua"]