The asonix.dog mastodon downstream
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

build-images.sh 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/env bash
  2. set -xe
  3. SOURCE=$1
  4. TAG=$2
  5. require_input() {
  6. input=$1
  7. name=$2
  8. if [ "$input" == "" ]; then
  9. echo "Input, $name, required but not present"
  10. exit 1;
  11. fi
  12. }
  13. require_input "$SOURCE" "Dockerfile"
  14. require_input "$TAG" "container tag"
  15. ARCHITECTURES=('arm64v8' 'arm32v7' 'amd64')
  16. for architecture in "${ARCHITECTURES[@]}"; do
  17. cp "$SOURCE" "$SOURCE-$architecture"
  18. if [ "$architecture" == arm32v7 ]; then
  19. sed -i'' 's/:amd64/:arm32v7/g' "$SOURCE-$architecture" # source image
  20. sed -i'' 's/FROM amd64/FROM arm32v7/g' "$SOURCE-$architecture" # source image
  21. sed -i'' 's/x64/armv7l/g' "$SOURCE-$architecture" # for node
  22. sed -i'' 's/amd64/armhf/g' "$SOURCE-$architecture" # for tini
  23. fi
  24. if [ "$architecture" == arm64v8 ]; then
  25. sed -i'' 's/:amd64/:arm64v8/g' "$SOURCE-$architecture" # source image
  26. sed -i'' 's/FROM amd64/FROM arm64v8/g' "$SOURCE-$architecture" # source image
  27. sed -i'' 's/x64/arm64/g' "$SOURCE-$architecture" # for node
  28. sed -i'' 's/amd64/arm64/g' "$SOURCE-$architecture" # for tini
  29. fi
  30. buildah build-using-dockerfile -f "$SOURCE-$architecture" -t "$TAG:$architecture" .
  31. rm "$SOURCE-$architecture"
  32. done