clonebuildregister


Nameclonebuildregister JSON
Version 0.0.7 PyPI version JSON
download
home_pageNone
SummaryA package to clone a Git repository, build it's image using Docker, and then register it to the Google Artifact Registry.
upload_time2024-06-25 16:14:47
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseBSD 3-Clause License Copyright (c) 2023, Jude Sproul Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
keywords docker google cloud artifact registry build clone git register upload image
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
******************
clonebuildregister
******************

Clones a repository, builds a docker image from that repository, and then pushes that image to google cloud artifact registry

To use clonebuildregister as a package:

    >>> from clonebuildregister.clonebuildregister import clonebuildregister
    >>> clonebuildregister("cbcunc", "timage", "develop", "testimage", "v1", "timage", "testimage", "v1", "us-east1", "bimage-project", "bimage-repository")
    >>>

To use clonebuildregister as a script:

    usage: clonebuildregister [-h] [-v] [-l PATH_TO_LOCAL_ENVIRONMENT] [-r PATH_TO_REMOTE_ENVIRONMENT] [-p PLATFORM] [-cn CLONE_NAME] [-dr DELETE_REPOSITORY]
                          [-di DELETE_ALL_DOCKER_IMAGES]
                          github_org repo_name branch_or_tag local_image_name local_image_tag path_to_dockerfile target_image_name target_image_tag region
                          gcloudProjectId repositoryName


positional arguments:
  :github_org:            The GitHub organization of the repository
  :repo_name:             The name of the repository in the organization
  :branch_or_tag:         The branch or tag of the repository
  :local_image_name:      The name of the image we create locally from the Dockerfile
  :local_image_tag:       The tag of the image we create locally from the Dockerfile (v1, 1.0.1, version2.0)
  :path_to_dockerfile:    The path to the docker file from the repository we cloned, usually the name of the repository
  :target_image_name:     The target image name, i.e. the name of the image we store in the google cloud artifact registry
  :target_image_tag:      The target image tag, i.e. the tag of the image we store in the google cloud artifact registry (v1, 1.0.1, version2.0)
  :region:                Region the image will be stored in the google cloud (e.g. us-east1, us, eu)
  :gcloudProjectId:       The project id from which the image will be stored under in a google artifact registry
  :repositoryName:        The name of the google cloud artifact registry that holds docker images

options:

  -h, --help            show this help message and exit

  -v, --version         show program's version number and exit

  -l PATH_TO_LOCAL_ENVIRONMENT, --path_to_local_environment PATH_TO_LOCAL_ENVIRONMENT
                        The path to a local environment file with secrets not to be seen on github (e.g usr/home/clonebuildregister/.env). Defaults to . (default: )

  -r PATH_TO_REMOTE_ENVIRONMENT, --path_to_remote_environment PATH_TO_REMOTE_ENVIRONMENT
                        The path to the dummy environment files found on github (e.g usr/home/clonebuildregister/.env). Defaults to . (default: )

  -p PLATFORM, --platform PLATFORM
                        The target platform of the image in the form of os[/arch[/variant]] (default: )

  -cn CLONE_NAME, --clone_name CLONE_NAME
                        The name of the top level folder of the github repository will be named after cloning. (default: )

  -dr DELETE_REPOSITORY, --delete_repository DELETE_REPOSITORY
                        Boolean that tells the program to delete the github repository that it clones after it registers it to the google cloud AR (default: False)

  -di DELETE_ALL_DOCKER_IMAGES, --delete_all_docker_images DELETE_ALL_DOCKER_IMAGES
                        Boolean that tells the program to delete all docker images on the local system after the program puts the image on the google cloud artifact registry. Deletes using force. Similar to running this $ docker rmi -f $(docker images -aq) (default: False)

    example:
        $ python -m clonebuildregister cbcunc timage develop testimage v1 timage testimage v1 us-east1 bimage-project bimage-repository

Use modules of clonebuildregister
*********************************
Use the module buildImage:
    >>> from clonebuildregister.buildImage import buildImage
    >>> image = buildImage("testimage:v1","") # if Dockerfile in current directory, use 2nd argument as target directory
    >>>
