3 ms·
You can create this type of thing (a self-contained single-file project) for any language or infrastructure, with or without a clever shebang. All you need are
by lwneal 3y ago
You can create this type of thing (a self-contained single-file project) for any language or infrastructure, with or without a clever shebang. All you need are heredocs.
For example, here's the same app but packaged as a regular bash script:
https://gist.github.com/lwneal/a24ba363d9cc9f7a02282c3621afa43d https://gist.github.com/lwneal/a24ba363d9cc9f7a02282c3621afa...
- adtac 3y agoOf course! Bash script is Turing complete so it should be possible to implement everything in it :) The only upside to having an executable Dockerfile is that it's still a valid Dockerfile that you can use with docker build, docker-compose, etc. in addition to being able to execute it.
- bcjordan 3y agoYes I love this approach, I use this exact format as a way to get ChatGPT to work with an entire multi file programming project in a single idempotent bootstrapping script. Then ask for changes to be given as the entire file again
- richdougherty 3y agoAgree, nesting files with cat >Dockerfile <<'EOF' and having a basic bash script seems way nicer than putting all the shell logic on the #! line.