Skip to content

Instantly share code, notes, and snippets.

@asafmaoz1234
Last active August 15, 2018 09:04
Show Gist options
  • Save asafmaoz1234/b274df223e33d5172e17ce244ef94ffe to your computer and use it in GitHub Desktop.
Save asafmaoz1234/b274df223e33d5172e17ce244ef94ffe to your computer and use it in GitHub Desktop.
update local running docker image with local repository changes
echo "########## - updating local docker container with local changes - ##########"
# PATH_TO_CODE_REPOSITORY : path in local machine to where your code is
# DOCKER_CONTAINER_NAME : the container name you want to update
PATH_TO_CODE_REPOSITORY='' #COMPLETE THIS
DOCKER_CONTAINER_NAME='' #COMPLETE THIS
PREFIX_OF_WAR_IN_DOCKER='' #COMPLETE THIS
LOCAL_REPOSITORY_WAR_PREFIX='' #COMPLETE THIS
cd ~/PATH_TO_CODE_REPOSITORY
echo "########## - Clean install to verify project can build - ##########"
mvn clean install -DskipTests
echo "########## - remove wars in docker - "
docker exec DOCKER_CONTAINER_NAME find /opt/tomcat/webapps/ -name 'PREFIX_OF_WAR_IN_DOCKER##*SNAPSHOT*' | xargs docker exec DOCKER_CONTAINER_NAME rm -rf
echo "########## - after rm rf wars in docker - "
echo "########## - content of webapps folder - ##########"
docker exec DOCKER_CONTAINER_NAME ls -l /opt/tomcat/webapps/
echo "########## - verify all war filess were deleted - ##########"
cd ~/PATH_TO_CODE_REPOSITORY/target
echo "########## - copy local repository war to docker - ##########"
docker cp LOCAL_REPOSITORY_WAR_PREFIX*.war DOCKER_CONTAINER_NAME:/opt/tomcat/webapps/
echo "########## - content of webapps folder - ##########"
docker exec DOCKER_CONTAINER_NAME ls -l /opt/tomcat/webapps/
echo "########## - verify war exists - ##########"
echo "########## - after copy restart docker - ##########"
docker restart DOCKER_CONTAINER_NAME
cd ~/PATH_TO_CODE_REPOSITORY
echo "########## - Docker updated with local canges- ##########"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment