Skip to content
Permalink
Browse files

contrib: update docker build and docs

  • Loading branch information
narqo committed Dec 10, 2019
1 parent 7842716 commit 8cbce8fa543489699668c2c3de25303a26db6853
Showing with 40 additions and 32 deletions.
  1. +1 −0 .dockerignore
  2. +17 −9 Makefile
  3. +13 −12 README.md
  4. +3 −5 contrib/docker/Dockerfile
  5. +6 −6 contrib/docker/README.md
@@ -0,0 +1 @@
/BUILD
@@ -5,6 +5,8 @@ LDFLAGS :=
GOFLAGS :=
TESTFLAGS :=

DOCKER ?= docker

BUILDTIME := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
GITSHA := $(shell git rev-parse --short HEAD 2>/dev/null)

@@ -16,18 +18,17 @@ LDFLAGS += -X $(PKG)/version.Version=$(VERSION)
LDFLAGS += -X $(PKG)/version.Commit=$(GITSHA)
LDFLAGS += -X $(PKG)/version.BuildTime=$(BUILDTIME)

BUILDDIR := BUILD
IMAGE_VERSION := $(VERSION)
DOCKER_IMAGE := profefe/profefe

DOCKER_BUILD_ARGS += --build-arg VERSION=$(VERSION)
DOCKER_BUILD_ARGS += --build-arg GITSHA=$(GITSHA)

# Required for globs to work correctly
SHELL := /bin/bash
BUILDDIR := BUILD

BUILD.go = $(GO) build $(GOFLAGS)
TEST.go = $(GO) test $(TESTFLAGS)

DOCKER_BUILD_ARGS += --build-arg VERSION=$(VERSION)
DOCKER_BUILD_ARGS += --build-arg GITSHA=$(GITSHA)
DOCKER_BUILD_ARGS += --build-arg BUILDTIME=$(BUILDTIME)

.PHONY: all
all: build-profefe

@@ -41,5 +42,12 @@ deploy:
test:
$(TEST.go) -ldflags "$(LDFLAGS)" ./...

container:
docker build $(DOCKER_BUILD_ARGS) -f ./contrib/docker/Dockerfile -t profefe/profefe:$(GITSHA) .
.PHONY: docker-image
docker-image:
$(DOCKER) build $(DOCKER_BUILD_ARGS) -t $(DOCKER_IMAGE):$(IMAGE_VERSION) -f ./contrib/docker/Dockerfile .

.PHONY: docker-push-image
docker-push-image: docker-image
$(DOCKER) tag $(DOCKER_IMAGE):$(IMAGE_VERSION) $(DOCKER_IMAGE):latest
$(DOCKER) push $(DOCKER_IMAGE):$(IMAGE_VERSION)
$(DOCKER) push $(DOCKER_IMAGE):latest
@@ -34,6 +34,18 @@ To build and start profefe collector, run:
2019-06-06T00:07:58.499+0200 info profefe/main.go:86 server is running {"addr": ":10100"}
```

### Docker

You can build a docker image with the command:

```
> make docker-image
```

More documentation can be found in [./contrib/docker/README.md](./contrib/docker/README.md).

---

The project includes a fork of [Google Stackdriver Profiler's example application][5], modified to use profefe agent,
that sends profiles to the local collector.

@@ -51,17 +63,6 @@ send profile: http://localhost:10100/api/0/profiles?instance_id=87cdc549c84507f2
send profile: http://localhost:10100/api/0/profiles?instance_id=87cdc549c84507f24944793b1ddbdc34&labels=version%3D1.0.0&service=hotapp-service&type=cpu
```

## Docker

You can build a docker image with the command:

```
make container
```

More documentation can be found in
[./contrib/docker/README.md](./contrib/docker/README.md)

### Querying Profiles

Querying profiling data is an HTTP call to profefe collector API endpoint:
@@ -130,7 +131,7 @@ body pprof.pb.gz
### Query saved meta information

```
GET /api/0/profiles?service=<service>&type=<type>from=<created_from>&to=<created_to>&labels=<key=value,key=value>
GET /api/0/profiles?service=<service>&type=<type>&from=<created_from>&to=<created_to>&labels=<key=value,key=value>
< 200 OK
<
@@ -1,16 +1,14 @@
FROM golang:1.13.4-alpine3.10 as builder

env GO111MODULE=off
env SHELL=/bin/sh
RUN apk add --update --no-cache make

env GO111MODULE=off
ARG VERSION
ARG GITSHA
ARG BUILDTIME

RUN apk add --update --no-cache make
COPY . /go/src/github.com/profefe/profefe
WORKDIR /go/src/github.com/profefe/profefe
RUN make SHELL=$SHELL GITSHA=$GITSHA
RUN make VERSION=$VERSION GITSHA=$GITSHA

FROM alpine

@@ -4,20 +4,20 @@ docker image for `profefe`.
Starting from the root of the project you can run:

```
make container
make docker-image
```

It will build an image called `profefe/profefe:<GITSHA>` where `<GITSHA>` is the
current git commit sha.
This will build an image named `profefe/profefe:git-<GITSHA>` where `<GITSHA>` is the
current git commit.

You can run the container with the command:

```
docker run -it -p 10100:10100 -v $PWD/data:$PWD/data profefe/profefe:<GITSHA>
docker run -it -p 10100:10100 -v $PWD/data:/data profefe/profefe:git-<GITSHA>
```

If you need to change the http server port you can do:
If you need to change the http server port and you can do:

```
docker run -it -p 10200:10200 -v $PWD/data:$PWD/data profefe/profefe:2550865 -addr :10200
docker run -it -p 10200:10200 -v $PWD/data:/data profefe/profefe:git-<GITSHA> -addr :10200
```

0 comments on commit 8cbce8f

Please sign in to comment.
You can’t perform that action at this time.