Use the module cloneRepo:
    >>> from clonebuildregister.cloneRepo import cloneRepo
    >>> cloneRepo("cbcunc", "timage", "develop") # github_org, repo_name, branch_or_tag
    >>>
Use the module cloneRepo with environment variable copy:
    >>> from clonebuildregister.cloneRepo import cloneRepo
    >>> cloneRepo("cbcunc", "timage", "develop", "path_to_secrets", "path_in_repo_to_env_file") # github_org, repo_name, branch_or_tag
    >>>
Use the module registerImage:
    >>> # don't forget to authenticate to gcloud within your shell before trying this command
    >>> from clonebuildregister.registerImage import registerImage
    >>> response = registerImage("testimage", "v2", "test-image-out", "v1", "us-east1", "bimage-project", "bimage-repository")
    >>> 

How to configure clonebuildregister with gcloud as a developer
**************************************************************
1. Create an account with Google Cloud at https://cloud.google.com 
2. Create a new project called bimage-project
3. Go to the google cloud artifact registry and create a repository called bimage-repository ensure the repository zone is us-east1
4. From there goto the terminal where you cloned bimage and ensure you have the gcloud CLI installed https://cloud.google.com/sdk/docs/install
5. Make sure add to path and run $ gcloud init, ensuring you choose bimage-project
6. Also ensure to run $ gcloud auth login, if needed
7. Make sure $ cat ~/.docker/config.json contains us-east1. If not run $ gcloud auth configure-docker us-east1-docker.pkg.dev to add it.
8. The test cases should now work assuming you also have docker running in the background and have already run $ python setup.py develop

Install Python dependencies
***************************
1. Navigate to clonebuildregister top-level folder
2. Create a python environment so that your default environment doesn't get cluttered
3. Install dependencies using $ pip install . (doesn't include pytest or tox, see "Run Tests section for that")
4. Ensure you have Docker installed.

Run Tests
*********
1. Navigate to clonebuildregister top-level folder
2. Ensure you have google cloud, docker, and the required dependencies.
3. Make sure clonebuildregister/test/testing_variables.py has the correct values for the setup you have.
4. $ pip install -e '.[dev]'
5. Run $ pytest to run test in local environment
6. Run $ tox to run test for python environments 3.8, 3.9. 3.10, 3.11, and 3.12. Along with linting, type checking, and style checking
7. Run $ tox -e style to just do style checking
8. $ tox -e lint for just linting.
9. $ tox -e type for just type checking


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "clonebuildregister",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "docker, google cloud, artifact registry, build, clone, git, register, upload, image",
    "author": null,
    "author_email": "Jude Sproul <judesproul@gmail.com>, Chris Calloway <cbc@unc.edu>",
    "download_url": "https://files.pythonhosted.org/packages/e3/80/c6873a8db74fe516e5dcc8bd72043d187984793738f542b3c2158a471ef1/clonebuildregister-0.0.7.tar.gz",
    "platform": null,
    "description": "\n******************\nclonebuildregister\n******************\n\nClones a repository, builds a docker image from that repository, and then pushes that image to google cloud artifact registry\n\nTo use clonebuildregister as a package:\n\n    >>> from clonebuildregister.clonebuildregister import clonebuildregister\n    >>> clonebuildregister(\"cbcunc\", \"timage\", \"develop\", \"testimage\", \"v1\", \"timage\", \"testimage\", \"v1\", \"us-east1\", \"bimage-project\", \"bimage-repository\")\n    >>>\n\nTo use clonebuildregister as a script:\n\n    usage: clonebuildregister [-h] [-v] [-l PATH_TO_LOCAL_ENVIRONMENT] [-r PATH_TO_REMOTE_ENVIRONMENT] [-p PLATFORM] [-cn CLONE_NAME] [-dr DELETE_REPOSITORY]\n                          [-di DELETE_ALL_DOCKER_IMAGES]\n                          github_org repo_name branch_or_tag local_image_name local_image_tag path_to_dockerfile target_image_name target_image_tag region\n                          gcloudProjectId repositoryName\n\n\npositional arguments:\n  :github_org:            The GitHub organization of the repository\n  :repo_name:             The name of the repository in the organization\n  :branch_or_tag:         The branch or tag of the repository\n  :local_image_name:      The name of the image we create locally from the Dockerfile\n  :local_image_tag:       The tag of the image we create locally from the Dockerfile (v1, 1.0.1, version2.0)\n  :path_to_dockerfile:    The path to the docker file from the repository we cloned, usually the name of the repository\n  :target_image_name:     The target image name, i.e. the name of the image we store in the google cloud artifact registry\n  :target_image_tag:      The target image tag, i.e. the tag of the image we store in the google cloud artifact registry (v1, 1.0.1, version2.0)\n  :region:                Region the image will be stored in the google cloud (e.g. us-east1, us, eu)\n  :gcloudProjectId:       The project id from which the image will be stored under in a google artifact registry\n  :repositoryName:        The name of the google cloud artifact registry that holds docker images\n\noptions:\n\n  -h, --help            show this help message and exit\n\n  -v, --version         show program's version number and exit\n\n  -l PATH_TO_LOCAL_ENVIRONMENT, --path_to_local_environment PATH_TO_LOCAL_ENVIRONMENT\n                        The path to a local environment file with secrets not to be seen on github (e.g usr/home/clonebuildregister/.env). Defaults to . (default: )\n\n  -r PATH_TO_REMOTE_ENVIRONMENT, --path_to_remote_environment PATH_TO_REMOTE_ENVIRONMENT\n                        The path to the dummy environment files found on github (e.g usr/home/clonebuildregister/.env). Defaults to . (default: )\n\n  -p PLATFORM, --platform PLATFORM\n                        The target platform of the image in the form of os[/arch[/variant]] (default: )\n\n  -cn CLONE_NAME, --clone_name CLONE_NAME\n                        The name of the top level folder of the github repository will be named after cloning. (default: )\n\n  -dr DELETE_REPOSITORY, --delete_repository DELETE_REPOSITORY\n                        Boolean that tells the program to delete the github repository that it clones after it registers it to the google cloud AR (default: False)\n\n  -di DELETE_ALL_DOCKER_IMAGES, --delete_all_docker_images DELETE_ALL_DOCKER_IMAGES\n                        Boolean that tells the program to delete all docker images on the local system after the program puts the image on the google cloud artifact registry. Deletes using force. Similar to running this $ docker rmi -f $(docker images -aq) (default: False)\n\n    example:\n        $ python -m clonebuildregister cbcunc timage develop testimage v1 timage testimage v1 us-east1 bimage-project bimage-repository\n\nUse modules of clonebuildregister\n*********************************\nUse the module buildImage:\n    >>> from clonebuildregister.buildImage import buildImage\n    >>> image = buildImage(\"testimage:v1\",\"\") # if Dockerfile in current directory, use 2nd argument as target directory\n    >>>\nUse the module cloneRepo:\n    >>> from clonebuildregister.cloneRepo import cloneRepo\n    >>> cloneRepo(\"cbcunc\", \"timage\", \"develop\") # github_org, repo_name, branch_or_tag\n    >>>\nUse the module cloneRepo with environment variable copy:\n    >>> from clonebuildregister.cloneRepo import cloneRepo\n    >>> cloneRepo(\"cbcunc\", \"timage\", \"develop\", \"path_to_secrets\", \"path_in_repo_to_env_file\") # github_org, repo_name, branch_or_tag\n    >>>\nUse the module registerImage:\n    >>> # don't forget to authenticate to gcloud within your shell before trying this command\n    >>> from clonebuildregister.registerImage import registerImage\n    >>> response = registerImage(\"testimage\", \"v2\", \"test-image-out\", \"v1\", \"us-east1\", \"bimage-project\", \"bimage-repository\")\n    >>> \n\nHow to configure clonebuildregister with gcloud as a developer\n**************************************************************\n1. Create an account with Google Cloud at https://cloud.google.com \n2. Create a new project called bimage-project\n3. Go to the google cloud artifact registry and create a repository called bimage-repository ensure the repository zone is us-east1\n4. From there goto the terminal where you cloned bimage and ensure you have the gcloud CLI installed https://cloud.google.com/sdk/docs/install\n5. Make sure add to path and run $ gcloud init, ensuring you choose bimage-project\n6. Also ensure to run $ gcloud auth login, if needed\n7. Make sure $ cat ~/.docker/config.json contains us-east1. If not run $ gcloud auth configure-docker us-east1-docker.pkg.dev to add it.\n8. The test cases should now work assuming you also have docker running in the background and have already run $ python setup.py develop\n\nInstall Python dependencies\n***************************\n1. Navigate to clonebuildregister top-level folder\n2. Create a python environment so that your default environment doesn't get cluttered\n3. Install dependencies using $ pip install . (doesn't include pytest or tox, see \"Run Tests section for that\")\n4. Ensure you have Docker installed.\n\nRun Tests\n*********\n1. Navigate to clonebuildregister top-level folder\n2. Ensure you have google cloud, docker, and the required dependencies.\n3. Make sure clonebuildregister/test/testing_variables.py has the correct values for the setup you have.\n4. $ pip install -e '.[dev]'\n5. Run $ pytest to run test in local environment\n6. Run $ tox to run test for python environments 3.8, 3.9. 3.10, 3.11, and 3.12. Along with linting, type checking, and style checking\n7. Run $ tox -e style to just do style checking\n8. $ tox -e lint for just linting.\n9. $ tox -e type for just type checking\n\n",
    "bugtrack_url": null,
    "license": "BSD 3-Clause License  Copyright (c) 2023, Jude Sproul  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ",
    "summary": "A package to clone a Git repository, build it's image using Docker, and then register it to the Google Artifact Registry.",
    "version": "0.0.7",
    "project_urls": {
        "Homepage": "https://github.com/cznethub/clonebuildregister",
        "Issues": "https://github.com/cznethub/clonebuildregister/issues"
    },
    "split_keywords": [
        "docker",
        " google cloud",
        " artifact registry",
        " build",
        " clone",
        " git",
        " register",
        " upload",
        " image"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "df09fdf28ba087e4bc89f9eaa6c66fdc6d41efac240fcddfc4552525b25b4456",
                "md5": "2c52e9d77f263e8591f45544d296181f",
                "sha256": "dc3657c570ba8161ed4e1775e169799ca59aaca5b5e610d7078bacb8d432c071"
            },
            "downloads": -1,
            "filename": "clonebuildregister-0.0.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2c52e9d77f263e8591f45544d296181f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 13525,
            "upload_time": "2024-06-25T16:14:19",
            "upload_time_iso_8601": "2024-06-25T16:14:19.888783Z",
            "url": "https://files.pythonhosted.org/packages/df/09/fdf28ba087e4bc89f9eaa6c66fdc6d41efac240fcddfc4552525b25b4456/clonebuildregister-0.0.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e380c6873a8db74fe516e5dcc8bd72043d187984793738f542b3c2158a471ef1",
                "md5": "b536a60be31ddc6f05c454028c1185af",
                "sha256": "2d61e0995fa33dcf02b5001bc6d2d42c43e5a1ff5ddfadcf4d4e2bd57f292724"
            },
            "downloads": -1,
            "filename": "clonebuildregister-0.0.7.tar.gz",
            "has_sig": false,
            "md5_digest": "b536a60be31ddc6f05c454028c1185af",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 17852,
            "upload_time": "2024-06-25T16:14:47",
            "upload_time_iso_8601": "2024-06-25T16:14:47.067017Z",
            "url": "https://files.pythonhosted.org/packages/e3/80/c6873a8db74fe516e5dcc8bd72043d187984793738f542b3c2158a471ef1/clonebuildregister-0.0.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-25 16:14:47",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cznethub",
    "github_project": "clonebuildregister",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "tox": true,
    "lcname": "clonebuildregister"
}
        
Elapsed time: 0.28291s