-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
55 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM ubuntu:18.04 | ||
RUN apt-get update && \ | ||
apt-get install -y --no-install-recommends ca-certificates=20180409 && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
COPY ./bin/engine . | ||
CMD [ "./engine" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
|
||
# script is use to use local go cache to speed up build | ||
# docker dosen't allow to mount volume during build, | ||
# so it always rebuild whole project. Use go build cache to | ||
# make docker build faster. | ||
|
||
set -e | ||
|
||
ENGINE_SUM_PATH="./bin/.engine.sum" | ||
DOCKER_SUM_PATH="./bin/.Dockerfile.dev.sum" | ||
|
||
echo "compile engine" | ||
GOOS=linux GOARCH=amd64 go build -o ./bin/engine core/main.go | ||
|
||
touch "$ENGINE_SUM_PATH" "$DOCKER_SUM_PATH" | ||
|
||
# check if engine bin was cached | ||
ENGINE_SUM="$(openssl md5 ./bin/engine)" | ||
ENGINE_SUM_PREV="$(cat $ENGINE_SUM_PATH)" | ||
if [[ "$ENGINE_SUM" == "$ENGINE_SUM_PREV" ]]; then | ||
BINCACHED=true | ||
else | ||
echo "$ENGINE_SUM" > "$ENGINE_SUM_PATH" | ||
fi | ||
|
||
# check if dockerfile was cached | ||
DOCKER_SUM="$(openssl md5 ./Dockerfile.dev)" | ||
DOCKER_SUM_PREV="$(cat $DOCKER_SUM_PATH)" | ||
if [[ "$DOCKER_SUM" == "$DOCKER_SUM_PREV" ]]; then | ||
DOCKERCACHED=true | ||
else | ||
echo "$DOCKER_SUM" > "$DOCKER_SUM_PATH" | ||
fi | ||
|
||
if [[ ! $BINCACHED ]] || [[ ! $DOCKERCACHED ]]; then | ||
echo "build mesg/engine image" | ||
docker build -f Dockerfile.dev -t "mesg/engine:local" . | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters