Skip to content

Commit

Permalink
fix docker build in production.
Browse files Browse the repository at this point in the history
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
  • Loading branch information
appleboy committed May 4, 2016
1 parent 25a152b commit c0e3a87
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ html:
go tool cover -html=coverage.out

docker_build: clean
tar -zcvf build.tar.gz gorush.go gorush
tar -zcvf build.tar.gz gorush.go gorush config storage Makefile glide.lock glide.yaml
docker build --rm -t $(BUILD_IMAGE) -f docker/Dockerfile.build .
docker run --rm $(BUILD_IMAGE) > gorush.tar.gz
docker build --rm -t $(PRODUCTION_IMAGE) -f docker/Dockerfile.dist .
Expand Down
11 changes: 6 additions & 5 deletions docker/Dockerfile.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ FROM golang:1.6-alpine

MAINTAINER Bo-Yi Wu <appleboy.tw@gmail.com>

RUN apk --update add git
RUN mkdir -p /tmp/build
Add build.tar.gz /tmp/build/
WORKDIR /tmp/build
RUN go get -v -d
RUN apk --update add git make
RUN go get github.com/Masterminds/glide && cd $GOPATH/src/github.com/Masterminds/glide && make install
RUN mkdir -p $GOPATH/src/github.com/appleboy/gorush
Add build.tar.gz $GOPATH/src/github.com/appleboy/gorush/
WORKDIR $GOPATH/src/github.com/appleboy/gorush
RUN make bundle
RUN GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o bin/gorush gorush.go

CMD tar -C bin -czf - gorush
2 changes: 1 addition & 1 deletion docker/Dockerfile.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RUN apk update && apk upgrade \

RUN mkdir /app
ADD gorush.tar.gz /app/
ADD config/config.yml /app/config
ADD config/config.yml /app/config/
WORKDIR /app
ENTRYPOINT ["./gorush", "-c", "config/config.yml"]
EXPOSE 8088
2 changes: 1 addition & 1 deletion script/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ for GOOS in $OS; do
(test "$GOOS" = "windows") && EXE="gorush.exe"

echo "Build: ${GOOS}, Arch: ${GOARCH}, EXE: ${EXE}"
GOOS=$GOOS GOARCH=$GOARCH go build -ldflags="-w" -o bin/$GOOS/$GOARCH/${EXE} gorush.go;
GOOS=$GOOS GOARCH=$GOARCH go build -ldflags="-s -w" -o bin/$GOOS/$GOARCH/${EXE} gorush.go;
tar -C bin/$GOOS/$GOARCH -czf bin/gorush-$VERSION-$GOOS-$GOARCH.tar.gz gorush
done
done

0 comments on commit c0e3a87

Please sign in to comment.