Skip to content
This repository was archived by the owner on Dec 23, 2023. It is now read-only.

Commit dc15c5b

Browse files
authored
Merge pull request #39 from b3n4kh/feature/goreleaser
Feature/goreleaser
2 parents df44f7f + e74ffdd commit dc15c5b

File tree

6 files changed

+182
-12
lines changed

6 files changed

+182
-12
lines changed

.github/workflows/build.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: build
2+
3+
on:
4+
push:
5+
tags:
6+
- '**'
7+
8+
permissions:
9+
contents: write
10+
packages: write
11+
12+
jobs:
13+
goreleaser:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v3
18+
with:
19+
fetch-depth: 0
20+
- name: Fetch all tags
21+
run: git fetch --force --tags
22+
- name: Set up Go
23+
uses: actions/setup-go@v3
24+
with:
25+
go-version: 1.19
26+
cache: true
27+
- name: get ghcr owner repository
28+
run: |
29+
echo "GHCR_OWNER=${GITHUB_REPOSITORY_OWNER,,}" >>${GITHUB_ENV}
30+
- name: Login to GitHub Container Registry
31+
uses: docker/login-action@v2
32+
with:
33+
registry: ghcr.io
34+
username: ${{ github.actor }}
35+
password: ${{ secrets.GITHUB_TOKEN }}
36+
- name: Run GoReleaser
37+
uses: goreleaser/goreleaser-action@v4
38+
with:
39+
distribution: goreleaser
40+
version: latest
41+
args: release --rm-dist
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
GHCR_OWNER: ${{ env.GHCR_OWNER }}

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22
config*.yml
33
!config.default.yml
44
mailwhale
5-
*.db
5+
node_modules
6+
package-lock.json
7+
package.json
8+
dist
9+
*.db

