Skip to content

Commit

Permalink
Update documentation (#14)
Browse files Browse the repository at this point in the history
* Update documentation

Move [nextcloud/all-in-one/community-containers/stalwart/upgrading.md](https://github.com/nextcloud/all-in-one/blob/main/community-containers/stalwart/upgrading.md) to [docjyJ/aio-stalwart/README.md](https://github.com/docjyJ/aio-stalwart/blob/main/README.md).

Signed-off-by: Jean-Yves <7360784+docjyJ@users.noreply.github.com>

* Update start.sh

Signed-off-by: Jean-Yves <7360784+docjyJ@users.noreply.github.com>

* Update README.md

Signed-off-by: Jean-Yves <7360784+docjyJ@users.noreply.github.com>

* Update docs

Signed-off-by: Jean-Yves <7360784+docjyJ@users.noreply.github.com>

---------

Signed-off-by: Jean-Yves <7360784+docjyJ@users.noreply.github.com>
  • Loading branch information
docjyJ authored Aug 5, 2024
1 parent 5eca9e5 commit 3f6a64e
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 5 deletions.
94 changes: 92 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,92 @@
# aio-stalwart
StalWart container used in https://github.com/nextcloud/all-in-one/tree/main/community-containers/stalwart
> [!WARNING]
> Stalwart and nextcloud community containers are solutions under development.
>
> Additionally, hosting your own mail server is one of the most difficult services to deploy.
>
> I try my best to make this as simple as possible. This solution is quite stable (I use it for my cloud) but it is not enterprise quality.
>
> If you have any suggestions, questions or want to report a bug, [open an issue](https://github.com/docjyj/aio-stalwart/issues)!
# Stalwart community container for Nextcloud All-in-one

This container is used in [Nextcloud All-in-one](https://github.com/nextcloud/all-in-one/tree/main/community-containers/stalwart) to provide a mail server.

Compared to a default Stalwart container, this container allows:
- Automatically configures a mail server and *(In progress) tutorials for actions need to be done manually and advanced feature*.
- Compatible with Nextcloud AIO backups.
- *(Planned) Synchronization of Nextcloud and Stalwart accounts.*

## Getting started

### Prerequisites

1. You will run this container on a server with a static IP address.
2. Make sure than port `25`, `465`, `993`, `4190` and `10003` are not used by another programme. (Use `sudo netstat -tulpn` to list all used ports).
3. You have deployed the [caddy community container](https://github.com/nextcloud/all-in-one/tree/main/community-containers/caddy) as reverse proxy. (Other solutions are possible, see: [Use your own reverse proxy](#use-your-own-reverse-proxy)).

### Installation

See [how to use community containers](https://github.com/nextcloud/all-in-one/tree/main/community-containers#how-to-use-this).

After installation on nextcloud go to `https://mail.$NC_DOMAIN/login` and login with the following credentials:
- Username: `admin`
- Password: get with the command `docker inspect nextcloud-aio-stalwart | grep STALWART_USER_PASS`

Once connected, add a domain, configure your DNS zone and create your users.

## Advanced configuration

### Use your own reverse proxy

You need to redirect http (or https) traffic from `mail.$NC_DOMAIN` to port `10003` of the `nextcloud-aio-stalwart` container in `http`.

**Then add your own certificate.** See : [Use your own certificate](#use-your-own-certificate)

Example with `Caddyfile` syntax:
```caddyfile
https://mail.{$NC_DOMAIN}:443 {
reverse_proxy http://{$STALWAER_IP}:10003
}
```

### Use your own certificate

Please add a certificate in volume `nextcloud_aio_caddy` in this path:
- `$VOLUME_ROOT/caddy/certificates/acme-v02.api.letsencrypt.org-directory/mail.$NC_DOMAIN/mail.$NC_DOMAIN.key`
- `$VOLUME_ROOT/caddy/certificates/acme-v02.api.letsencrypt.org-directory/mail.$NC_DOMAIN/mail.$NC_DOMAIN.crt`

If you're using caddy, you can mount the volume `nextcloud_aio_caddy` your caddy container and add this [storage global directive](https://caddyserver.com/docs/caddyfile/options#storage):
```caddyfile
{
storage file_system {$VOLUME_ROOT}/caddy
}
```

## Upgrading
> [!NOTE]
> Unless the starting script tells you, you have no action to do to update.
See https://github.com/stalwartlabs/mail-server/blob/main/UPGRADING.md

During a major server update, this message will be displayed:

```
Your data is in an old format.
Make a backup and see https://github.com/docjyJ/aio-stalwart#Upgrading
To avoid any loss of data, Stalwart will not launch.
```

> [!CAUTION]
> Before each update don't forget to make a backup.
### Upgrading from 0.7.x to 0.8.x

Run the script [`update_0.7_to_0.8.sh`](https://github.com/docjyJ/aio-stalwart/blob/main/scripts/update_0.7_to_0.8.sh) to update the data.

Please before upgrading, do a backup of your data !

If you're using the root user to run docker, read the script before running it.

```bash
curl -s https://raw.githubusercontent.com/docjyJ/aio-stalwart/main/scripts/backup.sh | bash
```
3 changes: 1 addition & 2 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ level = "info"
ansi = false
enable = true

[lookup."nextcloud-aio"]
domain = "%{env:NC_DOMAIN}%"
[lookup.default]
hostname = "mail.%{env:NC_DOMAIN}%"

[certificate.nextcloud-aio]
Expand Down
10 changes: 10 additions & 0 deletions script/update_0.7_to_0.8.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
echo -e '\033[0;31m WARNING: Please go in your AIO interface and backup your data before running this script. \033[0m'
read -p "Are-you sure you want to continue? (y/n) " -n 1 -r
echo -e '\n'
if [[ $REPLY =~ ^[Yy]$ ]]
then
docker stop nextcloud-aio-stalwart
docker run --rm -v nextcloud_aio_stalwart:/opt/stalwart-mail -it --entrypoint /bin/bash stalwartlabs/mail-server:v0.7.3 -c 'stalwart-mail --config /opt/stalwart-mail/etc/config.toml --export /opt/stalwart-mail/export'
docker run --rm -v nextcloud_aio_stalwart:/opt/stalwart-mail -it --entrypoint /bin/bash stalwartlabs/mail-server:v0.8.0 -c 'stalwart-mail --config /opt/stalwart-mail/etc/config.toml --import /opt/stalwart-mail/export && echo "0.8.0" > /opt/stalwart-mail/aio.lock'
fi
echo 'Finished'
2 changes: 1 addition & 1 deletion start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ DATA_VERSION="0.8.0"
if [ -f "$AIO_LOCK" ]; then
if [ "$DATA_VERSION" != "$(cat "$AIO_LOCK")" ]; then
echo "Your data is in an old format."
echo "Make a backup and see https://github.com/nextcloud/all-in-one/blob/main/community-containers/stalwart/upgrading.md"
echo "Make a backup and see https://github.com/docjyJ/aio-stalwart#Upgrading"
echo "To avoid any loss of data, Stalwart will not launch."
exit 1
fi
Expand Down

0 comments on commit 3f6a64e

Please sign in to comment.