Skip to content

Commit

Permalink
Add scripts to publish demo images and db
Browse files Browse the repository at this point in the history
  • Loading branch information
phlax committed Apr 12, 2018
1 parent f65fb39 commit bb320f0
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
26 changes: 26 additions & 0 deletions docker/bin/publish-demo-db
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

set -e

export LOCAL_USER_ID=${LOCAL_USER_ID:-$UID}
DOCKER_USERNAME=${DOCKER_USERNAME:-translatetravis2}
DOCKER_PUBLISH_NAME=${DOCKER_PUBLISH_NAME:-translate}

docker-compose pull --parallel demo redis elasticsearch
docker-compose build db-demo

echo "Installing db"
makey demo pootle migrate
makey demo pootle initdb

export DB_UUID=$(docker-compose ps -q db-demo)

echo "Dumping db in $DB_UUID"
docker exec -ti $DB_UUID bash -c "pg_dump -U pootle -Z9 pootledb > /docker-entrypoint-initdb.d/demo.sql.gz"

echo "Commiting $DB_UUID -> $DOCKER_PUBLISH_NAME/pootle:db-demo"
docker-compose stop
docker commit $DB_UUID $DOCKER_PUBLISH_NAME/pootle:db-demo

echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
docker push $DOCKER_PUBLISH_NAME/pootle:db-demo
13 changes: 13 additions & 0 deletions docker/bin/publish-demo-images
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -e

export LOCAL_USER_ID=${LOCAL_USER_ID:-$UID}
DOCKER_USERNAME=${DOCKER_USERNAME:-translatetravis2}
DOCKER_PUBLISH_NAME=${DOCKER_PUBLISH_NAME:-translate}

makey build-demo-all

echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin

docker push $DOCKER_PUBLISH_NAME/pootle:demo
39 changes: 39 additions & 0 deletions docker/bin/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

set -e

CMD="${@:2}";
IMAGE=$1
RUNNER=/home/pootle/pootle_env/src/pootle/docker/bin/run_in_container
export LOCAL_USER_ID=${LOCAL_USER_ID:-$UID}

function pull_images () {
docker-compose pull --include-deps --parallel $IMAGE
}

function image_exists() {
IMAGE_EXISTS=$(docker images -q translate/pootle:$IMAGE)
}

function run_in_container () {
COMPOSE="docker-compose run $FLAGS --rm $IMAGE"
$COMPOSE $RUNNER "${@:1}";
}

image_exists

if [ ! -z $IMAGE_EXISTS ]; then
echo "$IMAGE image exists"
else
echo "$IMAGE image does not exist, pulling..."
pull_images
fi

run_in_container bash /home/pootle/pootle_env/src/pootle/docker/bin/await-postgres

if [ -z ${CMD:+x} ]; then
run_in_container pootle revision --restore
FLAGS=--service-ports run_in_container
else
run_in_container $CMD;
fi

0 comments on commit bb320f0

Please sign in to comment.