summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicolargo <nicolashennion@gmail.com>2024-04-30 10:35:45 +0200
committernicolargo <nicolashennion@gmail.com>2024-04-30 10:35:45 +0200
commit88fee9bc8ed2882275b3363d9fcdfc260afbeb7a (patch)
treedfba01f8b62db9a777d36492f847cdc5b0243766
parentde69635d41efa38428e0779e2467632d2cafdede (diff)
Use buildx instead of build for local container images
-rw-r--r--Makefile13
-rw-r--r--README.rst4
-rw-r--r--docker-files/alpine.Dockerfile5
-rw-r--r--docker-files/ubuntu.Dockerfile8
-rw-r--r--glances/plugins/ip/__init__.py2
5 files changed, 21 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index e49c5301..a44396a4 100644
--- a/Makefile
+++ b/Makefile
@@ -184,6 +184,7 @@ snapcraft:
# ===================================================================
# Docker
+# Need Docker Buildx package (apt install docker-buildx on Ubuntu)
# ===================================================================
docker: docker-alpine docker-ubuntu ## Generate local docker images
@@ -191,24 +192,24 @@ docker: docker-alpine docker-ubuntu ## Generate local docker images
docker-alpine: docker-alpine-full docker-alpine-minimal docker-alpine-dev ## Generate local docker images (Alpine)
docker-alpine-full: ## Generate local docker image (Alpine full)
- docker build --target full -f ./docker-files/alpine.Dockerfile -t glances:local-alpine-full .
+ docker buildx build --target full -f ./docker-files/alpine.Dockerfile -t glances:local-alpine-full .
docker-alpine-minimal: ## Generate local docker image (Alpine minimal)
- docker build --target minimal -f ./docker-files/alpine.Dockerfile -t glances:local-alpine-minimal .
+ docker buildx build --target minimal -f ./docker-files/alpine.Dockerfile -t glances:local-alpine-minimal .
docker-alpine-dev: ## Generate local docker image (Alpine dev)
- docker build --target dev -f ./docker-files/alpine.Dockerfile -t glances:local-alpine-dev .
+ docker buildx build --target dev -f ./docker-files/alpine.Dockerfile -t glances:local-alpine-dev .
docker-ubuntu: docker-ubuntu-full docker-ubuntu-minimal docker-ubuntu-dev ## Generate local docker images (Ubuntu)
docker-ubuntu-full: ## Generate local docker image (Ubuntu full)
- docker build --target full -f ./docker-files/ubuntu.Dockerfile -t glances:local-ubuntu-full .
+ docker buildx build --target full -f ./docker-files/ubuntu.Dockerfile -t glances:local-ubuntu-full .
docker-ubuntu-minimal: ## Generate local docker image (Ubuntu minimal)
- docker build --target minimal -f ./docker-files/ubuntu.Dockerfile -t glances:local-ubuntu-minimal .
+ docker buildx build --target minimal -f ./docker-files/ubuntu.Dockerfile -t glances:local-ubuntu-minimal .
docker-ubuntu-dev: ## Generate local docker image (Ubuntu dev)
- docker build --target dev -f ./docker-files/ubuntu.Dockerfile -t glances:local-ubuntu-dev .
+ docker buildx build --target dev -f ./docker-files/ubuntu.Dockerfile -t glances:local-ubuntu-dev .
# ===================================================================
# Run
diff --git a/README.rst b/README.rst
index 4d80de92..059fd379 100644
--- a/README.rst
+++ b/README.rst
@@ -245,9 +245,9 @@ variable setting parameters for the glances startup command):
.. code-block:: console
- docker run -e TZ="${TZ}" -v `pwd`/glances.conf:/root/.config/glances/glances.conf -v /var/run/docker.sock:/var/run/docker.sock:ro -v /run/user/1000/podman/podman.sock:/run/user/1000/podman/podman.sock:ro --pid host -e GLANCES_OPT="-C /root/.config/glances/glances.conf" -it nicolargo/glances:latest-full
+ docker run -e TZ="${TZ}" -v $HOME/.config/glances/glances.conf:/glances.conf:ro -v /var/run/docker.sock:/var/run/docker.sock:ro -v /run/user/1000/podman/podman.sock:/run/user/1000/podman/podman.sock:ro --pid host -e GLANCES_OPT="-C /glances.conf" -it nicolargo/glances:latest-full
-Where \`pwd\`/glances.conf is a local directory containing your glances.conf file.
+Where $HOME/.config/glances/glances.conf is a local directory containing your glances.conf file.
Run the container in *Web server mode*:
diff --git a/docker-files/alpine.Dockerfile b/docker-files/alpine.Dockerfile
index 14e23c13..d7a2dab1 100644
--- a/docker-files/alpine.Dockerfile
+++ b/docker-files/alpine.Dockerfile
@@ -67,6 +67,7 @@ COPY requirements.txt docker-requirements.txt webui-requirements.txt optional-re
##############################################################################
# BUILD: Install the minimal image deps
FROM build as buildMinimal
+ARG PYTHON_VERSION
RUN /venv-build/bin/python${PYTHON_VERSION} -m pip install --target="/venv/lib/python${PYTHON_VERSION}/site-packages" \
-r requirements.txt \
@@ -76,6 +77,7 @@ RUN /venv-build/bin/python${PYTHON_VERSION} -m pip install --target="/venv/lib/p
##############################################################################
# BUILD: Install all the deps
FROM build as buildFull
+ARG PYTHON_VERSION
# Required for optional dependency cassandra-driver
ARG CASS_DRIVER_NO_CYTHON=1
@@ -91,10 +93,11 @@ RUN /venv-build/bin/python${PYTHON_VERSION} -m pip install --target="/venv/lib/p
##############################################################################
# Base image shared by all releases
FROM base as release
+ARG PYTHON_VERSION
# Copy source code and config file
COPY ./docker-compose/glances.conf /etc/glances/glances.conf
-COPY /glances /app/glances
+COPY ./glances/. /app/glances/
# Copy binary and update PATH
COPY docker-bin.sh /usr/local/bin/glances
diff --git a/docker-files/ubuntu.Dockerfile b/docker-files/ubuntu.Dockerfile
index 0fb38c4c..a44edbe2 100644
--- a/docker-files/ubuntu.Dockerfile
+++ b/docker-files/ubuntu.Dockerfile
@@ -60,6 +60,7 @@ COPY requirements.txt docker-requirements.txt webui-requirements.txt optional-re
##############################################################################
# BUILD: Install the minimal image deps
FROM build as buildMinimal
+ARG PYTHON_VERSION
RUN python3 -m pip install --target="/venv/lib/python${PYTHON_VERSION}/site-packages" \
-r requirements.txt \
@@ -69,6 +70,7 @@ RUN python3 -m pip install --target="/venv/lib/python${PYTHON_VERSION}/site-pack
##############################################################################
# BUILD: Install all the deps
FROM build as buildFull
+ARG PYTHON_VERSION
RUN python3 -m pip install --target="/venv/lib/python${PYTHON_VERSION}/site-packages" \
-r requirements.txt \
@@ -79,10 +81,11 @@ RUN python3 -m pip install --target="/venv/lib/python${PYTHON_VERSION}/site-pack
##############################################################################
# Base image shared by all releases
FROM base as release
+ARG PYTHON_VERSION
# Copy Glances source code and config file
COPY ./docker-compose/glances.conf /etc/glances/glances.conf
-COPY /glances /app/glances
+COPY ./glances/. /app/glances/
# Copy binary and update PATH
COPY docker-bin.sh /usr/local/bin/glances
@@ -99,12 +102,14 @@ CMD /venv/bin/python3 -m glances $GLANCES_OPT
################################################################################
# RELEASE: minimal
FROM release as minimal
+ARG PYTHON_VERSION
COPY --from=buildMinimal /venv /venv
################################################################################
# RELEASE: full
FROM release as full
+ARG PYTHON_VERSION
RUN apt-get update \
&& apt-get install -y --no-install-recommends libzmq5 \
@@ -116,6 +121,7 @@ COPY --from=buildFull /venv /venv
################################################################################
# RELEASE: dev - to be compatible with CI
FROM full as dev
+ARG PYTHON_VERSION
# Forward access and error logs to Docker's log collector
RUN ln -sf /dev/stdout /tmp/glances-root.log \
diff --git a/glances/plugins/ip/__init__.py b/glances/plugins/ip/__init__.py
index 9c079ef9..406f3af3 100644
--- a/glances/plugins/ip/__init__.py
+++ b/glances/plugins/ip/__init__.py
@@ -132,7 +132,7 @@ class PluginModel(GlancesPluginModel):
self.public_api, self.public_username, self.public_password
).get()
self.public_address = self.public_info['ip']
- except (KeyError, AttributeError) as e:
+ except (KeyError, AttributeError, TypeError) as e:
logger.debug("Cannot grab public IP information ({})".format(e))
else:
stats['public_address'] = (