Skip to content

Commit

Permalink
Fix up postgres database support
Browse files Browse the repository at this point in the history
Add a postgres service to the docker-compose file for convenience
  • Loading branch information
anoadragon453 committed Jul 3, 2020
1 parent 3af651f commit ed3e118
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
24 changes: 20 additions & 4 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ differences:
database: "postgres://username:password@postgres/matrix-reminder-bot?sslmode=disable"
```

**Note:** a postgres container is defined in `docker-compose.yaml` for your convenience.
If you would like to use it, set your database connection string to:

```
database: "postgres://postgres:matrixreminderbot@postgres/postgres?sslmode=disable"
```

Change any other config values as necessary. For instance, you may also want to
store log files in the `/data` directory.

Expand All @@ -57,23 +64,32 @@ docker volume create \
--opt device="/path/to/data/dir" data_volume
```

Run the following to start the bot:
If you want to use the postgres container defined in `docker-compose.yaml`, start that
first:

```
docker-compose up -d postgres
```

Start the bot with:

```
docker-compose up matrix-reminder-bot
```

This will start the bot and log the bot's output. You can instead run the container detached
with the `-d` flag:
This will run the bot and log the output to the terminal. You can instead run
the container detached with the `-d` flag:

```
docker-compose up -d matrix-reminder-bot
```

(Logs can later be accessed with the `docker logs` command).

This will use the `matrix-reminder-bot:latest` tag from
[Docker Hub](https://hub.docker.com/anoa/matrix-reminder-bot).

If you would rather run from the checked out code, you can run:
If you would rather run from the checked out code, you can use:

```
docker-compose up local-checkout
Expand Down
13 changes: 12 additions & 1 deletion docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
version: '3' # specify docker-compose version
version: '3.1' # specify docker-compose version

volumes:
# Set up with `docker volume create ...`. See docker/README.md for more info.
data_volume:
external: true
pg_data_volume:

services:
# Runs from the latest release
matrix-reminder-bot:
image: anoa/matrix-reminder-bot
restart: always
volumes:
- data_volume:/data
# Used for allowing connections to homeservers hosted on the host machine
Expand All @@ -34,3 +36,12 @@ services:
# Defaults to 127.0.0.1 and is set in docker/.env
extra_hosts:
- "localhost:${HOST_IP_ADDRESS}"

# Starts up a postgres database
postgres:
image: postgres
restart: always
volumes:
- pg_data_volume:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: matrixreminderbot

0 comments on commit ed3e118

Please sign in to comment.