Skip to content

Commit

Permalink
petethepig/pyroscope -> pyroscope-io/pyroscope, Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
petethepig committed Dec 17, 2020
1 parent 7f1beed commit dc5aa25
Show file tree
Hide file tree
Showing 55 changed files with 223 additions and 147 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
run: mkdir build

- name: Build
run: go build -o build/pyroscope ./cmd/pyroscope
run: make build-release

- name: List Assets
run: ls build/
Expand Down Expand Up @@ -76,10 +76,10 @@ jobs:
run: "sudo gem install fpm"

- name: Create rpm package
run: "fpm -s dir -t rpm -n pyroscope --iteration ${{ steps.iteration.outputs.iteration }} --architecture x86_64 -v ${GITHUB_REF#refs/*/v} --description 'pyroscope is continuous profiling software' -p ${{ steps.rpm_name.outputs.rpm_name }} ./package-build"
run: "fpm -s dir -t rpm -n pyroscope --iteration ${{ steps.iteration.outputs.iteration }} --architecture x86_64 -v ${GITHUB_REF#refs/*/v} --description 'pyroscope is open source continuous profiling software' -p ${{ steps.rpm_name.outputs.rpm_name }} ./package-build"

- name: Create deb package
run: "fpm -s dir -t deb -n pyroscope --iteration ${{ steps.iteration.outputs.iteration }} --architecture x86_64 -v ${GITHUB_REF#refs/*/v} --description 'pyroscope is continuous profiling software' -p ${{ steps.rpm_name.outputs.deb_name }} ./package-build"
run: "fpm -s dir -t deb -n pyroscope --iteration ${{ steps.iteration.outputs.iteration }} --architecture x86_64 -v ${GITHUB_REF#refs/*/v} --description 'pyroscope is open source continuous profiling software' -p ${{ steps.deb_name.outputs.deb_name }} ./package-build"

