buildall.sh 949 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/usr/bin/bash
  2. read -r -d '' START << EOM
  3. FROM debian:latest
  4. RUN apt update -y
  5. EOM
  6. read -r -d '' END << EOM
  7. RUN apt-get clean autoclean
  8. RUN apt-get autoremove --yes
  9. RUN rm -rf /var/lib/{apt,dpkg,cache,log}/
  10. RUN useradd -m user
  11. USER user
  12. WORKDIR /home/user
  13. EOM
  14. cd langs
  15. for dir in */
  16. do
  17. dir="${dir%*/}"
  18. if podman image exists "$dir-runner"; then
  19. continue
  20. fi
  21. if [ -f "$dir/Dockerfile.user" ]; then
  22. template_user="$(cat $dir/Dockerfile.user)"
  23. else
  24. template_user=""
  25. fi
  26. template="$(cat $dir/Dockerfile)"
  27. run_sh="$(cat $dir/run.sh)"
  28. echo "#!/usr/bin/bash
  29. if [ \"\$1\" = \"--init\" ]; then
  30. bash -
  31. fi
  32. $run_sh
  33. " > "Run$dir.sh"
  34. echo "$START
  35. $template
  36. COPY Run$dir.sh /usr/bin/run
  37. RUN chmod +x /usr/bin/run
  38. RUN chmod 705 /usr/bin/run
  39. $END
  40. $template_user
  41. ENTRYPOINT [\"/usr/bin/run\"]" > Dockerfile
  42. podman build -t "$dir-runner" .
  43. rm Dockerfile
  44. rm "Run$dir.sh"
  45. done
  46. cd ..