Page MenuHomeDevCentral

run-devcentral: script to launch the DevCentral container
ActivePublic

Authored by dereckson on Apr 22 2015, 01:52.
#!/bin/sh
INSTANCE_NAME=devcentral
DATA_DIRECTORY=/data/$INSTANCE_NAME
MYSQL_INSTANCE=acquisitariat
PHABRICATOR_URL=http://$INSTANCE_NAME.nasqueron.org
PHABRICATOR_TITLE="Nasqueron DevCentral"
PHABRICATOR_ALT_FILE_DOMAIN="http://phabricator-files-for-devcentral-nasqueron.spacetechnology.net"
REPO_LOGIN=git
REPO_HOST=bitbucket.org
PHABRICATOR_PROD_REPO="ssh://git@bitbucket.org/nasqueron/devcentral-phabricator"
PHABRICATOR_PROD_BRANCH=production
# Checks container isn't running
docker-container-status $INSTANCE_NAME > /dev/null
if [ "$?" -lt 2 ]; then
echo "Container is already running."
echo "To force relaunch, try docker stop $INSTANCE_NAME ; docker rm $INSTANCE_NAME ; $0"
exit 1
fi
# Creates container
docker run -d \
--link $MYSQL_INSTANCE:mysql \
-v $DATA_DIRECTORY/repo:/var/repo \
-v $DATA_DIRECTORY/conf:/opt/phabricator/conf \
-p 31080:80 \
-e PHABRICATOR_URL=$PHABRICATOR_URL \
-e PHABRICATOR_TITLE="$PHABRICATOR_TITLE" \
-e PHABRICATOR_ALT_FILE_DOMAIN="$PHABRICATOR_ALT_FILE_DOMAIN" \
-e PHABRICATOR_PROD_REPO=$PHABRICATOR_PROD_REPO \
-e PHABRICATOR_PROD_BRANCH=$PHABRICATOR_PROD_BRANCH \
--name $INSTANCE_NAME nasqueron/phabricator
# Application configuration
docker exec $INSTANCE_NAME sh -c 'cd /opt/phabricator && \
bin/config set mysql.host mysql && \
bin/config set mysql.pass $MYSQL_ENV_MYSQL_ROOT_PASSWORD && \
bin/config set phabricator.base-uri $PHABRICATOR_URL && \
bin/config set security.alternate-file-domain "$PHABRICATOR_ALT_FILE_DOMAIN" && \
rm -f /etc/nginx/sites-enabled/default && \
chown -R app /var/repo'
# At this stage, Phabricator is deployed out of the box and fully functional.
# Any successive failure should let to a task with a normal or high priority but not unbreak.
# Switches to our version
docker exec $INSTANCE_NAME sh -c 'mkdir -p /root/.ssh && \
cp /opt/phabricator/conf/deploy-keys/* /root/.ssh'
docker exec $INSTANCE_NAME ssh -o StrictHostKeyChecking=no ${REPO_LOGIN}@${REPO_HOST}
docker exec $INSTANCE_NAME sh -c 'cd /opt/phabricator && \
git remote add private "$PHABRICATOR_PROD_REPO" && \
git fetch --all && \
git checkout $PHABRICATOR_PROD_BRANCH'
echo "Deployment done at `date`."
exit 0

Event Timeline

dereckson changed the title of this paste from untitled to run-devcentral: script to launch the DevCentral container.
dereckson updated the paste's language from autodetect to autodetect.

docker exec $INSTANCE_NAME ssh -o StrictHostKeyChecking=no ${REPO_LOGIN}@${REPO_HOST}

To provide a .known_hosts file could be preferable, as GitHub has several servers.

dereckson edited the content of this paste. (Show Details)
dereckson edited the content of this paste. (Show Details)