Dockerfile 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. # SPDX-License-Identifier: GPL-3.0-or-later
  2. # author : paulfantom
  3. # Cross-arch building is achieved by specifying ARCH as a build parameter with `--build-arg` option.
  4. # It is automated in `build.sh` script
  5. ARG ARCH=amd64
  6. # This image contains preinstalled dependecies
  7. FROM netdata/builder:${ARCH} as builder
  8. ENV JUDY_VER 1.0.5
  9. # Copy source
  10. COPY . /opt/netdata.git
  11. WORKDIR /opt/netdata.git
  12. # Install from source
  13. RUN chmod +x netdata-installer.sh && ./netdata-installer.sh --dont-wait --dont-start-it
  14. # files to one directory
  15. RUN mkdir -p /app/usr/sbin/ \
  16. /app/usr/share \
  17. /app/usr/libexec \
  18. /app/usr/lib \
  19. /app/var/cache \
  20. /app/var/lib \
  21. /app/etc && \
  22. mv /usr/share/netdata /app/usr/share/ && \
  23. mv /usr/libexec/netdata /app/usr/libexec/ && \
  24. mv /usr/lib/netdata /app/usr/lib/ && \
  25. mv /var/cache/netdata /app/var/cache/ && \
  26. mv /var/lib/netdata /app/var/lib/ && \
  27. mv /etc/netdata /app/etc/ && \
  28. mv /usr/sbin/netdata /app/usr/sbin/ && \
  29. mv /judy-${JUDY_VER} /app/judy-${JUDY_VER} && \
  30. mv packaging/docker/run.sh /app/usr/sbin/ && \
  31. chmod +x /app/usr/sbin/run.sh
  32. #####################################################################
  33. ARG ARCH
  34. # This image contains preinstalled dependecies
  35. FROM netdata/base:${ARCH}
  36. # Conditional subscribiton to Polyverse's Polymorphic Linux repositories
  37. RUN if [ "$(uname -m)" == "x86_64" ]; then \
  38. apk update && apk upgrade; \
  39. curl https://sh.polyverse.io | sh -s install gcxce5byVQbtRz0iwfGkozZwy support+netdata@polyverse.io; \
  40. if [ $? -eq 0 ]; then \
  41. apk update && \
  42. apk upgrade --available --no-cache && \
  43. sed -in 's/^#//g' /etc/apk/repositories; \
  44. fi \
  45. fi
  46. # Copy files over
  47. RUN mkdir -p /opt/src
  48. COPY --from=builder /app /
  49. # Configure system
  50. ARG NETDATA_UID=201
  51. ARG NETDATA_GID=201
  52. ENV DOCKER_GRP netdata
  53. ENV DOCKER_USR netdata
  54. RUN \
  55. # provide judy installation to base image
  56. apk add make alpine-sdk shadow && \
  57. cd /judy-${JUDY_VER} && make install && cd / && \
  58. # Clean the source stuff once judy is installed
  59. rm -rf /judy-${JUDY_VER} && apk del make alpine-sdk && \
  60. # fping from alpine apk is on a different location. Moving it.
  61. mv /usr/sbin/fping /usr/local/bin/fping && \
  62. chmod 4755 /usr/local/bin/fping && \
  63. mkdir -p /var/log/netdata && \
  64. # Add netdata user
  65. addgroup -g ${NETDATA_GID} -S "${DOCKER_GRP}" && \
  66. adduser -S -H -s /usr/sbin/nologin -u ${NETDATA_GID} -h /etc/netdata -G "${DOCKER_GRP}" "${DOCKER_USR}" && \
  67. # Apply the permissions as described in
  68. # https://github.com/netdata/netdata/wiki/netdata-security#netdata-directories
  69. chown -R root:netdata /etc/netdata && \
  70. chown -R netdata:netdata /var/cache/netdata /var/lib/netdata /usr/share/netdata && \
  71. chown -R root:netdata /usr/lib/netdata && \
  72. chown -R root:netdata /usr/libexec/netdata/ && \
  73. chmod 4750 /usr/libexec/netdata/plugins.d/cgroup-network /usr/libexec/netdata/plugins.d/apps.plugin && \
  74. chmod 0750 /var/lib/netdata /var/cache/netdata && \
  75. # Link log files to stdout
  76. ln -sf /dev/stdout /var/log/netdata/access.log && \
  77. ln -sf /dev/stdout /var/log/netdata/debug.log && \
  78. ln -sf /dev/stderr /var/log/netdata/error.log
  79. ENV NETDATA_PORT 19999
  80. EXPOSE $NETDATA_PORT
  81. ENTRYPOINT ["/usr/sbin/run.sh"]