Skip to content

Commit

Permalink
#63 Production deployment script corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
dcoraboeuf committed Nov 27, 2014
1 parent f1bb9e8 commit b8e21b4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
8 changes: 4 additions & 4 deletions ontrack-delivery/Operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ In all cases, you'll have the following structure:

4. Start and connect to the `ontrack-data` volumes:

docker run -it --volumes-from ontrack-data ubuntu:14.04 /bin/bash
docker run -it --volumes-from ontrack-data --volume /root/migration:/migration ubuntu:14.04 /bin/bash

5. And execute the following commands:

Expand All @@ -189,21 +189,21 @@ In all cases, you'll have the following structure:

6. Clean the container list

docker rm $(docker ps -l | grep ubuntu | awk "{print \$1}")
docker rm $(docker ps -l | grep ubuntu | awk '{print $1}')

7. Remove the `ontrack` old container:

docker rm ontrack

8. Recreate the `ontrack` container from your favourite version:

docker run -d --name ontrack-<version> --volumes-from ontrack-data nemerosa/ontrack:<version>
docker run -d --name ontrack-$VERSION --volumes-from ontrack-data nemerosa/ontrack:$VERSION

9. Recreate the Nginx container:

docker run -d \
--publish 443:443 \
--link ontrack-<version>:ontrack \
--link ontrack-$VERSION:ontrack \
--volume /root/nginx/certs:/etc/nginx/certs \
--volume /root/nginx/sites-enabled:/etc/nginx/sites-enabled \
dockerfile/nginx
Expand Down
23 changes: 18 additions & 5 deletions ontrack-delivery/production-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,30 +57,43 @@ echo "[PRODUCTION] Version = ${VERSION}"

# Removes the Nginx container

NGINX_CID=`docker ps | grep "dockerfile/nginx" | awk "{print \$1}"`
docker stop ${NGINX_CID}
docker rm ${NGINX_CID}
echo "[PRODUCTION] Stopping Nginx container..."
NGINX_CID=`docker ps | grep "dockerfile/nginx" | awk '{print $1}'`
if [ "${NGINX_CID}" != "" ]
then
docker stop ${NGINX_CID}
docker rm ${NGINX_CID}
fi

# Stops the old version of Ontrack

docker stop $(docker ps docker ps | grep "nemerosa/ontrack" | awk "{print \$1}")
echo "[PRODUCTION] Stopping Ontrack container..."
ONTRACK_CID=`docker ps docker ps | grep "nemerosa/ontrack" | awk '{print $1}'`
if [ "${ONTRACK_CID}" != "" ]
then
docker stop ${ONTRACK_CID}
fi

# Backup of the data

echo "[PRODUCTION] Backuping Ontrack data..."
TIMESTAMP=`date +%F-%T`
docker run --volumes-from ontrack-data --volume /root:/backup ubuntu tar czvf /backup/backup-${TIMESTAMP}.tgz /opt/ontrack/mount

# Installs the new version of Ontrack

echo "[PRODUCTION] Starting new Ontrack version ${VERSION}..."
docker run -d --name ontrack-${VERSION} --volumes-from ontrack-data nemerosa/ontrack:${VERSION}

# Recreate the Nginx container:

echo "[PRODUCTION] Starting the Nginx proxy container..."
docker run -d \
--publish 443:443 \
--link ontrack-${VERSION}:ontrack \
--volume /root/nginx/certs:/etc/nginx/certs \
--volume /root/nginx/sites-enabled:/etc/nginx/sites-enabled \
dockerfile/nginx

# End
# End
echo "[PRODUCTION] End of deployment."

0 comments on commit b8e21b4

Please sign in to comment.