Skip to content
Permalink
Browse files

package: added helper scripts in docker/

  • Loading branch information...
adept authored and simonmichael committed Jan 30, 2019
1 parent 5435150 commit 26624ef94c68594115f236d66d7cf4fca6bd3009
Showing with 56 additions and 5 deletions.
  1. +22 −5 docker/README.md
  2. +3 −0 docker/build-dev.sh
  3. +3 −0 docker/build.sh
  4. +28 −0 docker/run.sh
@@ -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.
@@ -0,0 +1,3 @@
#!/bin/sh
cd `git rev-parse --show-toplevel`
docker image build --tag hledger --target dev .
@@ -0,0 +1,3 @@
#!/bin/sh
cd `git rev-parse --show-toplevel`
docker image build --rm --tag hledger .
@@ -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 "$@"

0 comments on commit 26624ef

Please sign in to comment.
You can’t perform that action at this time.