def _push_image(image): ext.dispatch("before_push", image) current_dir = os.getcwd() image_path = os.path.join(current_dir, image.get('path')) version = dockerfile.read_tag(image_path) use_versioning = image.get('use_versioning', False) repository = image.get('repository') release_tag = image.get('tag', 'latest') if use_versioning and version: local("docker push {0}:{1}".format(repository['url'], version)) local("docker push {0}:{1}".format(repository['url'], release_tag))
def deploy(): ''' Pull latest image and restart containers ''' images = env.image compose_file = env.compose_files[0] if not isinstance(env.image, list): images = [env.image] with env.cd(env.path): # Update images for image in images: repository = image.get('repository') release_tag = image.get('tag', 'latest') # Trigger before deploy hooks ext.dispatch("before_deploy", image) # Pull latest repro changes env.run("docker pull {0}:{1}".format(repository['url'], release_tag)) # Stop all containers env.run("docker-compose -f {0} -p {1} stop".format( compose_file, env.project)) # Start all containers env.run("docker-compose -f {0} -p {1} up -d".format( compose_file, env.project)) # Trigger after deploy hooks for image in images: ext.dispatch("after_deploy", image) # Remove dangeling images env.run("docker images --quiet --filter=dangling=true" " | xargs --no-run-if-empty docker rmi")
def deploy(): ''' Pull latest image and restart containers ''' images = env.image compose_file = env.compose_files[0] if not isinstance(env.image, list): images = [env.image] with env.cd(env.path): # Update images for image in images: repository = image.get('repository') release_tag = image.get('tag', 'latest') # Trigger before deploy hooks ext.dispatch("before_deploy", image) # Pull latest repro changes env.run("docker pull {0}:{1}".format(repository['url'], release_tag)) # Stop all containers env.run("docker-compose -f {0} -p {1} stop".format(compose_file, env.project)) # Start all containers env.run("docker-compose -f {0} -p {1} up -d".format(compose_file, env.project)) # Trigger after deploy hooks for image in images: ext.dispatch("after_deploy", image) # Remove dangeling images env.run("docker images --quiet --filter=dangling=true" " | xargs --no-run-if-empty docker rmi")