[FIX] Stop using --volumes-from option from Docker

This commit is contained in:
Olivier DOSSMANN 2017-01-24 16:55:24 +01:00
parent 975f00168a
commit f8ecbe1d1a
2 changed files with 3 additions and 10 deletions

View File

@ -17,7 +17,6 @@ PROJECT_DIR="${HOME}/gissmo_project"
POSTGRES_VERSION="9.5"
POSTGRES_DOCKER_NAME="gissmo_db"
DB_DIR="/dbdata"
DB_VOLUME_NAME="dbdata"
GIT_BRANCH="v1.7"
GISSMO_VERSION="1.7"
# GISSMO_DOCKER_NAME="gissmo"

View File

@ -84,8 +84,7 @@ show_help() {
echo -e " Where ${green}COMMAND${reset} is one of:"
echo -e " - backup Create a compressed postgreSQL database dump
in current directory"
echo -e " - create Create postgreSQL database volume and
postgreSQL Docker container"
echo -e " - create Create postgreSQL Docker container"
echo -e " - dev [arg ...] Mount Git repository directory AS VOLUME
for Gissmo Docker container and launch it in
'development' mode"
@ -162,10 +161,6 @@ test_create() {
if test -z "$DB_DIR"; then
error_and_quit "No database directory given (DB_DIR in config file)."
fi
if test -z "$DB_VOLUME_NAME"; then
error_and_quit "No database volume name given (DB_VOLUME_NAME in
config file)."
fi
if test -z "$POSTGRES_VERSION"; then
error_and_quit "No postgres version given (POSTGRES_VERSION in
config file)."
@ -179,8 +174,7 @@ config file)."
create() {
test_create
init
$docker_cmd create -v "${DB_DIR}:/var/lib/postgresql/data" --name "${DB_VOLUME_NAME}" "postgres:${POSTGRES_VERSION}" || error_and_quit "Initial database 'docker create' failed."
$docker_cmd run -d -P --volumes-from "${DB_VOLUME_NAME}" --name "${POSTGRES_DOCKER_NAME}" "postgres:${POSTGRES_VERSION}" || error_and_quit "Launching database docker container failed."
$docker_cmd run -d -P -v "${DB_DIR}:/var/lib/postgresql/data" --name "${POSTGRES_DOCKER_NAME}" "postgres:${POSTGRES_VERSION}" || error_and_quit "Launching database docker container failed."
}
dev() {
@ -277,7 +271,7 @@ restore() {
test_restore
$docker_cmd stop ${POSTGRES_DOCKER_NAME} && $docker_cmd rm ${POSTGRES_DOCKER_NAME} || error_and_quit "Failed to stop and delete postgreSQL Docker container: ${POSTGRES_DOCKER_NAME}"
sudo rm -rf ${DB_DIR} || error_and_quit "Failed to delete this directory: ${DB_DIR}"
$docker_cmd run -d -P --volumes-from "${DB_VOLUME_NAME}" --name "${POSTGRES_DOCKER_NAME}" "postgres:${POSTGRES_VERSION}" || error_and_quit "Launching database docker container failed."
$docker_cmd run -d -P -v "${DB_DIR}:/var/lib/postgresql/data" --name "${POSTGRES_DOCKER_NAME}" "postgres:${POSTGRES_VERSION}" || error_and_quit "Launching database docker container failed."
sleep 6 # to wait about docker container runs totally
RESTORE_COMMAND="$docker_cmd run -it --rm --link ${POSTGRES_DOCKER_NAME}:db -v ${DUMP_DIR}:/backup -e PGHOST=`$docker_cmd inspect -f \"{{ .NetworkSettings.IPAddress }}\" ${POSTGRES_DOCKER_NAME}` -e PGUSER=postgres postgres:${POSTGRES_VERSION} pg_restore -d postgres /backup/${DUMP_FILE}"
exec $RESTORE_COMMAND || error_and_quit "Failed to launch this command: ${CMD}"