Add Docker file. Add Docker usage information.

This commit is contained in:
Johan Steenhoven 2018-08-06 11:45:29 +02:00
parent 85e76e7d16
commit 7bedf28829
2 changed files with 24 additions and 0 deletions

14
Dockerfile Normal file

@ -0,0 +1,14 @@
FROM alpine:3.8 as builder
WORKDIR /build
ADD https://api.github.com/repos/anordal/shellharden/compare/master...HEAD /dev/null
RUN apk add --no-cache cargo git
RUN git clone https://github.com/anordal/shellharden
RUN cd shellharden && cargo build --release
FROM alpine:3.8
RUN apk add --no-cache libgcc
COPY --from=builder /build/shellharden/target/ /
ENTRYPOINT ["/release/shellharden"]
CMD ["--help"]

@ -63,6 +63,16 @@ Don't apply `--transform` blindly; code review is still necessary: A script that
In that unlucky case, ask yourself whether the script has any business in doing that. All too often, it's just a product of classical shellscripting, and would be better off rewritten, such as by using arrays. Even in the opposite case, say the business logic involves word splitting; that can still be done without invoking globbing. In short: There is always a better way than the forbidden syntax (if not more explicit), but some times, a human must step in to rewrite. See how, in the accompanying [how to do things safely in bash](how_to_do_things_safely_in_bash.md).
Building in Docker
To build a docker container with Shellharden:
```
docker build -t shellgarden:4.0 .
```
To run Shellharden in a Docker container:
```
cat shellscript.sh | docker run -i --rm sbkg0002/shellharden:4.0 ''
```
[1]: http://mywiki.wooledge.org/BashPitfalls
[2]: https://www.shellcheck.net/
[3]: http://stackoverflow.com/questions/41104131/tool-to-automatically-rewrite-a-bash-script-with-proper-quoting