Refactor Docker image factory: from now, only Alpine images will be provided

This commit is contained in:
nicolargo
2022-11-03 15:05:57 +01:00
parent 53f74248cd
commit 57a8a12a68
7 changed files with 25 additions and 152 deletions

View File

@@ -96,7 +96,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: ['debian', 'alpine']
os: ['alpine']
tag: ${{ fromJson(needs.create_Docker_builds.outputs.tags) }}
steps:
- name: Checkout
@@ -139,7 +139,7 @@ jobs:
uses: docker/build-push-action@v2
with:
push: ${{ env.PUSH_BRANCH == 'true' }}
tags: "${{ env.DEFAULT_DOCKER_IMAGE }}:${{ matrix.os != 'debian' && format('{0}-', matrix.os) || '' }}${{ matrix.tag.tag }}"
tags: "${{ env.DEFAULT_DOCKER_IMAGE }}:${{ matrix.os != 'alpine' && format('{0}-', matrix.os) || '' }}${{ matrix.tag.tag }}"
build-args: |
CHANGING_ARG=${{ github.sha }}
context: .

View File

@@ -115,7 +115,9 @@ flatpak: venv-dev-upgrade ## Generate FlatPack JSON file
# Docker
# ===================================================================
docker:
docker: docker-alpine
docker-alpine:
docker build --target full -f ./docker-files/alpine.Dockerfile -t glances:local-alpine-full .
docker build --target minimal -f ./docker-files/alpine.Dockerfile -t glances:local-alpine-minimal .
docker build --target dev -f ./docker-files/alpine.Dockerfile -t glances:local-alpine-dev .

View File

