2019-06-07 08:52:53 +00:00
|
|
|
DOCKER_NAMESPACE := victoriametrics
|
2019-12-09 20:52:51 +00:00
|
|
|
BUILDER_IMAGE := local/builder:go1.13.5
|
2019-11-29 16:24:39 +00:00
|
|
|
CERTS_IMAGE := local/certs:1.0.3
|
2019-05-22 21:16:55 +00:00
|
|
|
|
|
|
|
package-certs:
|
|
|
|
(docker image ls --format '{{.Repository}}:{{.Tag}}' | grep -q '$(CERTS_IMAGE)') \
|
|
|
|
|| docker build -t $(CERTS_IMAGE) deployment/docker/certs
|
|
|
|
|
|
|
|
package-builder:
|
|
|
|
(docker image ls --format '{{.Repository}}:{{.Tag}}' | grep -q '$(BUILDER_IMAGE)') \
|
|
|
|
|| docker build -t $(BUILDER_IMAGE) deployment/docker/builder
|
|
|
|
|
|
|
|
app-via-docker: package-certs package-builder
|
|
|
|
mkdir -p gocache-for-docker
|
|
|
|
docker run --rm \
|
|
|
|
--user $(shell id -u):$(shell id -g) \
|
|
|
|
--mount type=bind,src="$(shell pwd)",dst=/VictoriaMetrics \
|
|
|
|
-w /VictoriaMetrics \
|
|
|
|
--mount type=bind,src="$(shell pwd)/gocache-for-docker",dst=/gocache \
|
|
|
|
--env GOCACHE=/gocache \
|
2019-05-26 20:19:34 +00:00
|
|
|
--env GO111MODULE=on \
|
2019-07-23 16:54:50 +00:00
|
|
|
$(DOCKER_OPTS) \
|
2019-05-22 21:16:55 +00:00
|
|
|
$(BUILDER_IMAGE) \
|
2019-09-13 19:43:56 +00:00
|
|
|
go build $(RACE) -mod=vendor -trimpath -ldflags "-s -w -extldflags '-static' $(GO_BUILDINFO)" -tags 'netgo osusergo' \
|
|
|
|
-o bin/$(APP_NAME)$(APP_SUFFIX)-prod $(PKG_PREFIX)/app/$(APP_NAME)
|
2019-05-22 21:16:55 +00:00
|
|
|
|
|
|
|
package-via-docker:
|
|
|
|
(docker image ls --format '{{.Repository}}:{{.Tag}}' | grep -q '$(DOCKER_NAMESPACE)/$(APP_NAME):$(PKG_TAG)$(RACE)') || (\
|
|
|
|
$(MAKE) app-via-docker && \
|
|
|
|
docker build -t $(DOCKER_NAMESPACE)/$(APP_NAME):$(PKG_TAG)$(RACE) -f app/$(APP_NAME)/deployment/Dockerfile .)
|
|
|
|
|
|
|
|
publish-via-docker: package-via-docker
|
|
|
|
docker push $(DOCKER_NAMESPACE)/$(APP_NAME):$(PKG_TAG)$(RACE)
|
|
|
|
docker tag $(DOCKER_NAMESPACE)/$(APP_NAME):$(PKG_TAG)$(RACE) $(DOCKER_NAMESPACE)/$(APP_NAME):latest
|
|
|
|
docker push $(DOCKER_NAMESPACE)/$(APP_NAME):latest
|
|
|
|
|
|
|
|
run-via-docker: package-via-docker
|
|
|
|
docker run -it --rm \
|
|
|
|
--user $(shell id -u):$(shell id -g) \
|
|
|
|
--net host \
|
|
|
|
$(DOCKER_OPTS) \
|
|
|
|
$(DOCKER_NAMESPACE)/$(APP_NAME):$(PKG_TAG)$(RACE) $(ARGS)
|
|
|
|
|
|
|
|
remove-docker-images:
|
|
|
|
docker image ls --format '{{.Repository}}\t{{.ID}}' | grep $(DOCKER_NAMESPACE)/ | grep -v /builder | awk '{print $$2}' | xargs docker image rm -f
|