Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Make redis, postgres and rabbitmq hosts configurable via env variables #264

Merged
merged 7 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions build/musicbrainz-dev/DBDefs.pm
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ MusicBrainz::Server::DatabaseConnectionFactory->register_databases(
database => "musicbrainz_db",
username => "$ENV{POSTGRES_USER}",
password => "$ENV{POSTGRES_PASSWORD}",
host => "db",
host => "$ENV{MUSICBRAINZ_POSTGRES_SERVER}",
port => "5432",
},
# How to connect to a test database
TEST => {
database => "musicbrainz_test",
username => "$ENV{POSTGRES_USER}",
password => "$ENV{POSTGRES_PASSWORD}",
host => "db",
host => "$ENV{MUSICBRAINZ_POSTGRES_SERVER}",
port => "5432",
},
# How to connect to a Selenium test database. This database is created
Expand All @@ -73,15 +73,15 @@ MusicBrainz::Server::DatabaseConnectionFactory->register_databases(
schema => 'musicbrainz',
username => "$ENV{POSTGRES_USER}",
password => "$ENV{POSTGRES_PASSWORD}",
host => "db",
host => "$ENV{MUSICBRAINZ_POSTGRES_SERVER}",
port => "5432",
},
# How to connect for read-only access. See "REPLICATION_TYPE" (below)
READONLY => {
database => "musicbrainz_db",
username => "$ENV{POSTGRES_USER}",
password => "$ENV{POSTGRES_PASSWORD}",
host => "db",
host => "$ENV{MUSICBRAINZ_POSTGRES_READONLY_SERVER}",
port => "5432",
},
# How to connect for read-only access to the production database in standby mode.
Expand All @@ -101,7 +101,7 @@ MusicBrainz::Server::DatabaseConnectionFactory->register_databases(
database => "template1",
username => "$ENV{POSTGRES_USER}",
password => "$ENV{POSTGRES_PASSWORD}",
host => "db",
host => "$ENV{MUSICBRAINZ_POSTGRES_SERVER}",
port => "5432",
},
# How to connect when running maintenance scripts located under admin/.
Expand All @@ -111,7 +111,7 @@ MusicBrainz::Server::DatabaseConnectionFactory->register_databases(
# database => "musicbrainz_db",
# username => "$ENV{POSTGRES_USER}",
# password => "$ENV{POSTGRES_PASSWORD}",
# host => "db",
# host => "$ENV{MUSICBRAINZ_POSTGRES_SERVER}",
# port => "5432",
# },
# Fill out only if RAWDATA lives on a different host from the READWRITE server.
Expand Down Expand Up @@ -274,7 +274,7 @@ sub PLUGIN_CACHE_OPTIONS {
my $self = shift;
return {
class => 'MusicBrainz::Server::CacheWrapper::Redis',
server => 'redis:6379',
server => "$ENV{MUSICBRAINZ_REDIS_SERVER}:6379",
namespace => $self->CACHE_NAMESPACE . 'Catalyst:',
};
}
Expand All @@ -289,7 +289,7 @@ sub CACHE_MANAGER_OPTIONS {
external => {
class => 'MusicBrainz::Server::CacheWrapper::Redis',
options => {
server => 'redis:6379',
server => "$ENV{MUSICBRAINZ_REDIS_SERVER}:6379",
namespace => $self->CACHE_NAMESPACE,
},
},
Expand Down Expand Up @@ -328,7 +328,7 @@ sub DATASTORE_REDIS_ARGS {
return {
database => 0,
namespace => $self->CACHE_NAMESPACE,
server => 'redis:6379',
server => "$ENV{MUSICBRAINZ_REDIS_SERVER}:6379",
test_database => 1,
};
}
Expand Down
4 changes: 4 additions & 0 deletions build/musicbrainz-dev/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ ENV BASH_ENV=/noninteractive.bash_env \
MUSICBRAINZ_BASE_DOWNLOAD_URL=https://data.metabrainz.org/pub/musicbrainz \
MUSICBRAINZ_CATALYST_DEBUG=0 \
MUSICBRAINZ_DEVELOPMENT_SERVER=1 \
MUSICBRAINZ_POSTGRES_SERVER=db \
MUSICBRAINZ_POSTGRES_READONLY_SERVER=db \
MUSICBRAINZ_RABBITMQ_SERVER=mq \
MUSICBRAINZ_REDIS_SERVER=redis \
MUSICBRAINZ_SEARCH_SERVER=search:8983/solr \
MUSICBRAINZ_SERVER_PROCESSES=1 \
MUSICBRAINZ_STANDALONE_SERVER=1 \
Expand Down
2 changes: 1 addition & 1 deletion build/musicbrainz-dev/scripts/createdb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ for F in "${DUMP_FILES[@]}"; do
done

echo "found existing dumps"
dockerize -wait tcp://db:5432 -timeout 60s sleep 0
dockerize -wait "tcp://${MUSICBRAINZ_POSTGRES_SERVER}:5432" -timeout 60s sleep 0

update-perl.sh

Expand Down
2 changes: 1 addition & 1 deletion build/musicbrainz-dev/scripts/indexer-triggers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fi

INDEXER_SQL_DIR="$1"

dockerize -wait tcp://db:5432 -timeout 60s sleep 0
dockerize -wait "tcp://${MUSICBRAINZ_POSTGRES_SERVER}:5432" -timeout 60s sleep 0

cd /musicbrainz-server

Expand Down
4 changes: 2 additions & 2 deletions build/musicbrainz-dev/scripts/recreatedb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

set -e

dockerize -wait tcp://db:5432 -timeout 60s sleep 0
psql postgres -U musicbrainz -h db -c "DROP DATABASE IF EXISTS musicbrainz_db;"; createdb.sh "$@"
dockerize -wait "tcp://${MUSICBRAINZ_POSTGRES_SERVER}:5432" -timeout 60s sleep 0
psql postgres -U musicbrainz -h "${MUSICBRAINZ_POSTGRES_SERVER}" -c "DROP DATABASE IF EXISTS musicbrainz_db;"; createdb.sh "$@"
2 changes: 1 addition & 1 deletion build/musicbrainz-dev/scripts/replication.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

set -e

dockerize -wait tcp://db:5432 -timeout 60s sleep 0
dockerize -wait "tcp://${MUSICBRAINZ_POSTGRES_SERVER}:5432" -timeout 60s sleep 0
exec /musicbrainz-server/admin/cron/mirror.sh
2 changes: 1 addition & 1 deletion build/musicbrainz-dev/scripts/update-javascript.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ cd /musicbrainz-server

yarn

dockerize -wait tcp://db:5432 -timeout 60s -wait tcp://mq:5672 -timeout 60s -wait tcp://redis:6379 -timeout 60s
dockerize -wait "tcp://${MUSICBRAINZ_POSTGRES_SERVER}:5432" -timeout 60s -wait "tcp://${MUSICBRAINZ_RABBITMQ_SERVER}:5672" -timeout 60s -wait "tcp://${MUSICBRAINZ_REDIS_SERVER}:6379" -timeout 60s

./script/compile_resources.sh --watch client server tests &> /compile_resources.log &
12 changes: 6 additions & 6 deletions build/musicbrainz/DBDefs.pm
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ MusicBrainz::Server::DatabaseConnectionFactory->register_databases(
database => "musicbrainz_db",
username => "$ENV{POSTGRES_USER}",
password => "$ENV{POSTGRES_PASSWORD}",
host => "db",
host => "$ENV{MUSICBRAINZ_POSTGRES_SERVER}",
port => "5432",
},
# How to connect to a test database
Expand All @@ -80,15 +80,15 @@ MusicBrainz::Server::DatabaseConnectionFactory->register_databases(
database => "musicbrainz_db",
username => "$ENV{POSTGRES_USER}",
password => "$ENV{POSTGRES_PASSWORD}",
host => "db",
host => "$ENV{MUSICBRAINZ_POSTGRES_READONLY_SERVER}",
port => "5432",
},
# How to connect for administrative access
SYSTEM => {
database => "template1",
username => "$ENV{POSTGRES_USER}",
password => "$ENV{POSTGRES_PASSWORD}",
host => "db",
host => "$ENV{MUSICBRAINZ_POSTGRES_SERVER}",
port => "5432",
},
# How to connect when running maintenance scripts located under admin/.
Expand Down Expand Up @@ -261,7 +261,7 @@ sub PLUGIN_CACHE_OPTIONS {
my $self = shift;
return {
class => 'MusicBrainz::Server::CacheWrapper::Redis',
server => 'redis:6379',
server => "$ENV{MUSICBRAINZ_REDIS_SERVER}:6379",
namespace => $self->CACHE_NAMESPACE . 'Catalyst:',
};
}
Expand All @@ -276,7 +276,7 @@ sub CACHE_MANAGER_OPTIONS {
external => {
class => 'MusicBrainz::Server::CacheWrapper::Redis',
options => {
server => 'redis:6379',
server => "$ENV{MUSICBRAINZ_REDIS_SERVER}:6379",
namespace => $self->CACHE_NAMESPACE,
},
},
Expand Down Expand Up @@ -315,7 +315,7 @@ sub DATASTORE_REDIS_ARGS {
return {
database => 0,
namespace => $self->CACHE_NAMESPACE,
server => 'redis:6379',
server => "$ENV{MUSICBRAINZ_REDIS_SERVER}:6379",
test_database => 1,
};
}
Expand Down
4 changes: 4 additions & 0 deletions build/musicbrainz/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ ENV BASH_ENV=/noninteractive.bash_env \
MUSICBRAINZ_CATALYST_DEBUG=0 \
MUSICBRAINZ_DB_SCHEMA_SEQUENCE=28 \
MUSICBRAINZ_DEVELOPMENT_SERVER=0 \
MUSICBRAINZ_POSTGRES_SERVER=db \
MUSICBRAINZ_POSTGRES_READONLY_SERVER=db \
MUSICBRAINZ_RABBITMQ_SERVER=mq \
MUSICBRAINZ_REDIS_SERVER=redis \
MUSICBRAINZ_SEARCH_SERVER=search:8983/solr \
MUSICBRAINZ_SERVER_PROCESSES=10 \
MUSICBRAINZ_STANDALONE_SERVER=0 \
Expand Down
2 changes: 1 addition & 1 deletion build/musicbrainz/scripts/createdb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ for F in "${DUMP_FILES[@]}"; do
done

echo "found existing dumps"
dockerize -wait tcp://db:5432 -timeout 60s sleep 0
dockerize -wait "tcp://${MUSICBRAINZ_POSTGRES_SERVER}:5432" -timeout 60s sleep 0

mkdir -p $TMP_DIR
cd /media/dbdump
Expand Down
2 changes: 1 addition & 1 deletion build/musicbrainz/scripts/indexer-triggers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fi

INDEXER_SQL_DIR="$1"

dockerize -wait tcp://db:5432 -timeout 60s sleep 0
dockerize -wait "tcp://${MUSICBRAINZ_POSTGRES_SERVER}:5432" -timeout 60s sleep 0

cd /musicbrainz-server

Expand Down
4 changes: 2 additions & 2 deletions build/musicbrainz/scripts/load-crontab-only.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
set -e -u

dockerize \
-wait tcp://db:5432 -timeout 60s \
-wait tcp://redis:6379 -timeout 60s \
-wait "tcp://${MUSICBRAINZ_POSTGRES_SERVER}:5432" -timeout 60s \
-wait "tcp://${MUSICBRAINZ_REDIS_SERVER}:6379" -timeout 60s \
true

if [ -f /crons.conf -a -s /crons.conf ]
Expand Down
4 changes: 2 additions & 2 deletions build/musicbrainz/scripts/recreatedb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

set -e

dockerize -wait tcp://db:5432 -timeout 60s sleep 0
psql postgres -U musicbrainz -h db -c "DROP DATABASE IF EXISTS musicbrainz_db;"; createdb.sh "$@"
dockerize -wait "tcp://${MUSICBRAINZ_POSTGRES_SERVER}:5432" -timeout 60s sleep 0
psql postgres -U musicbrainz -h "${MUSICBRAINZ_POSTGRES_SERVER}" -c "DROP DATABASE IF EXISTS musicbrainz_db;"; createdb.sh "$@"
2 changes: 1 addition & 1 deletion build/musicbrainz/scripts/replication.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

set -e

dockerize -wait tcp://db:5432 -timeout 60s sleep 0
dockerize -wait "tcp://${MUSICBRAINZ_POSTGRES_SERVER}:5432" -timeout 60s sleep 0
exec /musicbrainz-server/admin/cron/mirror.sh
2 changes: 1 addition & 1 deletion build/musicbrainz/scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ then
/musicbrainz-server/script/compile_resources.sh
fi

dockerize -wait tcp://db:5432 -timeout 60s -wait tcp://mq:5672 -timeout 60s -wait tcp://redis:6379 -timeout 60s start_mb_renderer.pl
dockerize -wait "tcp://${MUSICBRAINZ_POSTGRES_SERVER}:5432" -timeout 60s -wait "tcp://${MUSICBRAINZ_RABBITMQ_SERVER}:5672" -timeout 60s -wait "tcp://${MUSICBRAINZ_REDIS_SERVER}:6379" -timeout 60s start_mb_renderer.pl

if [ -f /crons.conf -a -s /crons.conf ]
then
Expand Down
2 changes: 1 addition & 1 deletion build/musicbrainz/scripts/upgrade-db-schema.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ set -e -u

export MUSICBRAINZ_DB_SCHEMA_SEQUENCE=27

dockerize -wait tcp://db:5432 -timeout 60s ./upgrade.sh
dockerize -wait "tcp://${MUSICBRAINZ_POSTGRES_SERVER}:5432" -timeout 60s ./upgrade.sh
4 changes: 2 additions & 2 deletions build/sir-dev/scripts/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ pip install \
-r requirements_dev.txt

dockerize \
-wait tcp://db:5432 -timeout 60s \
-wait tcp://mq:5672 -timeout 60s \
-wait "tcp://${MUSICBRAINZ_POSTGRES_SERVER}:5432" -timeout 60s \
-wait "tcp://${MUSICBRAINZ_RABBITMQ_SERVER}:5672" -timeout 60s \
-wait tcp://search:8983 -timeout 60s \
sleep 0

Expand Down
6 changes: 6 additions & 0 deletions build/sir/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,11 @@ RUN git clone --depth=1 --branch "v${SIR_VERSION}" https://github.com/metabrainz

WORKDIR /code

ENV MUSICBRAINZ_RABBITMQ_SERVER=mq \
MUSICBRAINZ_POSTGRES_SERVER=db \
MUSICBRAINZ_POSTGRES_READONLY_SERVER=db \
MUSICBRAINZ_SEARCH_SERVER=search:8983/solr

ENV POSTGRES_USER=musicbrainz
ENV POSTGRES_PASSWORD=musicbrainz

6 changes: 3 additions & 3 deletions default/indexer.ini
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[database]
dbname = musicbrainz_db
host = db
host = ${MUSICBRAINZ_POSTGRES_SERVER}
password = ${POSTGRES_PASSWORD}
port = 5432
user = ${POSTGRES_USER}

[solr]
uri = http://search:8983/solr
uri = ${MUSICBRAINZ_SEARCH_SERVER}
batch_size = 200

[sir]
Expand All @@ -18,7 +18,7 @@ query_batch_size = 5000
wscompat = on

[rabbitmq]
host = mq
host = ${MUSICBRAINZ_RABBITMQ_SERVER}
user = sir
password = sir
vhost = /search-index-rebuilder
Expand Down