@@ -181,25 +181,20 @@ If you want to support other distributions, please contribute to `glancesautoins
Docker: the fun way
-------------------
Glances containers are availables. You can use it to monitor your
server and all your other containers!
Glances Docker images are availables. You can use it to monitor your
server and all your containers !
Get the Glances container:
.. code-block:: console
docker pull nicolargo/glances:alpine-latest-full
docker pull nicolargo/glances:latest-full
The following tags are availables:
- *alpine-latest-full* for a full Alpine Glances image (latest release) with all dependencies
- *latest-full* for a full Debian Glances image (latest release) with all dependencies
- *alpine-latest* for a basic Alpine Glances (latest release) version with minimal dependencies
- *latest* for a basic Debian Glances image (latest release) with minimal dependencies
- *alpine-dev* for a basic Alpine Glances image (development branch) with all dependencies
- *dev* for a basic Debian Glances image (development branch) with all dependencies
You can also specify a version (example: *alpine-3.2.7-full*).
- *latest-full* for a full Alpine Glances image (latest release) with all dependencies
- *latest* for a basic Alpine Glances (latest release) version with minimal dependencies (Bottle and Docker)
- *dev* for a basic Alpine Glances image (based on development branch) with all dependencies (Warning: may be instable)
Run last version of Glances container in *console mode*:

View File

@@ -1,3 +1,3 @@
FROM nicolargo/glances:alpine-dev
FROM nicolargo/glances:latest as glancesminimal
COPY glances.conf /glances/conf/glances.conf
CMD python -m glances -C /glances/conf/glances.conf $GLANCES_OPT

View File

@@ -15,7 +15,7 @@ services:
- "traefik.frontend.rule=Host:whoami.docker.localhost"
monitoring:
image: nicolargo/glances:alpine-dev
image: nicolargo/glances:dev
restart: unless-stopped
pid: host
privileged: true

View File

@@ -33,12 +33,15 @@ RUN apk add --no-cache \
FROM build as buildRequirements
ARG PYTHON_VERSION
COPY requirements.txt .
COPY webui-requirements.txt .
RUN pip3 install --no-cache-dir --user -r requirements.txt
# Minimal means no webui, but it break what is done previously (see #2155)
# So install the webui requirements...
COPY webui-requirements.txt .
RUN pip3 install --no-cache-dir --user -r webui-requirements.txt
# As minimal image we want to monitor others docker containers
RUN pip3 install --no-cache-dir --user docker
@@ -48,10 +51,9 @@ RUN pip3 install --no-cache-dir --user glances
##############################################################################
FROM build as buildOptionalRequirements
FROM buildRequirements as buildOptionalRequirements
ARG PYTHON_VERSION
COPY requirements.txt .
COPY optional-requirements.txt .
RUN CASS_DRIVER_NO_CYTHON=1 pip3 install --no-cache-dir --user -r optional-requirements.txt
@@ -70,9 +72,8 @@ COPY ./docker-compose/glances.conf /etc/glances.conf
# EXPOSE PORT (XMLRPC / WebUI)
EXPOSE 61209 61208
WORKDIR /glances
# Define default command.
WORKDIR /glances
CMD python3 -m glances -C /etc/glances.conf $GLANCES_OPT
##############################################################################
@@ -85,6 +86,8 @@ ARG PYTHON_VERSION
RUN apk add --no-cache \
python3 \
py3-packaging \
py3-dateutil \
curl \
lm-sensors \
wireless-tools \
@@ -94,10 +97,11 @@ COPY --from=buildRequirements /root/.local/bin /usr/local/bin/
COPY --from=buildRequirements /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 only because WebUI is not available)
EXPOSE 61209
# EXPOSE PORT (XMLRPC / WebUI)
EXPOSE 61209 61208
# Define default command.
WORKDIR /glances
CMD python3 -m glances -C /etc/glances.conf $GLANCES_OPT
##############################################################################
@@ -122,7 +126,6 @@ EXPOSE 61209 61208
RUN ln -sf /dev/stdout /tmp/glances-root.log \
&& ln -sf /dev/stderr /var/log/error.log
WORKDIR /glances
# Define default command.
WORKDIR /glances
CMD python3 -m glances -C /etc/glances.conf $GLANCES_OPT

View File

@@ -1,127 +0,0 @@
#
# Glances Dockerfile (based on Debian)
#
# https://github.com/nicolargo/glances
#
# 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 && \
apt-get install -y --no-install-recommends \
python3-dev \
curl \
build-essential \
lm-sensors \
wireless-tools \
smartmontools \
iputils-ping && \
apt-get clean && rm -rf /var/lib/apt/lists/*
##############################################################################
# Install the dependencies beforehand to make them cacheable
FROM build as buildRequirements
ARG PYTHON_VERSION
COPY requirements.txt .
COPY webui-requirements.txt .
RUN pip3 install --no-cache-dir --user -r requirements.txt
# Minimal means no webui, but it break what is done previously (see #2155)
# So install the webui requirements...
RUN pip3 install --no-cache-dir --user -r webui-requirements.txt
# As minimal image we want to monitor others docker containers
RUN pip3 install --no-cache-dir --user docker
# Force install otherwise it could be cached without rerun
ARG CHANGING_ARG
RUN pip3 install --no-cache-dir --user glances
##############################################################################
FROM build as buildOptionalRequirements
ARG PYTHON_VERSION
COPY requirements.txt .
COPY optional-requirements.txt .
RUN CASS_DRIVER_NO_CYTHON=1 pip3 install --no-cache-dir --user -r optional-requirements.txt
##############################################################################
# full image
##############################################################################
FROM build as full
ARG PYTHON_VERSION
COPY --from=buildRequirements /root/.local/bin /usr/local/bin/
COPY --from=buildRequirements /root/.local/lib/python${PYTHON_VERSION}/site-packages /usr/local/lib/python${PYTHON_VERSION}/site-packages/
COPY --from=buildOptionalRequirements /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
WORKDIR /glances
# Define default command.
CMD python3 -m glances -C /etc/glances.conf $GLANCES_OPT
##############################################################################
# minimal image
##############################################################################
# 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 \
curl \
lm-sensors \
wireless-tools \
smartmontools \
iputils-ping && \
apt-get clean && rm -rf /var/lib/apt/lists/*
COPY --from=buildRequirements /root/.local/bin /usr/local/bin/
COPY --from=buildRequirements /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)
EXPOSE 61209
# Define default command.
CMD python3 -m glances -C /etc/glances.conf $GLANCES_OPT
##############################################################################
# dev image
##############################################################################
FROM full as dev
ARG PYTHON_VERSION
COPY --from=buildRequirements /root/.local/bin /usr/local/bin/
COPY --from=buildRequirements /root/.local/lib/python${PYTHON_VERSION}/site-packages /usr/lib/python${PYTHON_VERSION}/site-packages/
COPY --from=buildOptionalRequirements /root/.local/lib/python${PYTHON_VERSION}/site-packages /usr/lib/python${PYTHON_VERSION}/site-packages/
COPY ./docker-compose/glances.conf /etc/glances.conf
# Copy the current Glances source code
COPY . /glances
# EXPOSE PORT (XMLRPC / WebUI)
EXPOSE 61209 61208
# Forward access and error logs to Docker's log collector
RUN ln -sf /dev/stdout /tmp/glances-root.log \
&& ln -sf /dev/stderr /var/log/error.log
WORKDIR /glances
# Define default command.
CMD python3 -m glances -C /etc/glances.conf $GLANCES_OPT