-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#2 adding a docker compose file to make easier setup of the musicbrai…
…nz database and the elastic search cluster
- Loading branch information
Showing
6 changed files
with
118 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
postgresql: | ||
build: postgres-dockerfile | ||
ports: | ||
- "5432:5432" | ||
env_file: | ||
- ./postgres-dockerfile/postgres.env | ||
elasticsearch: | ||
image: elasticsearch:1.7.1 | ||
ports: | ||
- "9200:9200" | ||
- "9300:9300" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM postgres:9.4 | ||
|
||
RUN apt-get update | ||
|
||
RUN DEBIAN_FRONTEND=noninteractive apt-get -y -q install git-core build-essential libxml2-dev libpq-dev libexpat1-dev libdb-dev libicu-dev postgresql-server-dev-9.4 wget | ||
|
||
RUN git clone https://github.com/metabrainz/postgresql-musicbrainz-unaccent.git && git clone https://github.com/metabrainz/postgresql-musicbrainz-collate.git | ||
|
||
RUN cd postgresql-musicbrainz-unaccent && make && make install && cd ../postgresql-musicbrainz-collate && make && make install && cd ../ | ||
|
||
RUN echo "listen_addresses='*'" >> /var/lib/postgresql/data/postgresql.conf | ||
|
||
ADD create-database.sh /create-database.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/bash | ||
|
||
cd /tmp | ||
|
||
echo "Creating Musicbrainz database structure" | ||
|
||
echo "postgresql:5432:musicbrainz:$POSTGRES_USER:$POSTGRES_PASSWORD" > ~/.pgpass | ||
chmod 0600 ~/.pgpass | ||
|
||
psql -h postgresql -d musicbrainz -U $POSTGRES_USER -a -c "CREATE SCHEMA musicbrainz" | ||
|
||
wget https://raw.githubusercontent.com/metabrainz/musicbrainz-server/master/admin/sql/Extensions.sql | ||
psql -h postgresql -d musicbrainz -U $POSTGRES_USER -a -f Extensions.sql | ||
rm Extensions.sql | ||
|
||
wget https://raw.githubusercontent.com/metabrainz/musicbrainz-server/master/admin/sql/CreateTables.sql | ||
psql -h postgresql -d musicbrainz -U $POSTGRES_USER -a -f CreateTables.sql | ||
rm CreateTables.sql | ||
|
||
echo "Downloading last Musicbrainz dump" | ||
wget -nd -nH -P /tmp http://ftp.musicbrainz.org/pub/musicbrainz/data/fullexport/LATEST | ||
LATEST="$(cat /tmp/LATEST)" | ||
wget -nd -nH -P /tmp http://ftp.musicbrainz.org/pub/musicbrainz/data/fullexport/$LATEST/mbdump-derived.tar.bz2 | ||
wget -nd -nH -P /tmp http://ftp.musicbrainz.org/pub/musicbrainz/data/fullexport/$LATEST/mbdump.tar.bz2 | ||
|
||
|
||
echo "Uncompressing Musicbrainz dump" | ||
tar xjf /tmp/mbdump-derived.tar.bz2 | ||
rm mbdump-derived.tar.bz2 | ||
tar xjf /tmp/mbdump.tar.bz2 | ||
rm mbdump.tar.bz2 | ||
|
||
for f in mbdump/* | ||
do | ||
tablename="${f:7}" | ||
echo "Importing $tablename table" | ||
echo "psql -h postgresql -d musicbrainz -U $POSTGRES_USER -a -c COPY $tablename FROM '/tmp/$f'" | ||
chmod a+rX /tmp/$f | ||
psql -h postgresql -d musicbrainz -U $POSTGRES_USER -a -c "\COPY $tablename FROM '/tmp/$f'" | ||
done | ||
|
||
rm -rf mbdump | ||
|
||
echo "Creating Indexes and Primary Keys" | ||
|
||
wget https://raw.githubusercontent.com/metabrainz/musicbrainz-server/master/admin/sql/CreatePrimaryKeys.sql | ||
psql -h postgresql -d musicbrainz -U $POSTGRES_USER -a -f CreatePrimaryKeys.sql | ||
rm CreatePrimaryKeys.sql | ||
|
||
wget https://raw.githubusercontent.com/metabrainz/musicbrainz-server/master/admin/sql/CreateIndexes.sql | ||
psql -h postgresql -d musicbrainz -U $POSTGRES_USER -a -f CreateIndexes.sql | ||
rm CreateIndexes.sql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
POSTGRES_USER=musicbrainz | ||
POSTGRES_PASSWORD=musicbrainz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters