github.com/gocrane/crane@v0.11.0/docs/developer-guide.md (about)

     1  ---
     2  title: "Developer Guide"
     3  description: "Getting started to develop crane"
     4  date: 2022-08-21
     5  ---
     6  
     7  First, please make sure you've got a working [Go environment](https://golang.org/doc/install)
     8  and [Docker environment](https://docs.docker.com/engine).
     9  
    10  ## Clone crane
    11  
    12  Clone the repository,
    13  
    14  ```bash
    15  mkdir -p $GOPATH/src/github.com/gocrane/
    16  cd $GOPATH/src/github.com/gocrane/
    17  git clone https://github.com/gocrane/crane.git
    18  cd crane
    19  ```
    20  
    21  ## Building Binaries
    22  
    23  Run
    24  
    25  ```bash
    26  # build for linux/amd64 by default
    27  make all
    28  ```
    29  
    30  to build binaries `craned`, `crane-agent` and `metric-adapter` for `linux/amd64`.
    31  
    32  ![make_all_finish](images/developer-guide/make_all_finish.jpg)
    33  
    34  Also you could specify other platforms when building, such as,
    35  
    36  ```bash
    37  # build only crane-agent for linux/arm64 and darwin/amd64
    38  # use comma to separate multiple platforms
    39  PLATFORMS=linux/arm64,darwin/amd64 make crane-agent
    40  # below are all the supported platforms
    41  # PLATFORMS=darwin/amd64,darwin/arm64,linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/386,linux/arm
    42  ```
    43  
    44  All the built binaries will be placed at `$GOPATH/src/github.com/gocrane/crane/bin` folder.
    45  
    46  ![make_all_binaries_result](images/developer-guide/make_all_binaries_result.jpg)
    47  
    48  ## Building Docker Images
    49  
    50  You can also build docker images. Here `docker buildx` is used to help build multi-arch container images.
    51  
    52  If you're running MacOS, please install [Docker Desktop](https://docs.docker.com/desktop/) and then check the builder,
    53  
    54  ```bash
    55  $ docker buildx ls
    56  NAME/NODE DRIVER/ENDPOINT STATUS  PLATFORMS
    57  default * docker
    58    default default         running linux/amd64, linux/arm64, linux/ppc64le, linux/s390x, linux/386, linux/arm/v7, linux/arm/v6
    59  ```
    60  
    61  If you're running Linux, please refer to [docker buildx docs](https://docs.docker.com/buildx/working-with-buildx/)
    62  on the installation.
    63  
    64  !!! note
    65      For better `docker buildx` support, it is recommended to use Ubuntu Focal 20.04 (LTS), Debian Bullseye 11 and CentOS 8.
    66      And install deb/rpm package `qemu-user-static` as well, such as
    67  
    68      ```bash
    69      apt-get install qemu-user-static
    70      ```
    71      
    72      or
    73  
    74      ```bash
    75      yum install qemu-user-static
    76      ```
    77  
    78      ```bash
    79      # build for linux/amd64 by default
    80      # container images for craned, crane-agent, metric-adapter and dashboard
    81      make images
    82      ```
    83  
    84  ![make_image_start](images/developer-guide/make_image_start.jpg)
    85  
    86  ![make_image_finish](images/developer-guide/make_image_finish.jpg)
    87  
    88  Also you could build container images for other platforms, such as `arm64`,
    89  
    90  ```bash
    91  PLATFORMS=linux/amd64,linux/arm64,linux/ppc64le make images
    92  # below are all the supported platforms
    93  # PLATFORMS=linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/386,linux/arm
    94  ```
    95  
    96  !!! note
    97      For the first make image, It takes a bit of a long time, Please be patient.
    98  
    99  When we finish the make image, in the docker desktop, we can see the image we built, and the Tag is the hash value at the time of the git commit.
   100  
   101  ![make_image_docker_images](images/developer-guide/make_image_docker_images.jpg)