<commit_before>#!/usr/bin/env bash

set -e

help() {
    echo ""
    echo "usage: $0 [create docker_file tag] | [list image]"
    echo ""
    exit 1
}

VALID_IMAGE_NAME='<%= node['conda']['docker']['image-validation-regex'] %>'
if [ "$1" == "create" ] ; then

    # Sanity checks for injection attacks
    if [ ! -f "$2" ] ; then
	echo "Invalid docker file: $2" >&2
	help
    fi
    if ! [[ $3 =~ $VALID_IMAGE_NAME ]] ; then
	echo "error: Not an image name $3" >&2
	help
    fi
    
    DOCKER_BUILDKIT=1 docker build -f $2 --tag $3 ./

    docker push $3

<% if node['install']['managed_docker_registry'] == "false" -%>
elif [ "$1" == "delete" ] ; then
    # Remove tags from docker registry
    docker exec registry rm -rf /var/lib/registry/docker/registry/v2/repositories/$2/_manifests/tags/$3

elif [ "$1" == "gc" ] ; then
    # Run garbage collection for registry
    docker exec registry bin/registry garbage-collect /etc/docker/registry/config.yml -m
    
<% end -%>

elif [ "$1" == "list" ] ; then
    if ! [[ $2 =~ $VALID_IMAGE_NAME ]] ; then
	echo "error: Not an image name $2" >&2
	help
    fi
    
    docker run --rm $2 conda list -n theenv

elif [ "$1" == "export" ] ; then
    if ! [[ $2 =~ $VALID_IMAGE_NAME ]] ; then
	echo "error: Not an image name $2" >&2
	help
    fi

    docker pull $2 > /dev/null 2>&1
    docker run --rm $2 conda env export -n theenv
    
else
    help
fi

exit $?<commit_msg>[HOPSWORKS-2116] Add --network option to docker build (#525)<commit_after>#!/usr/bin/env bash

set -e

help() {
    echo ""
    echo "usage: $0 [create docker_file tag] | [list image]"
    echo ""
    exit 1
}

VALID_IMAGE_NAME='<%= node['conda']['docker']['image-validation-regex'] %>'
if [ "$1" == "create" ] ; then

    # Sanity checks for injection attacks
    if [ ! -f "$2" ] ; then
	echo "Invalid docker file: $2" >&2
	help
    fi
    if ! [[ $3 =~ $VALID_IMAGE_NAME ]] ; then
	echo "error: Not an image name $3" >&2
	help
    fi

    DOCKER_BUILDKIT=1 docker build --network=host -f $2 --tag $3 ./

    docker push $3

<% if node['install']['managed_docker_registry'] == "false" -%>
elif [ "$1" == "delete" ] ; then
    # Remove tags from docker registry
    docker exec registry rm -rf /var/lib/registry/docker/registry/v2/repositories/$2/_manifests/tags/$3

elif [ "$1" == "gc" ] ; then
    # Run garbage collection for registry
    docker exec registry bin/registry garbage-collect /etc/docker/registry/config.yml -m

<% end -%>

elif [ "$1" == "list" ] ; then
    if ! [[ $2 =~ $VALID_IMAGE_NAME ]] ; then
	echo "error: Not an image name $2" >&2
	help
    fi

    docker run --rm $2 conda list -n theenv

elif [ "$1" == "export" ] ; then
    if ! [[ $2 =~ $VALID_IMAGE_NAME ]] ; then
	echo "error: Not an image name $2" >&2
	help
    fi

    docker pull $2 > /dev/null 2>&1
    docker run --rm $2 conda env export -n theenv

else
    help
fi

exit $?
{'fraction_non_alphanumeric': 0.165045170257123, 'fraction_numerical': 0.023974982626824185, 'mean_word_length': 2.7100515463917527, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '349890', 'n_tokens_mistral': 1102, 'n_tokens_neox': 1035, 'n_words': 330}