Skip to content

Commit

Permalink
chore: add maildump in the docker environment
Browse files Browse the repository at this point in the history
  • Loading branch information
azmeuk committed Feb 12, 2025
1 parent 46ea884 commit 41ca556
Show file tree
Hide file tree
Showing 12 changed files with 103 additions and 55 deletions.
92 changes: 43 additions & 49 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,12 @@ Development environment

You can either run the demo locally or with Docker.

The only tool required for local development is `uv`.
Make sure to have uv `installed on your computer <https://docs.astral.sh/uv/getting-started/installation/>`_
to be able to hack Canaille.

Initialize your development environment with:

- ``uv sync --extra front --extra oidc`` to have a minimal working development environment. This will allow you to run the tests with ``uv pytest --backend memory``.
- ``uv sync --extra front --extra oidc --extra sqlite`` to have a minimal working development environment with SQLite backend support. This will allow you to run the tests with ``uv pytest --backend sql``.
- ``uv sync --extra front --extra oidc --extra ldap`` to have a minimal working development environment with LDAP backend support. This will allow you to run the tests with ``uv pytest --backend ldap``.
- ``uv sync --all-extras`` if you want to have everything at your fingertips. Note that it may compile some Python dependencies that would expect things to be installed on your system;
Some dependencies of Canaille might need to be compiled, so you probably want to check that `GCC` and `cargo` are available on your computer.

After having launched the demo you have access to several services:

- A canaille server at `localhost:5000 <http://localhost:5000>`__
- A dummy client at `localhost:5001 <http://localhost:5001>`__
- Another dummy client at `localhost:5002 <http://localhost:5002>`__
- A mail catcher at `localhost:1080 <http://localhost:1080>`__
- A canaille server at `canaille.localhost:5000 <http://canaille.localhost:5000>`__
- A dummy client at `client1.localhost:5001 <http://client1.localhost:5001>`__
- Another dummy client at `client2.localhost:5002 <http://client2.localhost:5002>`__
- A mail catcher at `maildump.localhost:1080 <http://maildump.localhost:1080>`__

The canaille server has some default users:

Expand All @@ -54,14 +42,22 @@ Canaille comes with several backends:
- a `sql` backend, based on sqlalchemy
- a production-ready `LDAP` backend

Docker environment
~~~~~~~~~~~~~~~~~~
.. _local_environment:

When launching Canaille with Docker, you have access to:
Local environment
~~~~~~~~~~~~~~~~~

- A canaille server at `canaille.localhost:5000 <http://canaille.localhost:5000>`__
- A dummy client at `client1.localhost:5001 <http://client1.localhost:5001>`__
- Another dummy client at `client2.localhost:5002 <http://client2client2..localhost:5002>`__
The only tool required for local development is `uv`.
Make sure to have uv `installed on your computer <https://docs.astral.sh/uv/getting-started/installation/>`_
to be able to hack Canaille.

Initialize your development environment with:

- ``uv sync --extra front --extra oidc`` to have a minimal working development environment. This will allow you to run the tests with ``uv pytest --backend memory``.
- ``uv sync --extra front --extra oidc --extra sqlite`` to have a minimal working development environment with SQLite backend support. This will allow you to run the tests with ``uv pytest --backend sql``.
- ``uv sync --extra front --extra oidc --extra ldap`` to have a minimal working development environment with LDAP backend support. This will allow you to run the tests with ``uv pytest --backend ldap``.
- ``uv sync --all-extras`` if you want to have everything at your fingertips. Note that it may compile some Python dependencies that would expect things to be installed on your system;
Some dependencies of Canaille might need to be compiled, so you probably want to check that `GCC` and `cargo` are available on your computer.

SQL
^^^
Expand All @@ -70,8 +66,7 @@ With the SQL backend, the demo instance will load and save data in a local sqlit
.. code-block:: console
:caption: Run the demo instance with the SQL backend
cd demo
docker compose up
./demo/run.sh
Memory
^^^^^^
Expand All @@ -80,8 +75,7 @@ With the memory backend, all data is lost when Canaille stops.
.. code-block:: console
:caption: Run the demo instance with the memory backend
cd demo
docker compose --file docker-compose-memory.yml up
./demo/run.sh --backend memory
LDAP
^^^^
Expand All @@ -90,13 +84,25 @@ With the LDAP backend, all data is lost when Canaille stops.
.. code-block:: console
:caption: Run the demo instance with the LDAP backend
cd demo
docker compose --file docker-compose-ldap.yml up
./demo/run.sh --backend ldap
.. _local_environment:
.. note ::
If you want to run the demo locally with the LDAP backend, you need to have
`OpenLDAP <https://www.openldap.org/>`_ installed on your system.
It is generally shipped under the ``slapd`` or ``openldap`` package name.
Local environment
~~~~~~~~~~~~~~~~~
.. warning ::
On Debian or Ubuntu systems, the OpenLDAP `slapd` binary usage might be restricted by apparmor,
and thus makes the tests and the demo fail. This can be mitigated by removing apparmor restrictions
on `slapd`.
.. code-block:: console
sudo apt install --yes apparmor-utils
sudo aa-complain /usr/sbin/slapd
Docker environment
~~~~~~~~~~~~~~~~~~

