Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

♻️ refact(docker): Remove docker compose version #4

Merged
merged 1 commit into from
Oct 7, 2022
Merged
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
data/mosquitto.db
log/mosquitto.log
config/mosquitto.conf
config/password.txt
40 changes: 25 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,63 @@
# Simple Mosquitto broker

![Mosquitto Logo](https://mosquitto.org/images/mosquitto-text-side-28.png 'Mosquitto')

# Simple Mosquitto broker
This is a simple [Mosquitto](https://mosquitto.org) broker to quickly initialize projects requiring an MQTT broker.

This is a simple [Mosquitto](https://mosquitto.org) broker to to quickly initialize projects requiring an MQTT broker. The config file is in the folder `config/mosquitto.conf`.
## Prerequisite

By default we activated the log and data persistance (respectively in `log` and `data` folder).
The authentication can be activated if needed.
- [Docker](https://www.docker.com/)
- [Docker compose](https://docs.docker.com/compose/) +v1.27.0 (better to have v2)

# How to use
## How to use

To start the container, just :

```
docker-compose up -d
```bash
UID=$UID GID=$GID docker-compose up -d
```

The Mosquitto broker is now available on localhost. You can test it easily (require Mosquitto client):

| In one shell:

```
```bash
mosquitto_sub -h localhost -t "sensor/temperature"
```

| In a second shell:

```
```bash
mosquitto_pub -h localhost -t sensor/temperature -m 23
```

# Enabling authentication
## Configuration

The config file is in the file [mosquito.conf](./config/mosquitto.conf)

By default we activated the log and data persistance (logs are in the `log` folder, and data are stored in a docker voume).

## Authentication

### Enable authentication

In the config file, just uncomment the `Authentication` part and then restart the container.
The default user is `admin/password`.

**You always have to restart if you want the modification to be taken in account:**

```
```bash
docker-compose restart
```

## Change user password / create a new user:
### Change user password / create a new user

```
```bash
docker-compose exec mosquitto mosquitto_passwd -b /mosquitto/config/password.txt user password
```

## Delete user:
### Delete user

```
```bash
docker-compose exec mosquitto mosquitto_passwd -D /mosquitto/config/password.txt user
```
9 changes: 6 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
version: "3"

services:
mosquitto:
image: eclipse-mosquitto:1.6
volumes:
- ./:/mosquitto/:rw
- ./config/:/mosquitto/config/:ro
- ./log/:/mosquito/log/
- data:/mosquito/data/
ports:
- 1883:1883
- 9001:9001

volumes:
data: ~
Empty file added log/.gitkeep
Empty file.