dkr2sh
dkr2sh copied to clipboard
How to use this?
Yep, that's the issue ;-). Looks nice, and found this and another one here:
https://github.com/thatkevin/dockerfile-to-shell-script
Kevin's not proud of his (he says), but it's simple one shell script. What you have here puzzles me:
- the README fails to offer any tips on how to actually use it.
- To confound that, an examination reveals two oddly identical files
copy.shand `copy-from.sh - a sed script with not tips on how to use it
- a
sh2sed.shscript with no internal docs on use
The desire of a naive conversion is strong, and you've put a little more work into it than Kevin, certainly with ADD handling. But it's just a tiny bit of documentation and maybe housekeeping, short of being useful to others. Can I motivate you to add a little more documentation?
The file to use is dkr2sh.sed, which is a sed script, note how it starts:
#!/bin/sed -f
# Convert Dockerfile to shell script.
To use it, normal sed usage implies it takes stdin and outputs stdout. So:
./dkr2sh.sed < Dockerfile > mydockerscript.sh
Contributing:
The explanation of the tranform rules in the documentation matches the .sh files, copy-from.sh, copy.sh and add.sh
In the dkr2sh.sed file, the transform rules have been translated to sed patterns. The sh2sed.sh is the helper script that can do this as part of manual labour. You can change any of the patterns and run, eg. ./sh2sed.sh < copy-from.sh and you will get this:
for i in ARGS; do\n\ttest -d "$i" \&\& i="$i\/"\n\trsync -a "$i" DEST # FROM\ndone
It matches the replacement string in the dkr2sh.sed file, here, but with match groups inserted inplace of ARGS, DEST, FROM
s/^[[:space:]]*COPY\([[:space:]]\+--from=[^[:space:]]\+\)\(\([[:space:]]\+[^[:space:]]\+\)\+\)\([[:space:]]\+[^[:space:]]\+\)[[:space:]]*/for i in\2; do\n\ttest -d "$i" \&\& i="$i\/"\n\trsync -a "$i"\4 #\1\ndone/i
I don't really expect that this will get merged, so for any newcomers, take a look at the branched version here
https://github.com/dsschneidermann/dkr2sh