update makefile.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
becb322c10
commit
085d19832a
|
@ -39,8 +39,6 @@ script:
|
|||
after_success:
|
||||
- test "$TRAVIS_BRANCH" == "master" && test "$TRAVIS_GO_VERSION" == "1.6.3"
|
||||
&& test "$TRAVIS_PULL_REQUEST" == "false" && docker login -e="$DOCKER_EMAIL" -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
|
||||
- test "$TRAVIS_BRANCH" == "master" && test "$TRAVIS_GO_VERSION" == "1.6.3"
|
||||
&& test "$TRAVIS_PULL_REQUEST" == "false" && cd $TRAVIS_BUILD_DIR && make docker_build
|
||||
- test "$TRAVIS_BRANCH" == "master" && test "$TRAVIS_GO_VERSION" == "1.6.3"
|
||||
&& test "$TRAVIS_PULL_REQUEST" == "false" && cd $TRAVIS_BUILD_DIR && make deploy tag=latest
|
||||
- bash <(curl -s https://codecov.io/bash) -f .cover/coverage.txt
|
||||
|
|
21
Makefile
21
Makefile
|
@ -9,6 +9,12 @@ VERSION := $(shell git describe --tags)
|
|||
TARGETS_NOVENDOR := $(shell glide novendor)
|
||||
export PROJECT_PATH = /go/src/github.com/appleboy/gorush
|
||||
|
||||
ifneq ($(shell uname), Darwin)
|
||||
EXTLDFLAGS = -extldflags "-static" $(null)
|
||||
else
|
||||
EXTLDFLAGS =
|
||||
endif
|
||||
|
||||
all: build
|
||||
|
||||
init:
|
||||
|
@ -28,6 +34,9 @@ install:
|
|||
update:
|
||||
glide update
|
||||
|
||||
build_static:
|
||||
go build -ldflags="${EXTLDFLAGS}-s -w -X main.Version=${VERSION}" -o bin/gorush gorush.go
|
||||
|
||||
build: clean
|
||||
sh script/build.sh $(VERSION)
|
||||
|
||||
|
@ -58,14 +67,10 @@ docker_build: clean
|
|||
docker build --rm -t $(BUILD_IMAGE) -f docker/Dockerfile.tmp .
|
||||
docker run --rm $(BUILD_IMAGE) > gorush.tar.gz
|
||||
|
||||
docker_test: init clean
|
||||
docker-compose -p ${PRODUCTION_IMAGE} -f docker/docker-compose.testing.yml run gorush
|
||||
docker-compose -p ${PRODUCTION_IMAGE} -f docker/docker-compose.testing.yml down
|
||||
|
||||
docker_production: docker_build
|
||||
docker_production:
|
||||
docker build --rm -t $(PRODUCTION_IMAGE) -f docker/Dockerfile.dist .
|
||||
|
||||
deploy: docker_production
|
||||
deploy: docker_build docker_production
|
||||
ifeq ($(tag),)
|
||||
@echo "Usage: make $@ tag=<tag>"
|
||||
@exit 1
|
||||
|
@ -73,6 +78,10 @@ endif
|
|||
docker tag $(PRODUCTION_IMAGE):latest $(DEPLOY_ACCOUNT)/$(PRODUCTION_IMAGE):$(tag)
|
||||
docker push $(DEPLOY_ACCOUNT)/$(PRODUCTION_IMAGE):$(tag)
|
||||
|
||||
docker_test: init clean
|
||||
docker-compose -p ${PRODUCTION_IMAGE} -f docker/docker-compose.testing.yml run gorush
|
||||
docker-compose -p ${PRODUCTION_IMAGE} -f docker/docker-compose.testing.yml down
|
||||
|
||||
fmt:
|
||||
@echo $(TARGETS_NOVENDOR) | xargs go fmt
|
||||
|
||||
|
|
|
@ -7,6 +7,6 @@ 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 install
|
||||
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-s -w -X main.Version=${VERSION}" -o bin/gorush gorush.go
|
||||
RUN CGO_ENABLED=0 make build_static
|
||||
|
||||
CMD tar -C bin -czf - gorush
|
||||
|
|
|
@ -1,14 +1,9 @@
|
|||
FROM alpine
|
||||
|
||||
MAINTAINER Bo-Yi Wu <appleboy.tw@gmail.com>
|
||||
|
||||
RUN apk update && apk upgrade \
|
||||
&& apk add ca-certificates \
|
||||
&& rm -rf /var/cache/apk/*
|
||||
|
||||
RUN mkdir /app
|
||||
ADD gorush.tar.gz /app/
|
||||
ADD config/config.yml /app/config/
|
||||
WORKDIR /app
|
||||
ENTRYPOINT ["./gorush", "-c", "config/config.yml"]
|
||||
FROM centurylink/ca-certs
|
||||
EXPOSE 8088
|
||||
|
||||
ADD config/config.yml /
|
||||
|
||||
ADD gorush.tar.gz /
|
||||
|
||||
ENTRYPOINT ["/gorush"]
|
||||
CMD ["-c", "config.yml"]
|
||||
|
|
|
@ -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="-s -w -X main.Version=${VERSION}" -o bin/$GOOS/$GOARCH/${EXE} gorush.go;
|
||||
GOOS=$GOOS GOARCH=$GOARCH CGO_ENABLED=0 go build -ldflags="-s -w -X main.Version=${VERSION}" -o bin/$GOOS/$GOARCH/${EXE} gorush.go;
|
||||
tar -C bin/$GOOS/$GOARCH -czf bin/gorush-$VERSION-$GOOS-$GOARCH.tar.gz gorush
|
||||
done
|
||||
done
|
||||
|
|
Loading…
Reference in New Issue