Skip to content

Instantly share code, notes, and snippets.

@pablete
Last active August 29, 2015 14:15
Show Gist options
  • Save pablete/b91293aeebfbe8a63169 to your computer and use it in GitHub Desktop.
Save pablete/b91293aeebfbe8a63169 to your computer and use it in GitHub Desktop.
#!/bin/sh
if [ -z "$1" ]; then
echo "Need to provide an image name. Use this script as ./build.sh imagename"
exit 1
fi
set -o nounset -o errexit
TIMESTAMP=$(date +"%Y%m%d%H%M%S")
IMAGE=$1
REGISTRY="docker.otenv.com"
docker build -t opentable/${IMAGE} .
docker tag opentable/${IMAGE} ${REGISTRY}/${IMAGE}:${TIMESTAMP}
docker push ${REGISTRY}/${IMAGE}:${TIMESTAMP}
mkdir -p config/pp-uswest2/
mkdir -p config/prod-uswest2/
mkdir -p config/prod-euwest1/
cat <<EOF > config/pp-uswest2/singularity.json
{
"requestId": "${IMAGE}",
"resources": {
"cpus": 0.5,
"memoryMb": 256,
"numPorts": 1
},
"daemon": true,
"serviceBasePath": "/",
"healthcheckUri": "/",
"healthcheckTimeoutSeconds": 300,
"containerInfo": {
"type": "DOCKER",
"docker": {
"image": "docker-pp-uswest2.otenv.com/${IMAGE}:${TIMESTAMP}",
"network": "BRIDGE",
"portMappings": [{"containerPort": 80, "hostPort": 0, "hostPortType": "FROM_OFFER"}]
}
},
"env": {
"OT_ENV": "QA"
}
}
EOF
cat <<EOF > config/prod-uswest2/singularity.json
{
"requestId": "${IMAGE}",
"resources": {
"cpus": 0.5,
"memoryMb": 256,
"numPorts": 1
},
"daemon": true,
"serviceBasePath": "/",
"healthcheckUri": "/",
"healthcheckTimeoutSeconds": 300,
"containerInfo": {
"type": "DOCKER",
"docker": {
"image": "docker-prod-uswest2.otenv.com/${IMAGE}:${TIMESTAMP}",
"network": "BRIDGE",
"portMappings": [{"containerPort": 80, "hostPort": 0, "hostPortType": "FROM_OFFER"}]
}
},
"env": {
"OT_ENV": "PROD"
}
}
EOF
cat <<EOF > config/prod-euwest1/singularity.json
{
"requestId": "${IMAGE}",
"resources": {
"cpus": 0.5,
"memoryMb": 256,
"numPorts": 1
},
"daemon": true,
"serviceBasePath": "/",
"healthcheckUri": "/",
"healthcheckTimeoutSeconds": 300,
"containerInfo": {
"type": "DOCKER",
"docker": {
"image": "docker-prod-euwest1.otenv.com/${IMAGE}:${TIMESTAMP}",
"network": "BRIDGE",
"portMappings": [{"containerPort": 80, "hostPort": 0, "hostPortType": "FROM_OFFER"}]
}
},
"env": {
"OT_ENV": "PROD"
}
}
EOF
echo "Deploy it using:"
echo "otpl-deploy -d ${IMAGE} pp-uswest2 ${TIMESTAMP}"
echo "otpl-deploy -d ${IMAGE} prod-uswest2 ${TIMESTAMP}"
echo "otpl-deploy -d ${IMAGE} prod-euwest1 ${TIMESTAMP}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment