Skip to content

Commit

Permalink
Dockerfile (#186)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickatsegment authored Feb 7, 2019
1 parent e64e264 commit 059f1d1
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM golang:1.11-alpine AS build

WORKDIR /go/src/github.com/segmentio/chamber
COPY . .

RUN apk add -U make git
RUN make linux

FROM scratch AS run

COPY --from=build /go/src/github.com/segmentio/chamber/chamber /chamber

ENTRYPOINT ["/chamber"]
22 changes: 21 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
# This makefile is meant for humans

VERSION := $(shell git describe --tags --always --dirty="-dev")
VERSION_MAJOR_MINOR_PATCH := $(shell git describe --tags --always --dirty="-dev" | sed 's/^v\([0-9]*.[0-9]*.[0-9]*\).*/\1/')
VERSION_MAJOR_MINOR := $(shell git describe --tags --always --dirty="-dev" | sed 's/^v\([0-9]*.[0-9]*\).*/\1/')
VERSION_MAJOR := $(shell git describe --tags --always --dirty="-dev" | sed 's/^v\([0-9]*\).*/\1/')
ANALYTICS_WRITE_KEY ?=
LDFLAGS := -ldflags='-X "main.Version=$(VERSION)" -X "main.AnalyticsWriteKey=$(ANALYTICS_WRITE_KEY)"'

Expand All @@ -22,10 +25,27 @@ dist/:
dist/chamber-$(VERSION)-darwin-amd64: | dist/
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 GO111MODULE=on go build $(LDFLAGS) -o $@

linux: dist/chamber-$(VERSION)-linux-amd64
cp $^ chamber

dist/chamber-$(VERSION)-linux-amd64: | dist/
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 GO111MODULE=on go build $(LDFLAGS) -o $@

dist/chamber-$(VERSION)-windows-amd64.exe: | dist/
GOOS=windows GOARCH=amd64 CGO_ENABLED=0 GO111MODULE=on go build $(LDFLAGS) -o $@

.PHONY: clean all
docker-image: docker-image-$(VERSION)

docker-image-$(VERSION):
docker build \
-t segment/chamber:$(VERSION_MAJOR_MINOR_PATCH) \
-t segment/chamber:$(VERSION_MAJOR_MINOR) \
-t segment/chamber:$(VERSION_MAJOR) \
.

docker-image-publish: docker-image
docker push segment/chamber:$(VERSION_MAJOR_MINOR_PATCH)
docker push segment/chamber:$(VERSION_MAJOR_MINOR)
docker push segment/chamber:$(VERSION_MAJOR)

.PHONY: clean all linux docker-image docker-image-$(VERSION) docker-image-publish
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ If you have a functional go environment, you can install with:
$ go get github.com/segmentio/chamber
```

[See the wiki for more installation options like Linux packages and precompiled binaries.](https://github.com/segmentio/chamber/wiki/Installation)
[See the wiki for more installation options like Docker images, Linux packages, and precompiled binaries.](https://github.com/segmentio/chamber/wiki/Installation)

## Authenticating

Expand Down

0 comments on commit 059f1d1

Please sign in to comment.