-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify and shrink Dockerfile to use alpine
Add Makefile to simplify the build process. Signed-off-by: Byron Ruth <b@devel.io>
- Loading branch information
Showing
2 changed files
with
52 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
FROM golang:1.7-onbuild | ||
FROM alpine:3.5 | ||
|
||
WORKDIR / | ||
COPY ./dist/linux-amd64/prometheus-sql / | ||
|
||
EXPOSE 8080 | ||
|
||
ENTRYPOINT ["app", "-host", "0.0.0.0"] | ||
ENTRYPOINT ["/prometheus-sql", "-host", "0.0.0.0"] | ||
|
||
# Default command assumes the SQL agent is linked. | ||
CMD ["-service", "http://sqlagent:5000"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
PROG_NAME := "prometheus-sql" | ||
IMAGE_NAME := "dbhi/prometheus-sql" | ||
CMD_PATH := "." | ||
|
||
GIT_SHA := $(shell git log -1 --pretty=format:"%h" .) | ||
GIT_TAG := $(shell git describe --tags --exact-match . 2>/dev/null) | ||
GIT_BRANCH := $(shell git symbolic-ref -q --short HEAD) | ||
GIT_VERSION := $(shell git log -1 --pretty=format:"%h (%ci)" .) | ||
|
||
build: | ||
go build -ldflags "-X \"main.buildVersion=$(GIT_VERSION)\"" \ | ||
-o $(GOPATH)/bin/$(PROG_NAME) $(CMD_PATH) | ||
|
||
dist-build: | ||
mkdir -p dist | ||
|
||
gox -output="./dist/{{.OS}}-{{.Arch}}/$(PROG_NAME)" \ | ||
-ldflags "-X \"main.buildVersion=$(GIT_VERSION)\"" \ | ||
-os "windows linux darwin" \ | ||
-arch "amd64" $(CMD_PATH) > /dev/null | ||
|
||
dist-zip: | ||
cd dist && zip $(PROG_NAME)-darwin-amd64.zip darwin-amd64/* | ||
cd dist && zip $(PROG_NAME)-linux-amd64.zip linux-amd64/* | ||
cd dist && zip $(PROG_NAME)-windows-amd64.zip windows-amd64/* | ||
|
||
dist: dist-build dist-zip | ||
|
||
docker: | ||
docker build -t ${IMAGE_NAME}:${GIT_SHA} . | ||
docker tag ${IMAGE_NAME}:${GIT_SHA} ${IMAGE_NAME}:${GIT_BRANCH} | ||
if [ -n "${GIT_TAG}" ] ; then \ | ||
docker tag ${IMAGE_NAME}:${GIT_SHA} ${IMAGE_NAME}:${GIT_TAG} ; \ | ||
fi; | ||
if [ "${GIT_BRANCH}" == "master" ]; then \ | ||
docker tag ${IMAGE_NAME}:${GIT_SHA} ${IMAGE_NAME}:latest ; \ | ||
fi; | ||
|
||
docker-push: | ||
docker push ${IMAGE_NAME}:${GIT_SHA} | ||
docker push ${IMAGE_NAME}:${GIT_BRANCH} | ||
if [ -n "${GIT_TAG}" ]; then \ | ||
docker push ${IMAGE_NAME}:${GIT_TAG} ; \ | ||
fi; | ||
if [ "${GIT_BRANCH}" == "master" ]; then \ | ||
docker push ${IMAGE_NAME}:latest ; \ | ||
fi; | ||
|
||
.PHONY: build dist-build dist |