forked from parca-dev/parca
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
63 lines (46 loc) · 1.86 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
ARG NODE_BUILDER_BASE
ARG GOLANG_BUILDER_BASE
ARG RUNNER_BASE
FROM ${NODE_BUILDER_BASE} AS ui-deps
WORKDIR /app
COPY ui/packages/shared ./packages/shared
COPY ui/packages/app/web/package.json ./packages/app/web/package.json
COPY ui/package.json ui/yarn.lock ./
RUN yarn workspace @parca/web install --frozen-lockfile
# Rebuild the source code only when needed
FROM ${NODE_BUILDER_BASE} AS ui-builder
ENV NODE_ENV production
ENV CIRCLE_NODE_TOTAL 1
WORKDIR /app
COPY ./ui .
COPY --from=ui-deps /app/node_modules ./node_modules
RUN yarn workspace @parca/web build
FROM ${GOLANG_BUILDER_BASE} as builder
RUN mkdir /.cache && chown nobody:nogroup /.cache && touch -t 202101010000.00 /.cache
ARG VERSION
ARG COMMIT
ARG ARCH=amd64
ENV CGO_ENABLED=0
ENV GOOS=linux
ENV GOARCH=$ARCH
WORKDIR /app
COPY go.mod go.sum /app/
RUN go mod download -modcacherw
COPY --chown=nobody:nogroup go.mod go.sum ./
COPY --chown=nobody:nogroup ./cmd/parca ./cmd/parca
COPY --chown=nobody:nogroup ./pkg ./pkg
COPY --chown=nobody:nogroup ./internal ./internal
COPY --chown=nobody:nogroup ./gen ./gen
COPY --chown=nobody:nogroup ./proto ./proto
COPY --chown=nobody:nogroup ./ui/ui.go ./ui/ui.go
COPY --chown=nobody:nogroup --from=ui-builder /app/packages/app/web/build ./ui/packages/app/web/build
RUN go build -ldflags "-X main.version=${VERSION} -X main.commit=${COMMIT}" -trimpath -o parca ./cmd/parca
RUN go install github.com/grpc-ecosystem/grpc-health-probe@latest
# Predicatable path for copying over to final image
RUN if [ "$(go env GOHOSTARCH)" != "$(go env GOARCH)" ]; then mv "$(go env GOPATH)/bin/$(go env GOOS)_$(go env GOARCH)/grpc-health-probe" "$(go env GOPATH)/bin/grpc-health-probe"; fi
FROM ${RUNNER_BASE} as runner
USER nobody
COPY --chown=0:0 --from=builder /app/parca /parca
COPY --chown=0:0 --from=builder /go/bin/grpc-health-probe /
COPY --chown=0:0 parca.yaml /parca.yaml
CMD ["/parca"]