WIP Add environment variables for Database configuration. TODO test it with postgres

This commit is contained in:
Sara Aimée Smiseth 2021-05-01 13:04:23 +02:00
parent 5bcf0fd3d0
commit d3f5a603e5
6 changed files with 45 additions and 7 deletions

View file

@ -3,6 +3,7 @@
## Unreleased
* Updated luarocks to version 3.7.0.
* Create environment variables for database settings. It is now possible to use MariaDB or Postgres instead of SQLite.
## v1.1.4

View file

@ -1,8 +1,21 @@
default_storage = "sql"
-- TODO change if
--if DB_DRIVER then
sql = {
driver = "SQLite3";
database = "prosody.sqlite";
driver = os.getenv("DB_DRIVER"); -- May also be "PostgreSQL" or "MySQL" or "SQLite3" (case sensitive!)
database = os.getenv("DB_DATABASE"); -- The database name to use. For SQLite3 this the database filename (relative to the data storage directory).
host = os.getenv("DB_HOST"); -- The address of the database server (delete this line for Postgres)
port = os.getenv("DB_PORT"); -- 3306 - For databases connecting over TCP
username = os.getenv("DB_USERNAME"); -- The username to authenticate to the database
password = os.getenv("DB_PASSWORD"); -- The password to authenticate to the database
}
--else
--sql = {
--driver = "SQLite3";
--database = "prosody.sqlite";
--}
--end
-- make 0.10-distributed mod_mam use sql store
archive_store = "archive2" -- Use the same data store as prosody-modules mod_mam

View file

@ -21,6 +21,10 @@ export SERVER_CONTACT_INFO_SECURITY=${SERVER_CONTACT_INFO_SECURITY:-"xmpp:securi
export SERVER_CONTACT_INFO_SUPPORT=${SERVER_CONTACT_INFO_SUPPORT:-"xmpp:support@$DOMAIN"}
export PROSODY_ADMINS=${PROSODY_ADMINS:-""}
# TODO sort into above
export DB_DRIVER=${DB_DRIVER:-"SQLite3"}
export DB_DATABASE=${DB_DATABASE:-"prosody.sqlite"}
if [[ "$1" != "prosody" ]]; then
exec prosodyctl $*
exit 0;

View file

@ -194,6 +194,12 @@ Inspect logs: ```docker-compose logs -f```.
| **DOMAIN_MUC** | Domain for Multi-user chat (MUC) for allowing you to create hosted chatrooms/conferences for XMPP users | *optional* | conference.**DOMAIN** |
| **DOMAIN_PROXY** | Domain for SOCKS5 bytestream proxy for server-proxied file transfers | *optional* | proxy.**DOMAIN** |
| **DOMAIN_PUBSUB** | Domain for a XEP-0060 pubsub service | *optional* | pubsub.**DOMAIN** |
|**DB_DRIVER** | May also be "PostgreSQL" or "MySQL" or "SQLite3" (case sensitive!)|
|**DB_DATABASE** | The database name to use. For SQLite3 this the database filename (relative to the data storage directory).|
|**DB_HOST** | The address of the database server (delete this line for Postgres)|
|**DB_PORT** | 3306 - For databases connecting over TCP|
|**DB_USERNAME** | The username to authenticate to the database|
|**DB_PASSWORD** | The password to authenticate to the database|
| **E2E_POLICY_CHAT** | Policy for chat messages. Possible values: "none", "optional" and "required". | *optional* | "required" |
| **E2E_POLICY_MUC** | Policy for MUC messages. Possible values: "none", "optional" and "required". | *optional* | "required" |
| **E2E_POLICY_WHITELIST** | Make this module ignore messages sent to and from this JIDs or MUCs. | *optional* | "" |

View file

@ -15,6 +15,8 @@ services:
E2E_POLICY_WHITELIST: "admin@localhost, user1@localhost"
LOG_LEVEL: debug
PROSODY_ADMINS: "admin@localhost, admin2@localhost"
#DB_DRIVER: "SQLite3"
#DB_DATABASE: "prosody.sqlite"
extra_hosts:
- "conference.localhost:127.0.0.1"
- "pubsub.localhost:127.0.0.1"
@ -22,3 +24,15 @@ services:
- "upload.localhost:127.0.0.1"
volumes:
- ./certs:/usr/local/etc/prosody/certs
depends_on:
- postgres
postgres:
image: postgres:13-alpine
restart: unless-stopped
environment:
POSTGRES_DB: prosody
POSTGRES_USER: prosody
POSTGRES_PASSWORD: prosody
#volumes:
#- ./postgres-data:/var/lib/postgresql/data

View file

@ -1,3 +1,3 @@
aioxmpp==0.11.0
pip-chill==1.0.0
pytest-asyncio==0.14.0
aioxmpp==0.12.2
pip-chill==1.0.1
pytest-asyncio==0.15.1