build-node-docker.sh 827 B

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/env bash
  2. set -e
  3. # Looks for a cached joystream/node image matching code shasum.
  4. # Search order: local repo then dockerhub. If no cached image is found we build it.
  5. SCRIPT_PATH="$(dirname "${BASH_SOURCE[0]}")"
  6. cd $SCRIPT_PATH
  7. source scripts/features.sh
  8. CODE_HASH=`scripts/runtime-code-shasum.sh`
  9. IMAGE=joystream/node:${CODE_HASH}
  10. # Look for image locally
  11. if ! docker inspect ${IMAGE} > /dev/null;
  12. then
  13. # Not found, try to fetch from remote repo
  14. echo "Trying to fetch cached ${IMAGE} image"
  15. docker pull ${IMAGE} || :
  16. # If we didn't find it, build it
  17. if ! docker inspect ${IMAGE} > /dev/null;
  18. then
  19. echo "Building ${IMAGE}.."
  20. docker build . --file joystream-node.Dockerfile \
  21. --tag ${IMAGE} \
  22. --build-arg CARGO_FEATURES=${FEATURES}
  23. fi
  24. else
  25. echo "Found ${IMAGE} in local repo"
  26. fi