Commit 1e1cbd7 1 parent 7a0fd1e commit 1e1cbd7 Copy full SHA for 1e1cbd7
File tree 5 files changed +46
-1
lines changed
5 files changed +46
-1
lines changed Original file line number Diff line number Diff line change 1
1
version : " 3"
2
2
services :
3
3
database :
4
- image : transport_db
4
+ image : antoinede/transport_data_gouv_dev_database
5
5
volumes :
6
6
- pgdata:/var/lib/postgresql/data
7
7
environment :
Original file line number Diff line number Diff line change
1
+ FROM mdillon/postgis:11-alpine
2
+
3
+ # PATH to the clever cloud backup file
4
+ ARG BACKUP_PATH
5
+
6
+ ENV POSTGRES_DB transport_repo
7
+
8
+ COPY restore_db.sh /docker-entrypoint-initdb.d/
9
+ COPY create_test_db.sh /docker-entrypoint-initdb.d/
10
+ COPY ${BACKUP_PATH} /db_backup
11
+
12
+
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ # create test database
3
+ createdb transport_test
Original file line number Diff line number Diff line change
1
+ # Script to build a database docker image
2
+
3
+ To build the image run:
4
+
5
+ ` docker build -t transport_data_gouv_dev_database --build-arg BACKUP_PATH=<path_to_the_backup_file> . `
6
+
7
+ Note: backup file needs to be in the directory.
8
+
9
+ If you want to push it to dockerhub (change the destination image name if needed):
10
+
11
+ ` docker login `
12
+
13
+ ` docker tag transport_data_gouv_dev_database antoinede/transport_data_gouv_dev_database:latest `
14
+
15
+ ` docker push antoinede/transport_data_gouv_dev_database:latest `
Original file line number Diff line number Diff line change
1
+ #! /bin/bash -x
2
+
3
+ DB_NAME=" transport_repo"
4
+ BACKUP_PATH=" /db_backup"
5
+
6
+ # the pg_restore fail for some obscure reasons, but the import seems to be ok
7
+ pg_restore --dbname=$DB_NAME --format=c --no-owner --clean $BACKUP_PATH || true
8
+
9
+ # add a check
10
+ nb_datasets=` psql -qtAX $DB_NAME -c " select count(*) from dataset;" `
11
+
12
+ if [[ $nb_datasets -eq 0 ]]; then
13
+ echo " no datasets loaded, something is strange"
14
+ exit 1
15
+ fi
You can’t perform that action at this time.
0 commit comments