Skip to content

Commit

Permalink
improve: upd Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
robotomize committed May 31, 2021
1 parent 2142523 commit dcb45f9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ WORKDIR /src

COPY . .

ENV BUILD_INFO_PACKAGE=github.com/bloops-games/bloops/internal/buildinfo
ENV BUILD_NAME=bloopsbot-srv

RUN go build \
-trimpath \
-ldflags "-s -w -X main.version=$(git describe --tags --abbrev=0) -extldflags '-static'" \
-ldflags "-s -w -X $BUILD_INFO_PACKAGE.BuildTag=$(git describe --tags --abbrev=0) -X $BUILD_INFO_PACKAGE.Time=$(date -u '+%Y-%m-%d-%H:%M') -X $BUILD_INFO_PACKAGE.Name=$BUILD_NAME -extldflags '-static'" \
-installsuffix cgo \
-tags netgo \
-o /app/bot \
Expand Down
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ GO111MODULE?=on
BUILD_INFO_PACKAGE = github.com/bloops-games/bloops/internal/buildinfo
BUILD_TAG=$(shell git describe --tags --abbrev=0)
BUILD_TIME?=$(shell date -u '+%Y-%m-%d-%H:%M')
BUILD_NAME_CLI?= bloopsbot-cli
BUILD_NAME_SRV?= bloopsbot-srv
BUILD_NAME_CLI?=bloopsbot-cli
BUILD_NAME_SRV?=bloopsbot-srv

unittest:
@$(GO_CMD) test -short $$(go list ./... | grep -v /vendor/)
Expand All @@ -23,20 +23,21 @@ test:
test-cover:
@$(GO_CMD) test -count=2 -race -timeout=10m ./... -coverprofile=coverage.out

.PHONY: build
.PHONY: srv
srv:
GOARCH=${GOARCH} GO111MODULE=${GO111MODULE} CGO_ENABLED=0 GOOS=${GOOS} \
$(GO_CMD) build -o build/bloops-srv -trimpath \
-ldflags "-s -w -X ${BUILD_INFO_PACKAGE}.BuildTag=${BUILD_TAG} -X ${BUILD_INFO_PACKAGE}.Time=${BUILD_TIME} -X ${BUILD_INFO_PACKAGE}.Name=${BUILD_NAME_CLI}" \
./cmd/bloops-srv

.PHONY: cli
cli:
GOARCH=${GOARCH} GO111MODULE=${GO111MODULE} CGO_ENABLED=0 GOOS=${GOOS} \
$(GO_CMD) build -o build/bloops-cli -trimpath \
-ldflags "-s -w -X ${BUILD_INFO_PACKAGE}.BuildTag=${BUILD_TAG} -X ${BUILD_INFO_PACKAGE}.Time=${BUILD_TIME} -X ${BUILD_INFO_PACKAGE}.Name=${BUILD_NAME_CLI}" \
./cmd/bloops-cli

docker-dev:
docker:
@$(DOCKER) build -t bloops .

vet:
Expand Down

0 comments on commit dcb45f9

Please sign in to comment.