SQL
^^^
Expand All @@ -105,7 +111,8 @@ With the SQL backend, the demo instance will load and save data in a local sqlit
.. code-block:: console
:caption: Run the demo instance with the SQL backend
./demo/run.sh
cd demo
docker compose up
Memory
^^^^^^
Expand All @@ -114,7 +121,8 @@ With the memory backend, all data is lost when Canaille stops.
.. code-block:: console
:caption: Run the demo instance with the memory backend
./demo/run.sh --backend memory
cd demo
docker compose --file docker-compose-memory.yml up
LDAP
^^^^
Expand All @@ -123,22 +131,8 @@ With the LDAP backend, all data is lost when Canaille stops.
.. code-block:: console
:caption: Run the demo instance with the LDAP backend
./demo/run.sh --backend ldap
.. note ::
If you want to run the demo locally with the LDAP backend, you need to have
`OpenLDAP <https://www.openldap.org/>`_ installed on your system.
It is generally shipped under the ``slapd`` or ``openldap`` package name.
.. warning ::
On Debian or Ubuntu systems, the OpenLDAP `slapd` binary usage might be restricted by apparmor,
and thus makes the tests and the demo fail. This can be mitigated by removing apparmor restrictions
on `slapd`.
.. code-block:: console
sudo apt install --yes apparmor-utils
sudo aa-complain /usr/sbin/slapd
cd demo
docker compose --file docker-compose-ldap.yml up
Populate the database
~~~~~~~~~~~~~~~~~~~~~
Expand Down
9 changes: 9 additions & 0 deletions demo/Dockerfile-maildump
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM python:slim

RUN \
apt update && \
apt --yes upgrade

RUN pip install maildump

ENTRYPOINT ["maildump", "--http-ip", "0.0.0.0", "--smtp-ip", "0.0.0.0"]
4 changes: 4 additions & 0 deletions demo/conf-docker/canaille-ldap.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ FAVICON = "/static/img/canaille-c.webp"
ENABLE_REGISTRATION = true
ADMIN_EMAIL = "admin@example.org"

[CANAILLE.SMTP]
HOST = "maildump.localhost"
PORT = 1025

[CANAILLE.ACL.DEFAULT]
PERMISSIONS = ["edit_self", "use_oidc"]
READ = [
Expand Down
5 changes: 4 additions & 1 deletion demo/conf-docker/canaille-memory.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ SERVER_NAME = "canaille.localhost"
[CANAILLE]
LOGO = "/static/img/canaille-head.webp"
FAVICON = "/static/img/canaille-c.webp"
EMAIL_CONFIRMATION = false
ENABLE_REGISTRATION = true
ADMIN_EMAIL = "admin@example.org"

[CANAILLE.SMTP]
HOST = "maildump.localhost"
PORT = 1025

[CANAILLE.ACL.DEFAULT]
PERMISSIONS = ["edit_self", "use_oidc"]
READ = [
Expand Down
5 changes: 4 additions & 1 deletion demo/conf-docker/canaille-sql.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ SERVER_NAME = "canaille.localhost"
[CANAILLE]
LOGO = "/static/img/canaille-head.webp"
FAVICON = "/static/img/canaille-c.webp"
EMAIL_CONFIRMATION = false
ENABLE_REGISTRATION = true
ADMIN_EMAIL = "admin@example.org"

[CANAILLE.SMTP]
HOST = "maildump.localhost"
PORT = 1025

[CANAILLE.ACL.DEFAULT]
PERMISSIONS = ["edit_self", "use_oidc"]
READ = [
Expand Down
3 changes: 1 addition & 2 deletions demo/conf/canaille-ldap.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ SERVER_NAME = "canaille.localhost"
[CANAILLE]
LOGO = "/static/img/canaille-head.webp"
FAVICON = "/static/img/canaille-c.webp"
EMAIL_CONFIRMATION = false
ENABLE_REGISTRATION = true
ADMIN_EMAIL = "admin@example.org"

[CANAILLE.SMTP]
HOST = "localhost"
HOST = "maildump.localhost"
PORT = 1025

[CANAILLE.ACL.DEFAULT]
Expand Down
2 changes: 1 addition & 1 deletion demo/conf/canaille-memory.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ENABLE_REGISTRATION = true
ADMIN_EMAIL = "admin@example.org"

[CANAILLE.SMTP]
HOST = "localhost"
HOST = "maildump.localhost"
PORT = 1025

[CANAILLE.ACL.DEFAULT]
Expand Down
2 changes: 1 addition & 1 deletion demo/conf/canaille-sql.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ENABLE_REGISTRATION = true
ADMIN_EMAIL = "admin@example.org"

[CANAILLE.SMTP]
HOST = "localhost"
HOST = "maildump.localhost"
PORT = 1025

[CANAILLE.ACL.DEFAULT]
Expand Down
9 changes: 9 additions & 0 deletions demo/docker-compose-ldap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,12 @@ services:
command: --port=5002
ports:
- 5002:5002

maildump:
hostname: maildump.localhost
build:
context: ..
dockerfile: demo/Dockerfile-maildump
ports:
- 1025:1025
- 1080:1080
9 changes: 9 additions & 0 deletions demo/docker-compose-memory.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,12 @@ services:
command: --port=5002
ports:
- 5002:5002

maildump:
hostname: maildump.localhost
build:
context: ..
dockerfile: demo/Dockerfile-maildump
ports:
- 1025:1025
- 1080:1080
9 changes: 9 additions & 0 deletions demo/docker-compose-sql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,12 @@ services:
command: --port=5002
ports:
- 5002:5002

maildump:
hostname: maildump.localhost
build:
context: ..
dockerfile: demo/Dockerfile-maildump
ports:
- 1025:1025
- 1080:1080
9 changes: 9 additions & 0 deletions demo/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,12 @@ services:
command: --port=5002
ports:
- 5002:5002

maildump:
hostname: maildump.localhost
build:
context: ..
dockerfile: demo/Dockerfile-maildump
ports:
- 1025:1025
- 1080:1080

0 comments on commit 41ca556

Please sign in to comment.