summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicolargo <nicolas@nicolargo.com>2022-05-24 11:57:06 +0200
committernicolargo <nicolas@nicolargo.com>2022-05-24 11:57:06 +0200
commit9cc10fd33d241c18f4e473a8c3f216f19c81d926 (patch)
tree88ef987a7f717c2c0bffe9be0cef0ead16d8b1f3
parent6f51c5fd43eeda78063e6d31c2ae45007024e808 (diff)
Use glances.conf file inside docker-compose folder for Docker images
-rw-r--r--docker-compose/glances.conf8
-rw-r--r--docker-files/README.md26
-rw-r--r--docker-files/alpine.Dockerfile38
-rw-r--r--docker-files/debian.Dockerfile40
-rw-r--r--glances/outdated.py11
5 files changed, 103 insertions, 20 deletions
diff --git a/docker-compose/glances.conf b/docker-compose/glances.conf
index c04f8e96..ab4a30e7 100644
--- a/docker-compose/glances.conf
+++ b/docker-compose/glances.conf
@@ -158,6 +158,8 @@ tx_warning=80
tx_critical=90
# Define the list of hidden network interfaces (comma-separated regexp)
#hide=docker.*,lo
+# Define the list of wireless network interfaces to be show (comma-separated)
+#show=docker.*
# WLAN 0 alias
#wlan0_alias=Wireless
# It is possible to overwrite the bitrate thresholds per interface
@@ -187,6 +189,8 @@ nf_conntrack_percent_critical=90
disable=True
# Define the list of hidden wireless network interfaces (comma-separated regexp)
hide=lo,docker.*
+# Define the list of wireless network interfaces to be show (comma-separated)
+#show=docker.*
# Define SIGNAL thresholds in db (lower is better...)
# Based on: http://serverfault.com/questions/501025/industry-standard-for-minimum-wifi-signal-strength
careful=-65
@@ -198,6 +202,8 @@ disable=False
# Define the list of hidden disks (comma-separated regexp)
#hide=sda2,sda5,loop.*
hide=loop.*,/dev/loop*
+# Define the list of disks to be show (comma-separated)
+#show=sda.*
# Alias for sda1
#sda1_alias=InternalDisk
@@ -205,6 +211,8 @@ hide=loop.*,/dev/loop*
disable=False
# Define the list of hidden file system (comma-separated regexp)
hide=/boot.*,/snap.*
+# Define the list of file system to be show (comma-separated)
+#show=/,/srv
# Define filesystem space thresholds in %
# Default values if not defined: 50/70/90
# It is also possible to define per mount point value
diff --git a/docker-files/README.md b/docker-files/README.md
index 874f34a5..93a4e321 100644
--- a/docker-files/README.md
+++ b/docker-files/README.md
@@ -3,18 +3,36 @@
The Dockerfiles used here are using multi-staged builds.
For building a specific stage locally docker needs to know the target stage with `--target`.
-## Examples
+## Examples for Debian images
+
+For the dev image:
+``bash
+docker build --target dev -f ./docker-files/debian.Dockerfile -t glances:dev .
+``
+
+For the minimal image:
+``bash
+docker build --target minimal -f ./docker-files/debian.Dockerfile -t glances:minimal .
+``
+
+For the full image:
+``bash
+docker build --target full -f ./docker-files/debian.Dockerfile -t glances:full .
+``
+
+## Examples for Alpine images
+
For the dev image:
``bash
-docker build --target dev -f docker-files/debian.Dockerfile -t glances .
+docker build --target dev -f ./docker-files/alpine.Dockerfile -t glances:dev .
``
For the minimal image:
``bash
-docker build --target minimal -f docker-files/debian.Dockerfile -t glances .
+docker build --target minimal -f ./docker-files/alpine.Dockerfile -t glances:minimal .
``
For the full image:
``bash
-docker build --target full -f docker-files/debian.Dockerfile -t glances .
+docker build --target full -f ./docker-files/alpine.Dockerfile -t glances:full .
``
diff --git a/docker-files/alpine.Dockerfile b/docker-files/alpine.Dockerfile
index b805475f..01052fd0 100644
--- a/docker-files/alpine.Dockerfile
+++ b/docker-files/alpine.Dockerfile
@@ -4,7 +4,14 @@
# https://github.com/nicolargo/glances
#
-FROM alpine:3.13 as build
+# WARNING: the versions should be set.
+# Ex: Python 3.10 for Alpine 3.16
+# Note: ENV is for future running containers. ARG for building your Docker image.
+
+ARG IMAGE_VERSION=3.16
+ARG PYTHON_VERSION=3.10
+FROM alpine:${IMAGE_VERSION} as build
+ARG PYTHON_VERSION
RUN apk add --no-cache \
python3 \
@@ -23,6 +30,7 @@ RUN apk add --no-cache \
FROM build as remoteInstall
+ARG PYTHON_VERSION
# Install the dependencies beforehand to make them cacheable
COPY requirements.txt .
RUN pip3 install --no-cache-dir --user -r requirements.txt
@@ -33,16 +41,22 @@ RUN pip3 install --no-cache-dir --user glances[all]
FROM build as additional-packages
+ARG PYTHON_VERSION
COPY *requirements.txt ./
RUN CASS_DRIVER_NO_CYTHON=1 pip3 install --no-cache-dir --user -r optional-requirements.txt
+##############################################################################
+# dev image
+##############################################################################
FROM build as dev
+ARG PYTHON_VERSION
-COPY --from=additional-packages /root/.local/lib/python3.8/site-packages /usr/lib/python3.8/site-packages/
+COPY --from=additional-packages /root/.local/lib/python${PYTHON_VERSION}/site-packages /usr/lib/python${PYTHON_VERSION}/site-packages/
COPY . /glances
+COPY ./docker-compose/glances.conf /etc/glances.conf
# EXPOSE PORT (XMLRPC / WebUI)
EXPOSE 61209 61208
@@ -50,11 +64,15 @@ EXPOSE 61209 61208
WORKDIR /glances
# Define default command.
-CMD python3 -m glances -C /glances/conf/glances.conf $GLANCES_OPT
+CMD python3 -m glances -C /etc/glances.conf $GLANCES_OPT
+##############################################################################
+# minimal image
+##############################################################################
#Create running images without any building dependency
-FROM alpine:3.13 as minimal
+FROM alpine:${IMAGE_VERSION} as minimal
+ARG PYTHON_VERSION
RUN apk add --no-cache \
python3 \
@@ -64,15 +82,21 @@ RUN apk add --no-cache \
iputils
COPY --from=remoteInstall /root/.local/bin /usr/local/bin/
-COPY --from=remoteInstall /root/.local/lib/python3.8/site-packages /usr/lib/python3.8/site-packages/
+COPY --from=remoteInstall /root/.local/lib/python${PYTHON_VERSION}/site-packages /usr/lib/python${PYTHON_VERSION}/site-packages/
+COPY ./docker-compose/glances.conf /etc/glances.conf
# EXPOSE PORT (XMLRPC / WebUI)
EXPOSE 61209 61208
# Define default command.
-CMD python3 -m glances -C /glances/conf/glances.conf $GLANCES_OPT
+CMD python3 -m glances -C /etc/glances.conf $GLANCES_OPT
+##############################################################################
+# full image
+##############################################################################
FROM minimal as full
+ARG PYTHON_VERSION
-COPY --from=additional-packages /root/.local/lib/python3.8/site-packages /usr/lib/python3.8/site-packages/
+COPY --from=additional-packages /root/.local/lib/python${PYTHON_VERSION}/site-packages /usr/lib/python${PYTHON_VERSION}/site-packages/
+COPY ./docker-compose/glances.conf /etc/glances.conf
diff --git a/docker-files/debian.Dockerfile b/docker-files/debian.Dockerfile
index 1eb9d8da..ef8f963e 100644
--- a/docker-files/debian.Dockerfile
+++ b/docker-files/debian.Dockerfile
@@ -4,7 +4,14 @@
# https://github.com/nicolargo/glances
#
-FROM python:3.9-slim-buster as build
+# WARNING: the version should be set.
+# Ex: Python 3.10 for 3.10-slim-buster
+# Note: ENV is for future running containers. ARG for building your Docker image.
+
+ARG IMAGE_VERSION=3.10-slim-buster
+ARG PYTHON_VERSION=3.10
+FROM python:${IMAGE_VERSION} as build
+ARG PYTHON_VERSION
# Install package
RUN apt-get update && \
@@ -20,6 +27,7 @@ RUN apt-get update && \
FROM build as remoteInstall
+ARG PYTHON_VERSION
# Install the dependencies beforehand to make them cacheable
COPY requirements.txt .
RUN pip3 install --no-cache-dir --user -r requirements.txt
@@ -30,16 +38,22 @@ RUN pip3 install --no-cache-dir --user glances[all]
FROM build as additional-packages
+ARG PYTHON_VERSION
COPY *requirements.txt ./
RUN CASS_DRIVER_NO_CYTHON=1 pip3 install --no-cache-dir --user -r optional-requirements.txt
+##############################################################################
+# dev image
+##############################################################################
FROM build as dev
+ARG PYTHON_VERSION
-COPY --from=additional-packages /root/.local/lib/python3.9/site-packages /usr/local/lib/python3.9/site-packages/
+COPY --from=additional-packages /root/.local/lib/python${PYTHON_VERSION}/site-packages /usr/local/lib/python${PYTHON_VERSION}/site-packages/
COPY . /glances
+COPY ./docker-compose/glances.conf /etc/glances.conf
# EXPOSE PORT (XMLRPC / WebUI)
EXPOSE 61209 61208
@@ -47,11 +61,15 @@ EXPOSE 61209 61208
WORKDIR /glances
# Define default command.
-CMD python3 -m glances -C /glances/conf/glances.conf $GLANCES_OPT
+CMD python3 -m glances -C /etc/glances.conf $GLANCES_OPT
+##############################################################################
+# minimal image
+##############################################################################
-#Create running images without any building dependency
-FROM python:3.9-slim-buster as minimal
+# Create running images without any building dependency
+FROM python:${IMAGE_VERSION} as minimal
+ARG PYTHON_VERSION
RUN apt-get update && \
apt-get install -y --no-install-recommends \
@@ -63,15 +81,21 @@ RUN apt-get update && \
apt-get clean && rm -rf /var/lib/apt/lists/*
COPY --from=remoteInstall /root/.local/bin /usr/local/bin/
-COPY --from=remoteInstall /root/.local/lib/python3.9/site-packages /usr/local/lib/python3.9/site-packages/
+COPY --from=remoteInstall /root/.local/lib/python${PYTHON_VERSION}/site-packages /usr/local/lib/python${PYTHON_VERSION}/site-packages/
+COPY ./docker-compose/glances.conf /etc/glances.conf
# EXPOSE PORT (XMLRPC / WebUI)
EXPOSE 61209 61208
# Define default command.
-CMD python3 -m glances -C /glances/conf/glances.conf $GLANCES_OPT
+CMD python3 -m glances -C /etc/glances.conf $GLANCES_OPT
+##############################################################################
+# full image
+##############################################################################
FROM minimal as full
+ARG PYTHON_VERSION
-COPY --from=additional-packages /root/.local/lib/python3.9/site-packages /usr/local/lib/python3.9/site-packages/
+COPY --from=additional-packages /root/.local/lib/python${PYTHON_VERSION}/site-packages /usr/local/lib/python${PYTHON_VERSION}/site-packages/
+COPY ./docker-compose/glances.conf /etc/glances.conf
diff --git a/glances/outdated.py b/glances/outdated.py
index 39cdd6dc..b44e319b 100644
--- a/glances/outdated.py
+++ b/glances/outdated.py
@@ -20,7 +20,6 @@
"""Manage Glances update."""
from datetime import datetime, timedelta
-from packaging.version import Version
import threading
import json
import pickle
@@ -33,6 +32,14 @@ from glances.config import user_cache_dir
from glances.globals import safe_makedirs
from glances.logger import logger
+try:
+ from packaging.version import Version
+ PACKAGING_IMPORT = True
+except ModuleNotFoundError as e:
+ logger.error("Unable to import 'packaging' module ({}). Glances cannot check for updates.".format(e))
+ PACKAGING_IMPORT = False
+
+
PYPI_API_URL = 'https://pypi.python.org/pypi/Glances/json'
@@ -54,6 +61,8 @@ class Outdated(object):
self.data = {u'installed_version': __version__, u'latest_version': '0.0', u'refresh_date': datetime.now()}
# Read the configuration file
self.load_config(config)
+ if not PACKAGING_IMPORT:
+ self.args.disable_check_update = False
logger.debug("Check Glances version up-to-date: {}".format(not self.args.disable_check_update))
# And update !