Dockerfile 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. # SPDX-License-Identifier: GPL-3.0-or-later
  2. # author : paulfantom
  3. # This image contains preinstalled dependencies
  4. # hadolint ignore=DL3007
  5. FROM netdata/builder:v2 AS builder
  6. # One of 'nightly' or 'stable'
  7. ARG RELEASE_CHANNEL=nightly
  8. ARG CFLAGS
  9. ENV CFLAGS=$CFLAGS
  10. ARG EXTRA_INSTALL_OPTS
  11. ENV EXTRA_INSTALL_OPTS=$EXTRA_INSTALL_OPTS
  12. ARG DEBUG_BUILD
  13. ENV DEBUG_BUILD=$DEBUG_BUILD
  14. # Copy source
  15. COPY . /opt/netdata.git
  16. WORKDIR /opt/netdata.git
  17. # Install from source
  18. RUN chmod +x netdata-installer.sh && \
  19. cp -rp /deps/* /usr/local/ && \
  20. /bin/echo -e "INSTALL_TYPE='oci'\nPREBUILT_ARCH='$(uname -m)'" > ./system/.install-type && \
  21. CFLAGS="$(packaging/docker/gen-cflags.sh)" LDFLAGS="-Wl,--gc-sections" ./netdata-installer.sh --dont-wait --dont-start-it --use-system-protobuf \
  22. ${EXTRA_INSTALL_OPTS} --disable-ebpf --install-no-prefix / "$([ "$RELEASE_CHANNEL" = stable ] && echo --stable-channel)"
  23. # files to one directory
  24. RUN mkdir -p /app/usr/sbin/ \
  25. /app/usr/share \
  26. /app/usr/libexec \
  27. /app/usr/local \
  28. /app/usr/lib \
  29. /app/var/cache \
  30. /app/var/lib \
  31. /app/etc && \
  32. mv /usr/share/netdata /app/usr/share/ && \
  33. mv /usr/libexec/netdata /app/usr/libexec/ && \
  34. mv /usr/lib/netdata /app/usr/lib/ && \
  35. mv /var/cache/netdata /app/var/cache/ && \
  36. mv /var/lib/netdata /app/var/lib/ && \
  37. mv /etc/netdata /app/etc/ && \
  38. mv /usr/sbin/netdata /app/usr/sbin/ && \
  39. mv /usr/sbin/netdatacli /app/usr/sbin/ && \
  40. mv /usr/sbin/systemd-cat-native /app/usr/sbin/ && \
  41. mv packaging/docker/run.sh /app/usr/sbin/ && \
  42. mv packaging/docker/health.sh /app/usr/sbin/ && \
  43. mkdir -p /deps/etc && \
  44. cp -rp /deps/etc /app/usr/local/etc && \
  45. chmod -R o+rX /app && \
  46. chmod +x /app/usr/sbin/run.sh
  47. #####################################################################
  48. # This image contains preinstalled dependencies
  49. # hadolint ignore=DL3007
  50. FROM netdata/base:v2 AS base
  51. LABEL org.opencontainers.image.authors="Netdatabot <bot@netdata.cloud>"
  52. LABEL org.opencontainers.image.url="https://netdata.cloud"
  53. LABEL org.opencontainers.image.documentation="https://learn.netdata.cloud"
  54. LABEL org.opencontainers.image.source="https://github.com/netdata/netdata"
  55. LABEL org.opencontainers.image.title="Netdata Agent"
  56. LABEL org.opencontainers.image.description="Official Netdata Agent Docker Image"
  57. LABEL org.opencontainers.image.vendor="Netdata Inc."
  58. ARG OFFICIAL_IMAGE=false
  59. ENV NETDATA_OFFICIAL_IMAGE=$OFFICIAL_IMAGE
  60. ONBUILD ENV NETDATA_OFFICIAL_IMAGE=false
  61. ARG NETDATA_UID=201
  62. ARG NETDATA_GID=201
  63. ENV DOCKER_GRP=netdata
  64. ENV DOCKER_USR=netdata
  65. # If DISABLE_TELEMETRY is set, it will disable anonymous stats collection and reporting
  66. #ENV DISABLE_TELEMETRY=1
  67. ENV NETDATA_LISTENER_PORT=19999
  68. EXPOSE $NETDATA_LISTENER_PORT
  69. ENV NETDATA_EXTRA_DEB_PACKAGES=""
  70. RUN mkdir -p /opt/src /var/log/netdata && \
  71. ln -sf /dev/stdout /var/log/netdata/access.log && \
  72. ln -sf /dev/stdout /var/log/netdata/aclk.log && \
  73. ln -sf /dev/stdout /var/log/netdata/debug.log && \
  74. ln -sf /dev/stderr /var/log/netdata/error.log && \
  75. ln -sf /dev/stderr /var/log/netdata/daemon.log && \
  76. ln -sf /dev/stdout /var/log/netdata/collector.log && \
  77. ln -sf /dev/stdout /var/log/netdata/fluentbit.log && \
  78. ln -sf /dev/stdout /var/log/netdata/health.log
  79. COPY --from=builder /app /
  80. # Create netdata user and apply the permissions as described in
  81. # https://docs.netdata.cloud/docs/netdata-security/#netdata-directories, but own everything by root group due to https://github.com/netdata/netdata/pull/6543
  82. # hadolint ignore=DL3013
  83. RUN addgroup --gid ${NETDATA_GID} --system "${DOCKER_GRP}" && \
  84. adduser --system --no-create-home --shell /usr/sbin/nologin --uid ${NETDATA_UID} --home /etc/netdata --group "${DOCKER_USR}" && \
  85. chown -R root:root \
  86. /etc/netdata \
  87. /usr/share/netdata \
  88. /usr/libexec/netdata && \
  89. chown -R netdata:root \
  90. /usr/lib/netdata \
  91. /var/cache/netdata \
  92. /var/lib/netdata \
  93. /var/log/netdata && \
  94. chown -R netdata:netdata /var/lib/netdata/cloud.d && \
  95. chmod 0700 /var/lib/netdata/cloud.d && \
  96. chmod 0755 /usr/libexec/netdata/plugins.d/*.plugin && \
  97. for name in cgroup-network \
  98. local-listeners \
  99. apps.plugin \
  100. debugfs.plugin \
  101. freeipmi.plugin \
  102. go.d.plugin \
  103. perf.plugin \
  104. ndsudo \
  105. slabinfo.plugin \
  106. network-viewer.plugin \
  107. systemd-journal.plugin; do \
  108. [ -f "/usr/libexec/netdata/plugins.d/$name" ] && chmod 4755 "/usr/libexec/netdata/plugins.d/$name"; \
  109. done && \
  110. # Group write permissions due to: https://github.com/netdata/netdata/pull/6543
  111. find /var/lib/netdata /var/cache/netdata -type d -exec chmod 0770 {} \; && \
  112. find /var/lib/netdata /var/cache/netdata -type f -exec chmod 0660 {} \; && \
  113. cp -va /etc/netdata /etc/netdata.stock
  114. ENTRYPOINT ["/usr/sbin/run.sh"]
  115. HEALTHCHECK --interval=60s --timeout=10s --retries=3 CMD /usr/sbin/health.sh