diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..ad2992b --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,35 @@ +name: Docker + +on: + push: + branches: [ main ] + tags: [ 'v*.*.*' ] + pull_request: + branches: [ main ] + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Log into registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + push: true + tags: | + ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:latest + ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.sha }} \ No newline at end of file diff --git a/DockerFile b/DockerFile new file mode 100644 index 0000000..bd31ccc --- /dev/null +++ b/DockerFile @@ -0,0 +1,27 @@ +ARG NODE_VERSION=22.13.1 +ARG VERSION + +FROM node:${NODE_VERSION}-alpine + +ENV NODE_ENV="production" \ + PORT="2525" \ + UMASK="0002" \ + TZ="Etc/UTC" + +WORKDIR /app + +RUN apk add --no-cache --virtual=.build-deps git \ + && git clone https://github.com/softbounce/inbound-email.git . \ + && if [ -n "${VERSION}" ]; then \ + NUMBER_COMMITS_TO_REVERT=$(( $(git rev-list --count --first-parent HEAD) - $(echo "${VERSION}" | cut -d "." -f3) )); \ + git checkout "master~${NUMBER_COMMITS_TO_REVERT}"; \ + fi \ + && npm install --omit=dev \ + && chown -R root:root /app && chmod -R 755 /app \ + && apk del --purge .build-deps \ + && rm -rf /root/.cache /root/.cargo /tmp/* + +USER node +EXPOSE 2525 +CMD node server.js +LABEL org.opencontainers.image.source="https://github.com/softbounce/inbound-email" \ No newline at end of file diff --git a/readme.md b/readme.md index 2bfd463..fd87247 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,6 @@ # Inbound Email (SMTP) to Webhook -Author: [Martin Alexander](https://martinalexander.me/) - [LinkedIn](https://www.linkedin.com/in/martin-alexander) +Author: Martin Krivosija - [LinkedIn](https://linkedin.com/in/martin-alexander-k) A simple, efficient script that provides an SMTP server to receive emails, parse content (including headers), store attachments in Amazon S3, and forward email content to a webhook. Graceful handling of multiple concurrent SMTP sessions and webhook requests. @@ -24,7 +24,7 @@ A simple, efficient script that provides an SMTP server to receive emails, parse 1. Clone this repository: ``` - git clone https://github.com/sendbetter/inbound-email.git + git clone https://github.com/kriiv/inbound-email.git cd inbound-email ``` @@ -34,15 +34,22 @@ A simple, efficient script that provides an SMTP server to receive emails, parse ``` 3. Copy the `.env.example` file to `.env` and set the required configuration: (eg. `mv .env.example .env`) - - `MAX_FILE_SIZE`: Maximum size of attachments to process, in bytes (default: 5MB) - - `AWS_REGION`: Your AWS region - - `AWS_ACCESS_KEY_ID`: Your AWS access key ID - - `AWS_SECRET_ACCESS_KEY`: Your AWS secret access key - - `S3_BUCKET_NAME`: The name of your S3 bucket for storing attachments - - `PORT`: The port for the SMTP server to listen on (default: 25) - - `WEBHOOK_URL`: The URL where parsed emails will be sent (required) - - `SMTP_SECURE`: Set to 'true' for TLS support (default: false) - - `WEBHOOK_CONCURRENCY`: Number of concurrent webhook requests (default: 5) + + | Variable | Description | Required | Default | + | --------------------- | --------------------------------------------------------------- | -------- | ----------- | + | `WEBHOOK_URL` | The URL where parsed emails will be sent | Yes | `null` | + | `PORT` | The port for the SMTP server to listen on | No | `25` | + | `SMTP_SECURE` | Set to 'true' for TLS support (requires key/cert setup) | No | `false` | + | `WEBHOOK_CONCURRENCY` | Number of concurrent webhook requests | No | `5` | + | `MAX_FILE_SIZE` | Maximum attachment size in bytes (0 to disable S3 uploads) | No | `5242880` (5MB) | + | `AWS_REGION` | Your AWS region | If saving| `null` | + | `AWS_ACCESS_KEY_ID` | Your AWS access key ID | If saving| `null` | + | `AWS_SECRET_ACCESS_KEY`| Your AWS secret access key | If saving| `null` | + | `S3_BUCKET_NAME` | The name of your S3 bucket for storing attachments | If saving| `null` | + | `TLS_KEY_PATH` | Path to the TLS private key file (if `SMTP_SECURE=true`) | If secure| `null` | + | `TLS_CERT_PATH` | Path to the TLS certificate file (if `SMTP_SECURE=true`) | If secure| `null` | + + *Note: S3 credentials (`AWS_*`, `S3_BUCKET_NAME`) are required if `MAX_FILE_SIZE` > 0.* ## Usage