There are two options:
-
If you are not using a docker image to start your nodes then you should deploy the chaincode by specifying a fully qualified path, in other words, you should set the parameter when deploying:
-p /home/user/my/awesome/chaincode
-
If you are running your nodes/peers in a docker image (like the instructions you are following to setup a development network) then you have two options:
The first one is to put your chaincode inside a folder in the path $GOPATH/src/github.com/hyperledger/fabric/peer. Then you can build your image (go test -run BuildImage_Peer).
Now the docker image will have the chaincode in its filesystem (you can check it by navigating in it by using docker run --rm -it -e CORE_VM_ENDPOINT=http://172.17.0.1:2375 -e CORE_PEER_ID=vp0 -e CORE_PEER_ADDRESSAUTODETECT=true hyperledger-peer /bin/bash).
Finally, to deploy the chaincode you have to set the path (parameter -p) to the folder that contains your chaincode, relative to $GOPATH/src/. This path would be: github.com/hyperledger/fabric/peer/yourfolderwiththecc.
The second option is similar (not tested yet), but it uses a shared filesystem between docker and vagrant to access the chaincode. The idea is to run the docker with something like -v local-dev:localdev, so that local-dev folder in the docker image is linked to vagrant's local-dev folder (where you should put your chaincode) and with -e GOPATH=/local-dev you set the GOPATH so that the relative path can start from the /local-dev folder.
Observation: the path with github.com might be confusing because it seems that it is getting the chaincode from Github, but it is just the folder name.
Important: to deploy a chaincode, only one peer needs to have available the chaincode file (the one where the deploy is sent), as the consensus is responsible of broadcasting the chaincode.
Credits to @ghaskins for his help figuring out how to do it