package: added helper scripts in docker/

This commit is contained in:
Dmitry Astapov 2019-01-30 00:46:16 +00:00 committed by Simon Michael
parent 5435150d39
commit 26624ef94c
4 changed files with 56 additions and 5 deletions

View File

@ -1,11 +1,28 @@
## Build instructions
## Instructions
Build slim container with binaries only
Build slim container with binaries only:
```
docker image build --rm --tag hledger .
./build.sh
```
Build container suitable for development
Build container suitable for development:
```
docker image build --tag hledger --target dev .
./build-dev.sh
```
Run hledger-web in the container:
```
./run.sh /path/to/your.journal web
```
Run shell in the container (your files will be in /data):
```
./run.sh /path/to/your.journal bash
```
Run hledger command in the container:
```
./run.sh /path/to/your.journal hledger [ARGS]
```
Script `start.sh` is included inside container and used to start `hledger-web`, there is no need to run it manually.

3
docker/build-dev.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
cd `git rev-parse --show-toplevel`
docker image build --tag hledger --target dev .

3
docker/build.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
cd `git rev-parse --show-toplevel`
docker image build --rm --tag hledger .

28
docker/run.sh Executable file
View File

@ -0,0 +1,28 @@
#!/bin/bash
set -e -o pipefail
function usage() {
echo "USAGE: $0 /path/to/hledger.journal [web|bash|hledger [hledger-args]]"
}
journal=$(readlink -f "$1")
shift
[ -f "$journal" ] || { usage; exit 1; }
dir=$(dirname $journal)
file=$(basename $journal)
cmd="$1"
shift
case "$cmd" in
web) extra_args="" ;;
bash) extra_args="bash" ;;
hledger) extra_args="hledger" ;;
*)usage; exit 1 ;;
esac
docker container run --rm -it --volume "$dir:/data" \
--env HLEDGER_FILE_NAME=/data/$file \
--env LEDGER_FILE=/data/$file \
-p 5000:5000 -p 5001:5001 \
hledger $extra_args "$@"