1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- #!/usr/bin/bash
- read -r -d '' START << EOM
- FROM debian:latest
- RUN apt update -y
- EOM
- read -r -d '' END << EOM
- RUN apt-get clean autoclean
- RUN apt-get autoremove --yes
- RUN rm -rf /var/lib/{apt,dpkg,cache,log}/
- RUN useradd -m user
- USER user
- WORKDIR /home/user
- EOM
- cd langs
- for dir in */
- do
- dir="${dir%*/}"
- if podman image exists "$dir-runner"; then
- continue
- fi
- if [ -f "$dir/Dockerfile.user" ]; then
- template_user="$(cat $dir/Dockerfile.user)"
- else
- template_user=""
- fi
- template="$(cat $dir/Dockerfile)"
- run_sh="$(cat $dir/run.sh)"
- echo "#!/usr/bin/bash
- if [ \"\$1\" = \"--init\" ]; then
- bash -
- fi
- $run_sh
- " > "Run$dir.sh"
- echo "$START
- $template
- COPY Run$dir.sh /usr/bin/run
- RUN chmod +x /usr/bin/run
- RUN chmod 705 /usr/bin/run
- $END
- $template_user
- ENTRYPOINT [\"/usr/bin/run\"]" > Dockerfile
- podman build -t "$dir-runner" .
- rm Dockerfile
- rm "Run$dir.sh"
- done
- cd ..
|