- name: Archive Assets
run: tar czf ${{ steps.file_name.outputs.file_name }} build/*
Expand Down
82 changes: 82 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# assets build

FROM --platform=$BUILDPLATFORM node:14.15.1-alpine3.12 as js-builder

RUN apk add --no-cache make

WORKDIR /opt/pyroscope

COPY package.json package-lock.json .babelrc Makefile ./
COPY scripts ./scripts
COPY webapp ./webapp

# RUN make assets
RUN echo 1

# go build

FROM --platform=$BUILDPLATFORM golang:1.15.1-alpine3.12 as go-builder

RUN apk add --no-cache make git zstd gcc g++ libc-dev musl-dev

WORKDIR /opt/pyroscope

ENV ENABLED_SPIES none

COPY --from=js-builder /opt/pyroscope/webapp/public ./webapp/public
COPY pkg ./pkg
COPY cmd ./cmd
COPY tools ./tools
COPY scripts ./scripts
COPY go.mod go.sum pyroscope.go ./
COPY Makefile ./

RUN EMBEDDED_ASSETS_DEPS="" make build-release

# final image

FROM alpine:3.12

LABEL maintainer="Pyroscope team <hello@pyroscope.io>"

ARG PS_UID="472"
ARG PS_GID="0"

ENV PATH="/opt/pyroscope/bin:$PATH" \
PS_PATHS_CONFIG="/etc/pyroscope/" \
PS_PATHS_DATA="/var/lib/pyroscope" \
PS_PATHS_HOME="/opt/pyroscope" \
PS_PATHS_LOGS="/var/log/pyroscope"

WORKDIR $PS_PATHS_HOME

RUN apk add --no-cache ca-certificates bash tzdata && \
apk add --no-cache openssl musl-utils

COPY conf ./conf

RUN if [ ! $(getent group "$PS_GID") ]; then \
addgroup -S -g $PS_GID pyroscope; \
fi

RUN export PS_GID_NAME=$(getent group $PS_GID | cut -d':' -f1) && \
mkdir -p "$PS_PATHS_HOME/.aws" && \
adduser -S -u $PS_UID -G "$PS_GID_NAME" pyroscope && \
mkdir -p "$PS_PATHS_LOGS" \
"$PS_PATHS_CONFIG" \
"$PS_PATHS_DATA" \
&& \
mv "$PS_PATHS_HOME/conf/server.yml" "$PS_PATHS_CONFIG" && \
chown -R "pyroscope:$PS_GID_NAME" \
"$PS_PATHS_DATA" \
"$PS_PATHS_HOME" \
"$PS_PATHS_LOGS" \
"$PS_PATHS_CONFIG" \
&& \
chmod -R 777 "$PS_PATHS_DATA" "$PS_PATHS_HOME" "$PS_PATHS_LOGS" "$PS_PATHS_CONFIG"

COPY --from=go-builder /opt/pyroscope/bin/pyroscope ./bin/pyroscope

USER pyroscope
EXPOSE 8080/tcp
ENTRYPOINT [ "/opt/pyroscope/bin/pyroscope", "server" ]
45 changes: 36 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@ GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)
GOBUILD=go build -trimpath
ENABLED_SPIES ?= "rbspy,pyspy"
EMBEDDED_ASSETS_DEPS ?= "assets"
EMBEDDED_ASSETS ?= ""
DOCKER_ARCHES ?= "linux/amd64,linux/arm64"
GODEBUG=asyncpreemptoff=1
DOCKER_TAG ?= "dev"

ifndef $(GOPATH)
GOPATH=$(shell go env GOPATH)
export GOPATH
endif

.PHONY: all
all: build
Expand Down Expand Up @@ -47,14 +55,6 @@ assets: install-web-dependencies
assets-watch: install-web-dependencies
$(shell yarn bin webpack) --config scripts/webpack/webpack.js --watch

.PHONY: embedded-assets
embedded-assets: assets
pkger -o pkg/controller

.PHONY: build-release
build-release: embedded-assets
EMBEDDED_ASSETS=true $(MAKE) build

.PHONY: lint
lint:
revive -config revive.toml -formatter stylish ./...
Expand All @@ -77,7 +77,7 @@ dev:

.PHONY: godoc
godoc:
sleep 5 && open http://localhost:8090/pkg/github.com/petethepig/pyroscope/ &
sleep 5 && open http://localhost:8090/pkg/github.com/pyroscope-io/pyroscope/ &
godoc -http :8090

.PHONY: go-deps-graph
Expand All @@ -92,3 +92,30 @@ clean:
.PHONY: update-contributors
update-contributors:
$(shell yarn bin contributor-faces) .

# Release-related tasks:

.PHONY: embedded-assets
embedded-assets: install-dev-tools $(EMBEDDED_ASSETS_DEPS)
pkger -o pkg/server

.PHONY: build-release
build-release: embedded-assets
EMBEDDED_ASSETS=true $(MAKE) build

.PHONY: docker-build
docker-build:
docker build .

.PHONY: docker-build-x-setup
docker-build-x-setup:
docker buildx create --use

.PHONY: docker-build-all-arches
docker-build-all-arches:
docker buildx build \
--tag pyroscope/pyroscope:$(DOCKER_TAG) \
--push \
--platform $(DOCKER_ARCHES) \
.

4 changes: 2 additions & 2 deletions cmd/pyroscope/main.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package main

import (
"github.com/petethepig/pyroscope/pkg/cli"
"github.com/petethepig/pyroscope/pkg/config"
"github.com/pyroscope-io/pyroscope/pkg/cli"
"github.com/pyroscope-io/pyroscope/pkg/config"
log "github.com/sirupsen/logrus"
)

Expand Down
Empty file added conf/server.yml
Empty file.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/petethepig/pyroscope
module github.com/pyroscope-io/pyroscope

go 1.14

Expand Down
Loading

0 comments on commit dc5aa25

Please sign in to comment.