docker: Add postgres docker build with full text search.

This is multi-stage build which first builds tsearch-extras with the
current version of postgres and then configs postgres for zulip. The
zulip config installs the hunspell dictionaries, stop words file,
tsearch-extras, and creates the initial database.

**Testing Plan:**
1) `docker-compose up` the existing config.
2) Build the new image
3) Edit docker-compose.yml to use the new image id
4) `docker-compose up` and verify full text search is still working.
This commit is contained in:
Jason Michalski
2018-05-15 16:04:50 -07:00
committed by Tim Abbott
parent 495104bd56
commit 24fbd7205d
3 changed files with 59 additions and 7 deletions

View File

@@ -0,0 +1,21 @@
#!/bin/bash
set -e
set -x
# Make sure the current working directory is readable
cd /
DATABASE_CREATE="
CREATE USER zulip;
ALTER ROLE zulip SET search_path TO zulip,public;
CREATE DATABASE zulip OWNER=zulip;
\\connect zulip
CREATE SCHEMA zulip AUTHORIZATION zulip;
CREATE EXTENSION tsearch_extras SCHEMA zulip;
"
if [ -f /.dockerenv ]; then
echo "$DATABASE_CREATE" | psql
else
echo "$DATABASE_CREATE" | su postgres -c psql
fi