.goreleaser.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
builds:
3+
- id: mailwhale-builds
4+
binary: mailwhale
5+
dir: .
6+
before:
7+
hooks:
8+
- sudo npm install -g yarn
9+
- yarn --cwd webui
10+
- yarn --cwd webui build
11+
- cp config.default.yml config.yml
12+
archives:
13+
- id: mailwhale-archives
14+
builds:
15+
- mailwhale-builds
16+
files:
17+
- LICENSE
18+
- README.md
19+
- webui/public/*
20+
- config.yml
21+
- templates/*
22+
- version.txt
23+
replacements:
24+
darwin: Darwin
25+
linux: Linux
26+
386: i386
27+
amd64: x86_64
28+
name_template: "{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
29+
dockers:
30+
- ids:
31+
- mailwhale-builds
32+
goos: linux
33+
goarch: amd64
34+
dockerfile: Dockerfile-goreleaser
35+
extra_files:
36+
- "version.txt"
37+
- "config.yml"
38+
- "LICENSE"
39+
- "README.md"
40+
- "templates/"
41+
- "webui/"
42+
43+
image_templates:
44+
- "ghcr.io/{{ .Env.GHCR_OWNER }}/mailwhale:latest"
45+
- "ghcr.io/{{ .Env.GHCR_OWNER }}/mailwhale:{{ .Tag }}"
46+
release:
47+
mode: replace

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Build Stage
22

3-
FROM golang:1.18 AS api-build-env
3+
FROM golang:1.19 AS api-build-env
44

55
WORKDIR /src
66
ADD . .
@@ -11,7 +11,7 @@ RUN cp /src/mailwhale . && \
1111
cp /src/version.txt . && \
1212
cp -r /src/templates .
1313

14-
FROM node:14 AS ui-build-env
14+
FROM node:18 AS ui-build-env
1515

1616
WORKDIR /src
1717
ADD webui .

Dockerfile-goreleaser

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Build Stage
2+
3+
FROM golang:1.19 AS api-build-env
4+
5+
WORKDIR /app
6+
7+
FROM node:18 AS ui-build-env
8+
9+
WORKDIR /src
10+
ADD webui .
11+
RUN yarn && \
12+
yarn build
13+
14+
# Run Stage
15+
16+
# When running the application using `docker run`, you can pass environment variables
17+
# to override config values using `-e` syntax.
18+
19+
FROM alpine
20+
WORKDIR /app
21+
22+
COPY mailwhale README.md version.txt LICENSE config.yml templates/ ./
23+
COPY --from=ui-build-env /src/public ./webui/public
24+
25+
ENV MW_ENV=prod
26+
ENV MW_WEB_LISTEN_V4=0.0.0.0:3000
27+
ENV MW_STORE_PATH=/data/data.json.db
28+
29+
VOLUME /data
30+
31+
ENTRYPOINT ./mailwhale

README.md

Lines changed: 53 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ As a developer, chances are high that at some point you need to teach your appli
1717
Essentially, there are two options. Either you use a **professional mail sending service** or
1818
you **include an SMTP client library** to your software and **plug your own mail server**.
1919

20-
Think of MailWhale like [Mailgun](https://mailgun.com), [SendGrid](https://sendgrid.com) or [SMTPeter](https://smtpeter.com), but open source and self-hosted. Or like [Postal](https://github.com/postalhq/postal) or [Cuttlefish](https://cuttlefish.io/), but less bloated and without running its own, internal SMTP server.
20+
Think of MailWhale like [Mailgun](https://mailgun.com), [SendGrid](https://sendgrid.com) or [SMTPeter](https://smtpeter.com), but open source and self-hosted. Or like [Postal](https://github.com/postalhq/postal) or [Cuttlefish](https://cuttlefish.io/), but less bloated and without running its own, internal SMTP server.
2121

22-
However, if you want the best of both worlds – that is, send mails via simple HTTP calls and with no extra complexity,
22+
However, if you want the best of both worlds – that is, send mails via simple HTTP calls and with no extra complexity,
2323
but still use your own infrastructure – you may want to go with ✉️🐳.
2424

2525
You get a simple **REST API**, which you can call to send out e-mail. You can plug your self-hosted SMTP server, as well as Google Mail or **literally any other e-mail provider**.
@@ -29,12 +29,15 @@ Stay tuned, there is a lot more to come.
2929
![](assets/screenshot01.png)
3030

3131
## 🚧 Project State
32+
3233
The project is in a very early stage and breaking changes are likely to happen. We'd recommend to not yet use this in production or at least expect non-trivial effort required to upgrade to a new version.
3334

3435
For a more stable and robust alternative to MailWhale, check out [postalsys/emailengine](https://github.com/postalsys/emailengine).
3536

3637
## 📦 Installation
38+
3739
### Compile from source
40+
3841
```bash
3942
# 1. Clone repo
4043
$ git clone https://github.com/muety/mailwhale.git
@@ -54,7 +57,37 @@ $ GO111MODULE=on go build
5457
$ ./mailwhale
5558
```
5659

57-
### With Docker
60+
### From GitHub Release
61+
62+
```bash
63+
# 1. Download latest release
64+
curl -s https://api.github.com/repos/muety/mailwhale/releases/latest | jq -r ".assets[] | select(.name|match(\"Linux_$(arch).tar.gz\")) | .browser_download_url" | wget -qi -
65+
66+
# 2. Extract
67+
mkdir mailwhale
68+
tar xf mailwhale_*.tar.gz -C mailwhale
69+
cd mailwhale
70+
71+
# 3.[Optional] Adapt config to your needs, i.e. set your SMTP server and credentials, etc.
72+
# vi config.yml
73+
74+
# 4. Run it
75+
./mailwhale
76+
```
77+
78+
### With Docker Image
79+
80+
```bash
81+
$ docker run -d \
82+
-p 127.0.0.1:3000:3000 \
83+
-v "$(pwd)/config.yml":/app/config.yml:ro \
84+
-v mailwhale_data:/data \
85+
--name mailwhale \
86+
docker pull ghcr.io/muety/mailwhale
87+
```
88+
89+
### Build custom Docker Image
90+
5891
```bash
5992
# 1. Clone repo
6093
$ git clone https://github.com/muety/mailwhale.git
@@ -78,18 +111,22 @@ $ docker run -d \
78111
mailwhale
79112
```
80113

81-
**Note:** An official Docker image is about to come. Also, there will be no need to mount your config file into the container, as everything will be configurable using environment variables eventually.
114+
**Note:** An official Docker image is about to come. Also, there will be no need to mount your config file into the container, as everything will be configurable using environment variables eventually.
82115

83116
## ⌨️ Usage
84-
First of all, you can get most tasks done through the web UI, available at http://localhost:3000.
117+
118+
First of all, you can get most tasks done through the web UI, available at <http://localhost:3000>.
85119

86120
### 1. Define a user
87-
To get started with MailWhale, you need to create a **user** first. To do so, register a new user API or web UI. `security.allow_signup` needs to be set to `true`.
121+
122+
To get started with MailWhale, you need to create a **user** first. To do so, register a new user API or web UI. `security.allow_signup` needs to be set to `true`.
88123

89124
### 2. Create an API client
90-
It is good practice to not authenticate against the API as a user directly. Instead, create an **API client** with limited privileges, that could easily be revoked in the future. A client is identified by a **client ID** and a **client secret** (or token), very similar to what you might already be familiar with from AWS APIs. Usually, such a client corresponds to an individual client application of yours, which wants to access MailWhale's API.
125+
126+
It is good practice to not authenticate against the API as a user directly. Instead, create an **API client** with limited privileges, that could easily be revoked in the future. A client is identified by a **client ID** and a **client secret** (or token), very similar to what you might already be familiar with from AWS APIs. Usually, such a client corresponds to an individual client application of yours, which wants to access MailWhale's API.
91127

92128
#### Request
129+
93130
```bash
94131
$ curl -XPOST \
95132
-u 'admin@local.host:admin' \
@@ -103,7 +140,8 @@ $ curl -XPOST \
103140
```
104141

105142
#### Response
106-
```
143+
144+
```json
107145
{
108146
"id": "SVNORFBUWGhxWGZSUUl0eA==",
109147
"description": "My juicy web app",
@@ -129,6 +167,7 @@ $ echo "Authorization: Basic $(echo '<client_id>:<client_secret>' | base64)"
129167
### 3. Send E-Mails
130168

131169
#### Plain text or HTML
170+
132171
```bash
133172
$ curl -XPOST \
134173
-u '<client_id>:<client_secret>' \
@@ -144,7 +183,9 @@ $ curl -XPOST \
144183
You can also a `text` field instead, to send a plain text message.
145184

146185
#### Using a template
186+
147187
In case you have created a template using the web UI, you can reference it in a new mail like so:
188+
148189
```bash
149190
$ curl -XPOST \
150191
-u '<client_id>:<client_secret>' \
@@ -161,6 +202,7 @@ $ curl -XPOST \
161202
```
162203

163204
## 🔧 Configuration Options
205+
164206
You can specify configuration options either via a config file (`config.yml`) or via environment variables. Here is an overview of all options.
165207

166208
| YAML Key | Environment Variable | Default | Description |
@@ -184,14 +226,16 @@ You can specify configuration options either via a config file (`config.yml`) or
184226
| `security.block_list` | `MW_SECURITY_BLOCK_LIST` | `[]` | List of [regexes](https://regex101.com/) used to block certain recipient addresses |
185227

186228
### Sender verification & SPF Check
229+
187230
By default, mails are sent using a randomly generated address in the `From` header, which belongs to the domain configured via `mail.domain` (i.e. `user+abcdefgh@wakapi.dev`). Optionally, custom sender addresses can be configured on a per-API-client basis. However, it is recommended to properly configure [SPF](https://en.wikipedia.org/wiki/Sender_Policy_Framework) on that custom domain and instruct MailWhale to verify that configuration.
188231

189232
**As a user**, you need to configure your domain, which you want to use as part of your senders address (e.g. `example.org` for sending mails from `User Server <noreply@example.org>`), to publish an SPF record that delegates to the domain under which MailWhale is running (e.g. mailwhale.dev).
233+
190234
```
191235
example.org. IN TXT v=spf1 include:mailwhale.dev
192236
```
193237

194-
**As a server operator** of a MailWhale instance, you need to enable `mail.verify_senders` and set your `mail.domain` and `web.public_url`. For that domain, you need to configure an SPF record that allows your SMTP relay provider's (e.g. Mailbox.org, GMail, SendGrid, etc.) mail servers to be senders. Refer to your provider's documentation, e.g. [this](https://kb.mailbox.org/display/MBOKBEN/How+to+integrate+external+e-mail+accounts).
238+
**As a server operator** of a MailWhale instance, you need to enable `mail.verify_senders` and set your `mail.domain` and `web.public_url`. For that domain, you need to configure an SPF record that allows your SMTP relay provider's (e.g. Mailbox.org, GMail, SendGrid, etc.) mail servers to be senders. Refer to your provider's documentation, e.g. [this](https://kb.mailbox.org/display/MBOKBEN/How+to+integrate+external+e-mail+accounts).
195239

196240
## 🚀 Features (planned)
197241

0 commit comments

Comments
 (0)