Skip to content

Commit

Permalink
Smaller docker images
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeffail committed Apr 21, 2018
1 parent bdb24ed commit 7b84470
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,19 @@ PATHINSTDOCKER = $(DEST_DIR)/docker
VERSION := $(shell git describe --tags || echo "v0.0.0")
DATE := $(shell date +"%c" | tr ' :' '__')

LDFLAGS = -X $(BENTHOS_PATH)/lib/util/service.Version=$(VERSION) \
VER_FLAGS = -X $(BENTHOS_PATH)/lib/util/service.Version=$(VERSION) \
-X $(BENTHOS_PATH)/lib/util/service.DateBuilt=$(DATE)

LD_FLAGS =

APPS = benthos
all: $(APPS)

$(PATHINSTBIN)/benthos: $(wildcard lib/*/*.go lib/*/*/*.go lib/*/*/*/*.go cmd/benthos/*.go)

$(PATHINSTBIN)/%: deps
@mkdir -p $(dir $@)
@go build -tags "$(TAGS)" -ldflags "$(LDFLAGS)" -o $@ ./cmd/$*
@go build -tags "$(TAGS)" -ldflags "$(LD_FLAGS) $(VER_FLAGS)" -o $@ ./cmd/$*

$(APPS): %: $(PATHINSTBIN)/%

Expand Down
6 changes: 5 additions & 1 deletion resources/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ FROM golang:latest
WORKDIR /go/src/github.com/Jeffail/benthos/
COPY . /go/src/github.com/Jeffail/benthos/

RUN CGO_ENABLED=0 GOOS=linux make
RUN apt-get update
RUN apt-get install -y upx-ucl

RUN CGO_ENABLED=0 GOOS=linux make LD_FLAGS="-s -w"
RUN upx ./target/bin/benthos

FROM scratch

Expand Down

0 comments on commit 7b84470

Please sign in to comment.