Skip to content

Commit ed1bbf7

Browse files
author
Oleg Sidorov
committed
Dockerfile entrypoint ensures dependencies and builds plugins
This patch extends Dockerfile entrypoint with plugin build action. Conventional location for plugin folder under container environment is /go/src/flowd/plugins. The entrypoint iteratively builds all plugins inside this folder. Docker build command example: docker build -t awesome-flow/flow:latest . Docker run command example: docker run -it -p 8080:8080 -p 7071:7071 --rm \ -v "${GOPATH}/src/github.com/awesome-flow/flow/examples:/etc/flowd/" \ awesome-flow/flow:latest \ -config.path=/etc/flowd/http2stdout-config.yml Signed-off-by: Oleg Sidorov <[email protected]>
1 parent f879f04 commit ed1bbf7

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

Diff for: .dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
vendor/*/.git
33
vendor/*/*/.git
44
vendor/*/*/*/.git
5+
builds/*

Diff for: Dockerfile

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
FROM golang:1.12-alpine
22
RUN apk add build-base
3+
RUN apk add git
34
WORKDIR /go/src/github.com/awesome-flow/flow/
45
ADD . .
6+
RUN go get -u github.com/golang/dep/cmd/dep
7+
RUN dep ensure
58
RUN make build
6-
ENTRYPOINT ["./builds/flowd"]
9+
ENTRYPOINT ["sh", "./docker/flowd-runner.sh"]

Diff for: docker/flowd-runner.sh

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
set -e
2+
3+
FLOWD=./builds/flowd
4+
PLUGIN_PATH="/go/src/flowd/plugins/"
5+
6+
build_plugin () {
7+
plugin="${1}"
8+
echo "Building plugin ${plugin}"
9+
cd "${plugin}"
10+
if test -f go.mod
11+
then
12+
go mod verify
13+
fi
14+
if test -d Gopkg.toml
15+
then
16+
dep ensure
17+
fi
18+
go build -buildmode=plugin
19+
cd ..
20+
}
21+
22+
if test -d ${PLUGIN_PATH}
23+
then
24+
oldpath=$(pwd)
25+
cd "${PLUGIN_PATH}"
26+
for p in $(ls -l .); do
27+
if test -d $p
28+
then
29+
build_plugin "${p}"
30+
fi
31+
done
32+
cd "${oldpath}"
33+
fi
34+
35+
echo "Launching flowd"
36+
dep ensure
37+
${FLOWD} -plugin.path="${PLUGIN_PATH}" $@

0 commit comments

Comments
 (0)