comparison scripts/.functions.sh @ 284:d41836720ce4 production v2.3.0

flow: Merged <release> 'v2.3.0' to <master> ('production').
author smith@nwoca.org
date Thu, 15 Nov 2018 20:10:48 +0000
parents d6d8468441b1
children
comparison
equal deleted inserted replaced
277:5599ce0c5a50 284:d41836720ce4
32 } 32 }
33 33
34 # finds docker container for specified compose service 34 # finds docker container for specified compose service
35 composeGetContainer() { 35 composeGetContainer() {
36 service=${1?"Must supply service from current project"} 36 service=${1?"Must supply service from current project"}
37 container=$( docker-compose ps | cut -d " " -f 1 -s | grep _${service}_ ) 37 container=$( docker-compose ps -q $service | xargs docker inspect -f '{{.Name}}' | cut -d "/" -f 2 )
38 echo $container 38 echo $container
39 } 39 }
40 40
41 executeSQL() { 41 executeSQL() {
42 service=${1?Must supply db service to execute against} 42 service=${1?Must supply db service to execute against}
44 44
45 echo "$2" | docker exec -i $container sh -c "gosu postgres psql \$DB_NAME" 45 echo "$2" | docker exec -i $container sh -c "gosu postgres psql \$DB_NAME"
46 } 46 }
47 47
48 composeGetProject() { 48 composeGetProject() {
49 project=$( docker-compose ps | tail -n1 | cut -d "_" -f 1 -s ) 49 project=$(docker-compose ps -q | tail -n1 | xargs docker inspect -f "{{ index .Config.Labels \"com.docker.compose.project\"}}" )
50 echo $project 50 echo $project
51 } 51 }