docker compose updates; option not to replicate

pull/73/head
Christopher Usher 5 years ago
parent 38801ea6d3
commit 0eefdb94e0

@ -7,7 +7,7 @@
// Change these to configure the services. // Change these to configure the services.
// Image tag (application version) to use. // Image tag (application version) to use.
// Note: "latest" is not reccomended in production, as you can't be sure what version // Note: "latest" is not recommended in production, as you can't be sure what version
// you're actually running, and must manually re-pull to get an updated copy. // you're actually running, and must manually re-pull to get an updated copy.
image_tag:: "latest", image_tag:: "latest",
@ -33,8 +33,11 @@
// On OSX you need to change this to /private/var/lib/wubloader // On OSX you need to change this to /private/var/lib/wubloader
segments_path:: "/var/lib/wubloader/", segments_path:: "/var/lib/wubloader/",
// Local path to save database to. Full path must already exist. Cannot contain ':'. // Local path to save database to. Full path must already exist. Cannot
database_path:: "/var/lib/wubloader_postgres/", // contain ':'. If this directory is non-empty, the database will start with
// the database in this directory and not run the setup scripts to create a
// new database.
database_path:: "/private/var/lib/wubloader_postgres/",
// The host's port to expose each service on. // The host's port to expose each service on.
// Only nginx (and postgres if that is being deployed) needs to be externally accessible - the other non-database ports are routed through nginx. // Only nginx (and postgres if that is being deployed) needs to be externally accessible - the other non-database ports are routed through nginx.
@ -53,21 +56,27 @@
// You can exec into the container and telnet to this port to get a python shell. // You can exec into the container and telnet to this port to get a python shell.
backdoor_port:: 1234, backdoor_port:: 1234,
// Other nodes to backfill from. You should not include the local node. // Other nodes to always backfill from. You should not include the local node.
peers:: [ peers:: [
"http://wubloader.codegunner.com/"
], ],
// Connection args for the database. // Connection args for the database.
// If database is defined in this config, host and port should be postgres:5432. // If database is defined in this config, host and port should be postgres:5432.
db_args:: { db_args:: {
user: "postgres", user: "vst",
password: "postgres", password: "dbfh2019", // don't use default in production
host: "postgres", host: "postgres",
port: 5432, port: 5432,
dbname: "wubloader", dbname: "wubloader",
}, },
// Other database arguments
db_super_user:: "postgres", // only accessible from localhost
db_super_password:: "postgres",
db_replication_user:: "replicate", // if empty, don't allow replication
db_replication_password:: "standby", // don't use default in production
db_standby:: false, // set to true to have this database replicate another server
// Path to a JSON file containing google credentials as keys // Path to a JSON file containing google credentials as keys
// 'client_id', 'client_secret' and 'refresh_token'. // 'client_id', 'client_secret' and 'refresh_token'.
google_creds:: "./google_creds.json", google_creds:: "./google_creds.json",
@ -137,7 +146,7 @@
"--qualities", std.join(",", $.qualities), "--qualities", std.join(",", $.qualities),
"--static-nodes", std.join(",", $.peers), "--static-nodes", std.join(",", $.peers),
"--backdoor-port", std.toString($.backdoor_port), "--backdoor-port", std.toString($.backdoor_port),
"--node-database", $.db_connect, "--node-database", $.db_connect,
], ],
// Mount the segments directory at /mnt // Mount the segments directory at /mnt
volumes: ["%s:/mnt" % $.segments_path], volumes: ["%s:/mnt" % $.segments_path],
@ -231,14 +240,22 @@
}, },
[if $.enabled.postgres then "postgres"]: { [if $.enabled.postgres then "postgres"]: {
image: "postgres:latest", image: "quay.io/ekimekim/wubloader-postgres:%s" % $.image_tag,
restart: "on-failure", restart: "on-failure",
[if "postgres" in $.ports then "ports"]: ["%s:5432" % $.ports.postgres], [if "postgres" in $.ports then "ports"]: ["%s:5432" % $.ports.postgres],
environment: { environment: {
POSTGRES_USER: $.db_args.user, POSTGRES_USER: $.db_super_user,
POSTGRES_PASSWORD: $.db_args.password, POSTGRES_PASSWORD: $.db_super_password,
POSTGRES_DB: $.db_args.dbname, POSTGRES_DB: $.db_args.dbname,
PGDATA: "/mnt",
WUBLOADER_USER: $.db_args.user,
WUBLOADER_PASSWORD: $.db_args.password,
REPLICATION_USER: $.db_replication_user,
REPLICATION_PASSWORD: $.db_replication_password,
MASTER_NODE: $.db_args.host,
}, },
volumes: ["%s:/mnt" % $.database_path],
[if $.db_standby then "command"]: ["/standby_setup.sh"],
}, },
}, },

@ -3,17 +3,26 @@
set -e set -e
sed -i "/host all all all/d" "$PGDATA/pg_hba.conf" sed -i "/host all all all/d" "$PGDATA/pg_hba.conf"
echo "host replication $REPLICATION_USER all md5" >> "$PGDATA/pg_hba.conf"
echo "host all $WUBLOADER_USER all md5" >> "$PGDATA/pg_hba.conf" echo "host all $WUBLOADER_USER all md5" >> "$PGDATA/pg_hba.conf"
echo "Creating $WUBLOADER_USER"
psql -v ON_ERROR_STOP=1 -U postgres <<-EOSQL psql -v ON_ERROR_STOP=1 -U postgres <<-EOSQL
CREATE USER $WUBLOADER_USER LOGIN PASSWORD '$WUBLOADER_PASSWORD'; CREATE USER $WUBLOADER_USER LOGIN PASSWORD '$WUBLOADER_PASSWORD';
EOSQL
if [ -n "$REPLICATION_USER" ]; then
echo "Creating $REPLICATION_USER"
echo "host replication $REPLICATION_USER all md5" >> "$PGDATA/pg_hba.conf"
psql -v ON_ERROR_STOP=1 -U postgres <<-EOSQL
CREATE USER $REPLICATION_USER LOGIN REPLICATION PASSWORD '$REPLICATION_PASSWORD'; CREATE USER $REPLICATION_USER LOGIN REPLICATION PASSWORD '$REPLICATION_PASSWORD';
EOSQL EOSQL
cat >> ${PGDATA}/postgresql.conf <<EOF cat >> ${PGDATA}/postgresql.conf <<EOF
wal_level = replica wal_level = replica
archive_mode = on archive_mode = on
@ -22,3 +31,5 @@ max_wal_senders = 8
wal_keep_segments = 8 wal_keep_segments = 8
EOF EOF
fi

@ -11,7 +11,7 @@ if [ ! -s "$PGDATA/PG_VERSION" ]; then
standby_mode = on standby_mode = on
primary_conninfo = 'host=$MASTER_NODE password=$REPLICATION_PASSWORD port=5432 user=$REPLICATION_USER' primary_conninfo = 'host=$MASTER_NODE password=$REPLICATION_PASSWORD port=5432 user=$REPLICATION_USER'
trigger_file = '/tmp/touch_me_to_promote_to_me_master' trigger_file = '/tmp/touch_to_promote_to_master'
EOF EOF

Loading…
Cancel
Save