diff --git a/CHANGELOG.md b/CHANGELOG.md index f9fd989..c63cb2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +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. +* Create environment variables for database settings. It is now possible to use MariaDB or Postgres instead of SQLite. SQLite is the default. ## v1.1.4 diff --git a/Dockerfile b/Dockerfile index 6c7c2ce..a42e676 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,13 +27,15 @@ RUN apt-get update \ && DEBIAN_FRONTEND=noninteractive apt-get install -y \ libevent-dev `# this is no build dependency, but needed for luaevent` \ libidn11 \ + libpq-dev \ + libsqlite3-0 \ lua5.2 \ lua-bitop \ + lua-dbi-mysql \ lua-expat \ lua-filesystem \ lua-socket \ lua-sec \ - sqlite3 \ wget \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* @@ -65,6 +67,8 @@ RUN buildDeps='gcc git libc6-dev libidn11-dev liblua5.2-dev libsqlite3-dev libss \ && luarocks install luaevent \ && luarocks install luadbi \ + `#&& luarocks install luadbi-mysql MYSQL_INCDIR=/usr/include/mariadb/` \ + && luarocks install luadbi-postgresql POSTGRES_INCDIR=/usr/include/postgresql/ \ && luarocks install luadbi-sqlite3 \ && luarocks install stringy \ \ diff --git a/conf.d/02-storage.cfg.lua b/conf.d/02-storage.cfg.lua index 175fb3a..549573a 100644 --- a/conf.d/02-storage.cfg.lua +++ b/conf.d/02-storage.cfg.lua @@ -1,21 +1,13 @@ default_storage = "sql" --- TODO change if ---if DB_DRIVER then - sql = { - 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 +sql = { + driver = os.getenv("DB_DRIVER"); + database = os.getenv("DB_DATABASE"); + host = os.getenv("DB_HOST"); + port = os.getenv("DB_PORT"); + username = os.getenv("DB_USERNAME"); + password = os.getenv("DB_PASSWORD"); +} -- make 0.10-distributed mod_mam use sql store archive_store = "archive2" -- Use the same data store as prosody-modules mod_mam diff --git a/readme.md b/readme.md index 6f5210e..55c93ad 100644 --- a/readme.md +++ b/readme.md @@ -194,12 +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| +| **DB_DRIVER** | May also be "PostgreSQL" or "MySQL" or "SQLite3" (case sensitive!) | *optional* | SQLite3 | +| **DB_DATABASE** | The database name to use. For SQLite3 this the database filename (relative to the data storage directory). | *optional* | prosody.sqlite | +| **DB_HOST** | The address of the database server | *optional* | | +| **DB_PORT** | Port on which the database is listening | *optional* | | +| **DB_USERNAME** | The username to authenticate to the database | *optional* | | +| **DB_PASSWORD** | The password to authenticate to the database | *optional* | | | **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* | "" | diff --git a/tests/docker-compose.yml b/tests/docker-compose.yml index dede8cb..b978757 100644 --- a/tests/docker-compose.yml +++ b/tests/docker-compose.yml @@ -15,8 +15,13 @@ services: E2E_POLICY_WHITELIST: "admin@localhost, user1@localhost" LOG_LEVEL: debug PROSODY_ADMINS: "admin@localhost, admin2@localhost" - #DB_DRIVER: "SQLite3" - #DB_DATABASE: "prosody.sqlite" + #DB_DRIVER: "MySQL" + #DB_DRIVER: "PostgreSQL" + #DB_DATABASE: "prosody" + #DB_HOST: "postgres" + #DB_PORT: "5432" + #DB_USERNAME: "prosody" + #DB_PASSWORD: "prosody" extra_hosts: - "conference.localhost:127.0.0.1" - "pubsub.localhost:127.0.0.1" diff --git a/tests/test.bash b/tests/test.bash index 75048cd..2cd3ae4 100755 --- a/tests/test.bash +++ b/tests/test.bash @@ -21,7 +21,10 @@ generateCert "proxy.localhost" generateCert "pubsub.localhost" generateCert "upload.localhost" +# Start postgres first and wait for 10 seconds before starting prosody. sudo docker-compose down \ +&& sudo docker-compose up -d postgres \ +&& sleep 10 \ && sudo docker-compose up -d \ \ && sudo docker exec tests_prosody_1 /bin/bash -c "/entrypoint.sh register admin localhost 12345678" \