build-node-docker.sh 994 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. CODE_HASH=`scripts/runtime-code-shasum.sh`
  6. IMAGE=joystream/node:${CODE_HASH}
  7. FEATURES=
  8. if [[ "$RUNTIME_PROFILE" == "TESTING" ]]; then
  9. FEATURES="testing_runtime"
  10. fi
  11. if [[ "$RUNTIME_PROFILE" == "STAGING" ]]; then
  12. FEATURES="staging_runtime"
  13. fi
  14. if [[ "$RUNTIME_PROFILE" == "PLAYGROUND" ]]; then
  15. FEATURES="playground_runtime"
  16. fi
  17. # Look for image locally
  18. if ! docker inspect ${IMAGE} > /dev/null;
  19. then
  20. # Not found, try to fetch from remote repo
  21. echo "Trying to fetch cached ${IMAGE} image"
  22. docker pull ${IMAGE} || :
  23. # If we didn't find it, build it
  24. if ! docker inspect ${IMAGE} > /dev/null;
  25. then
  26. echo "Building ${IMAGE}.."
  27. docker build . --file joystream-node.Dockerfile \
  28. --tag ${IMAGE} \
  29. --build-arg CARGO_FEATURES=${FEATURES}
  30. fi
  31. else
  32. echo "Found ${IMAGE} in local repo"
  33. fi