top | item 38993127

(no title)

lwneal | 2 years 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/a24ba363d9cc9f7a02282c3621afa...

discuss

order

adtac|2 years ago

Of 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|2 years ago

Yes 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|2 years ago

Agree, nesting files with

    cat >Dockerfile <<'EOF'
and having a basic bash script seems way nicer than putting all the shell logic on the #! line.