github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/Dockerfile (about)

     1  #        _
     2  #       | |
     3  #  _ __ | |__  _ __  ___ _ __  _   _
     4  # | '_ \| '_ \| '_ \/ __| '_ \| | | |
     5  # | |_) | | | | |_) \__ \ |_) | |_| |
     6  # | .__/|_| |_| .__/|___/ .__/ \__, |
     7  # | |         | |       | |     __/ |
     8  # |_|         |_|       |_|    |___/
     9  
    10  FROM alpine:3.16 as phpspy-builder
    11  RUN apk update && apk upgrade \
    12      && apk add --update alpine-sdk
    13  COPY Makefile Makefile
    14  RUN mkdir -p third_party/phpspy
    15  RUN make build-phpspy-dependencies
    16  
    17  #                     _
    18  #                    | |
    19  #   __ _ ___ ___  ___| |_ ___
    20  #  / _` / __/ __|/ _ \ __/ __|
    21  # | (_| \__ \__ \  __/ |_\__ \
    22  #  \__,_|___/___/\___|\__|___/
    23  
    24  FROM node:16.18-alpine3.16 as js-builder
    25  
    26  RUN apk update && apk upgrade && \
    27      apk add --no-cache make
    28  
    29  WORKDIR /opt/pyroscope
    30  
    31  COPY scripts ./scripts
    32  COPY package.json yarn.lock Makefile lerna.json ./
    33  COPY lib ./lib
    34  COPY packages ./packages
    35  COPY babel.config.js .eslintrc.js .eslintignore .prettierrc tsconfig.json ./
    36  COPY webapp ./webapp
    37  
    38  RUN make install-build-web-dependencies
    39  
    40  
    41  ARG EXTRA_METADATA=""
    42  
    43  RUN EXTRA_METADATA=$EXTRA_METADATA make assets-release
    44  
    45  
    46  
    47  #       _            __
    48  #      | |          / _|
    49  #   ___| |__  _ __ | |_
    50  #  / _ \ '_ \| '_ \|  _|
    51  # |  __/ |_) | |_) | |
    52  #  \___|_.__/| .__/|_|
    53  #            | |
    54  #            |_|
    55  FROM alpine:3.16 as ebpf-builder
    56  RUN apk update && apk upgrade && \
    57      apk add cmake make binutils gcc g++ clang musl-dev linux-headers zlib-dev elfutils-dev libelf-static zlib-static git openssh
    58  ADD third_party/libbpf/Makefile /build/libbpf/
    59  RUN make -C /build/libbpf/
    60  ADD third_party/bcc/Makefile /build/bcc/
    61  RUN make -C /build/bcc/
    62  ADD pkg/agent/ebpfspy/bpf/Makefile pkg/agent/ebpfspy/bpf/profile.bpf.c pkg/agent/ebpfspy/bpf/profile.bpf.h /build/profile.bpf/
    63  RUN CFLAGS=-I/build/libbpf/lib/include make -C /build/profile.bpf
    64  
    65  #              _
    66  #             | |
    67  #   __ _  ___ | | __ _ _ __   __ _
    68  #  / _` |/ _ \| |/ _` | '_ \ / _` |
    69  # | (_| | (_) | | (_| | | | | (_| |
    70  #  \__, |\___/|_|\__,_|_| |_|\__, |
    71  #   __/ |                     __/ |
    72  #  |___/                     |___/
    73  
    74  
    75  FROM golang:1.19-alpine3.16 AS go-builder
    76  
    77  RUN apk update && apk upgrade && \
    78      apk add --no-cache make git zstd gcc g++ libc-dev musl-dev bash zlib-dev elfutils-dev libelf-static zlib-static \
    79      linux-headers
    80  
    81  WORKDIR /opt/pyroscope
    82  
    83  
    84  COPY third_party/phpspy/phpspy.h /opt/pyroscope/third_party/phpspy/phpspy.h
    85  COPY --from=phpspy-builder /third_party/phpspy/libphpspy.a /opt/pyroscope/third_party/phpspy/libphpspy.a
    86  COPY --from=js-builder /opt/pyroscope/webapp/public ./webapp/public
    87  COPY --from=ebpf-builder /build/bcc/lib third_party/bcc/lib
    88  COPY --from=ebpf-builder /build/libbpf/lib third_party/libbpf/lib
    89  COPY --from=ebpf-builder /build/profile.bpf/profile.bpf.o pkg/agent/ebpfspy/bpf/profile.bpf.o
    90  COPY Makefile ./
    91  COPY tools ./tools
    92  COPY go.mod go.sum ./
    93  RUN make install-dev-tools
    94  RUN make install-go-dependencies
    95  
    96  COPY pkg ./pkg
    97  COPY cmd ./cmd
    98  COPY webapp/assets_embedded.go ./webapp/assets_embedded.go
    99  COPY webapp/assets.go ./webapp/assets.go
   100  COPY scripts ./scripts
   101  
   102  RUN ENABLED_SPIES_RELEASE="ebpfspy,phpspy,dotnetspy" \
   103      EMBEDDED_ASSETS_DEPS="" \
   104      EXTRA_LDFLAGS="-linkmode external -extldflags '-static'" \
   105      make build-release
   106  
   107  
   108  
   109  #   __ _             _   _
   110  #  / _(_)           | | (_)
   111  # | |_ _ _ __   __ _| |  _ _ __ ___   __ _  __ _  ___
   112  # |  _| | '_ \ / _` | | | | '_ ` _ \ / _` |/ _` |/ _ \
   113  # | | | | | | | (_| | | | | | | | | | (_| | (_| |  __/
   114  # |_| |_|_| |_|\__,_|_| |_|_| |_| |_|\__,_|\__, |\___|
   115  #                                           __/ |
   116  #                                          |___/
   117  
   118  FROM alpine:3.16
   119  
   120  LABEL maintainer="Pyroscope team <hello@pyroscope.io>"
   121  
   122  WORKDIR /var/lib/pyroscope
   123  
   124  RUN apk update && apk upgrade && \
   125      apk add --no-cache ca-certificates bash tzdata openssl musl-utils bash-completion
   126  
   127  RUN ln -s $(which python3) /usr/bin/python
   128  
   129  RUN addgroup -S pyroscope && adduser -S pyroscope -G pyroscope
   130  
   131  RUN mkdir -p \
   132          "/var/lib/pyroscope" \
   133          "/var/log/pyroscope" \
   134          "/etc/pyroscope" \
   135          && \
   136      chown -R "pyroscope:pyroscope" \
   137          "/var/lib/pyroscope" \
   138          "/var/log/pyroscope" \
   139          "/etc/pyroscope" \
   140          && \
   141      chmod -R 777 \
   142          "/var/lib/pyroscope" \
   143          "/var/log/pyroscope" \
   144          "/etc/pyroscope"
   145  
   146  COPY scripts/packages/server.yml "/etc/pyroscope/server.yml"
   147  COPY --from=go-builder --chmod=0777 /opt/pyroscope/bin/pyroscope /usr/bin/pyroscope
   148  # we use this in cloud
   149  COPY --from=js-builder /opt/pyroscope/webapp/public/standalone.html /standalone.html
   150  
   151  RUN pyroscope completion bash > /usr/share/bash-completion/completions/pyroscope
   152  
   153  USER pyroscope
   154  EXPOSE 4040/tcp
   155  ENTRYPOINT [ "/usr/bin/pyroscope" ]