mirror of https://github.com/nicolargo/glances
Merge pull request #1859 from Poeschl/versioned-minimal-full-images
Docker images overhaulpull/1860/head
commit
ccee17e4eb
|
@ -19,74 +19,6 @@ on:
|
|||
- v*
|
||||
|
||||
jobs:
|
||||
buildx:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Cache Docker layers
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: /tmp/.buildx-cache
|
||||
key: ${{ runner.os }}-buildx-${{ env.NODE_ENV }}-${{ github.sha }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-buildx-${{ env.NODE_ENV }}
|
||||
|
||||
- name: Configure ENVs
|
||||
env:
|
||||
DOCKER_IMAGE: ${{ secrets.DOCKER_IMAGE || env.DEFAULT_DOCKER_IMAGE }}
|
||||
DOCKERFILE: ${{ env.NODE_ENV == 'prod' && './docker-files/Dockerfile' || './docker-files/dev.Dockerfile' }}
|
||||
run: |
|
||||
ls -la /tmp/.buildx-cache || true
|
||||
VERSION=latest
|
||||
|
||||
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
||||
VERSION=${GITHUB_REF#refs/tags/v}
|
||||
fi
|
||||
|
||||
if [[ $GITHUB_REF == refs/heads/develop ]]; then
|
||||
VERSION=dev
|
||||
fi
|
||||
|
||||
echo "DOCKERFILE=${DOCKERFILE}" >> $GITHUB_ENV
|
||||
echo "VERSION=${VERSION}" >> $GITHUB_ENV
|
||||
echo "TAGS=${DOCKER_IMAGE}:${VERSION}" >> $GITHUB_ENV
|
||||
echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV
|
||||
echo "VCS_REF=${GITHUB_SHA::8}" >> $GITHUB_ENV
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
with:
|
||||
platforms: all
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
id: buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
with:
|
||||
version: latest
|
||||
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
if: ${{ env.PUSH_BRANCH == 'true' }}
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
push: ${{ env.PUSH_BRANCH == 'true' }}
|
||||
tags: ${{env.TAGS}}
|
||||
build-args: |
|
||||
VERSION=${{env.VERSION}}
|
||||
BUILD_DATE=${{env.BUILD_DATE}}
|
||||
VCS_REF=${{env.VCS_REF}}
|
||||
context: .
|
||||
file: ${{env.DOCKERFILE}}
|
||||
platforms: ${{env.DOCKER_PLATFORMS}}
|
||||
cache-from: type=local,src=/tmp/.buildx-cache
|
||||
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max
|
||||
|
||||
pypi:
|
||||
runs-on: ubuntu-latest
|
||||
|
@ -100,7 +32,7 @@ jobs:
|
|||
pip install
|
||||
build
|
||||
--user
|
||||
|
||||
|
||||
- name: Build a binary wheel and a source tarball
|
||||
run: >-
|
||||
python -m
|
||||
|
@ -122,4 +54,97 @@ jobs:
|
|||
uses: pypa/gh-action-pypi-publish@master
|
||||
with:
|
||||
user: __token__
|
||||
password: ${{ secrets.PYPI_API_TOKEN }}
|
||||
password: ${{ secrets.PYPI_API_TOKEN }}
|
||||
|
||||
create_Docker_builds:
|
||||
runs-on: ubuntu-latest
|
||||
# Make sure we release the python package first. So we are sure to get the latest.
|
||||
needs:
|
||||
- pypi
|
||||
outputs:
|
||||
tags: ${{ steps.config.outputs.tags }}
|
||||
steps:
|
||||
- name: Determine image tags
|
||||
id: config
|
||||
shell: bash
|
||||
run: |
|
||||
TAG_ARRAY='['
|
||||
|
||||
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
||||
VERSION=${GITHUB_REF#refs/tags/v}
|
||||
TAG_ARRAY="$TAG_ARRAY { \"target\": \"minimal\", \"tag\": \"${VERSION}\" },"
|
||||
TAG_ARRAY="$TAG_ARRAY { \"target\": \"full\", \"tag\": \"${VERSION}-full\" },"
|
||||
|
||||
elif [[ $GITHUB_REF == refs/heads/develop ]]; then
|
||||
TAG_ARRAY="$TAG_ARRAY { \"target\": \"dev\", \"tag\": \"dev\" },"
|
||||
|
||||
else
|
||||
TAG_ARRAY="$TAG_ARRAY { \"target\": \"minimal\", \"tag\": \"latest\" },"
|
||||
TAG_ARRAY="$TAG_ARRAY { \"target\": \"full\", \"tag\": \"latest-full\" },"
|
||||
fi
|
||||
|
||||
TAG_ARRAY="${TAG_ARRAY::-1} ]"
|
||||
|
||||
echo "Tags to build: $TAG_ARRAY"
|
||||
echo "::set-output name=tags::$TAG_ARRAY"
|
||||
|
||||
build_Docker_image:
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- create_Docker_builds
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: ['debian', 'alpine']
|
||||
tag: ${{ fromJson(needs.create_Docker_builds.outputs.tags) }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Retrieve Repository Docker metadata
|
||||
id: docker_meta
|
||||
uses: crazy-max/ghaction-docker-meta@v2.5.0
|
||||
with:
|
||||
images: ${{ env.DEFAULT_DOCKER_IMAGE }}
|
||||
labels: |
|
||||
org.opencontainers.image.url=https://nicolargo.github.io/glances/
|
||||
|
||||
- name: Cache Docker layers
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: /tmp/.buildx-cache
|
||||
key: ${{ runner.os }}-buildx-${{ env.NODE_ENV }}-${{ matrix.os }}-${{ matrix.tag.tag }}
|
||||
restore-keys: ${{ runner.os }}-buildx-${{ env.NODE_ENV }}-${{ matrix.os }}
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
with:
|
||||
platforms: all
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
id: buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
with:
|
||||
version: latest
|
||||
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
if: ${{ env.PUSH_BRANCH == 'true' }}
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Build and push image
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
push: ${{ env.PUSH_BRANCH == 'true' }}
|
||||
tags: "${{ matrix.os != 'debian' && format('{0}-', matrix.os) || '' }}${{ matrix.tag.tag }}"
|
||||
build-args: |
|
||||
CHANGING_ARG=${{ github.sha }}
|
||||
context: .
|
||||
file: "docker-files/${{ matrix.os }}.Dockerfile"
|
||||
platforms: ${{env.DOCKER_PLATFORMS}}
|
||||
target: ${{ matrix.tag.target }}
|
||||
labels: ${{ steps.docker_meta.outputs.labels }}
|
||||
cache-from: type=local,src=/tmp/.buildx-cache
|
||||
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
#
|
||||
# Glances Dockerfile (based on Ubuntu)
|
||||
#
|
||||
# https://github.com/nicolargo/glances
|
||||
#
|
||||
|
||||
ARG ARCH=
|
||||
FROM ${ARCH}python:3-slim-buster
|
||||
|
||||
# Install package
|
||||
# Must used calibre package to be able to run external module
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
RUN \
|
||||
apt-get update && \
|
||||
apt-get install -y \
|
||||
curl \
|
||||
gcc \
|
||||
lm-sensors \
|
||||
wireless-tools \
|
||||
iputils-ping && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Force rebuild otherwise it could be cached without rerun
|
||||
ARG VCS_REF
|
||||
RUN pip install glances[all]
|
||||
|
||||
# Define working directory.
|
||||
WORKDIR /glances
|
||||
|
||||
# EXPOSE PORT (XMLRPC / WebUI)
|
||||
EXPOSE 61209 61208
|
||||
|
||||
# Define default command.
|
||||
CMD python3 -m glances -C /glances/conf/glances.conf $GLANCES_OPT
|
|
@ -0,0 +1,20 @@
|
|||
# Dockerfiles
|
||||
|
||||
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
|
||||
For the dev image:
|
||||
``bash
|
||||
docker build --target dev -f docker-files/debian.Dockerfile -t glances .
|
||||
``
|
||||
|
||||
For the minimal image:
|
||||
``bash
|
||||
docker build --target minimal -f docker-files/debian.Dockerfile -t glances .
|
||||
``
|
||||
|
||||
For the full image:
|
||||
``bash
|
||||
docker build --target full -f docker-files/debian.Dockerfile -t glances .
|
||||
``
|
|
@ -0,0 +1,78 @@
|
|||
#
|
||||
# Glances Dockerfile (based on Alpine)
|
||||
#
|
||||
# https://github.com/nicolargo/glances
|
||||
#
|
||||
|
||||
FROM alpine:3.13 as build
|
||||
|
||||
RUN apk add --no-cache \
|
||||
python3 \
|
||||
python3-dev \
|
||||
py3-pip \
|
||||
py3-wheel \
|
||||
musl-dev \
|
||||
linux-headers \
|
||||
build-base \
|
||||
libzmq \
|
||||
zeromq-dev \
|
||||
curl \
|
||||
lm-sensors \
|
||||
wireless-tools \
|
||||
iputils
|
||||
|
||||
|
||||
FROM build as remoteInstall
|
||||
# Install the dependencies beforehand to make them cacheable
|
||||
COPY requirements.txt .
|
||||
RUN pip3 install --no-cache-dir --user -r requirements.txt
|
||||
|
||||
# Force install otherwise it could be cached without rerun
|
||||
ARG CHANGING_ARG
|
||||
RUN pip3 install --no-cache-dir --user glances[all]
|
||||
|
||||
|
||||
FROM build as additional-packages
|
||||
|
||||
COPY *requirements.txt .
|
||||
|
||||
RUN CASS_DRIVER_NO_CYTHON=1 pip3 install --no-cache-dir --user -r optional-requirements.txt
|
||||
|
||||
|
||||
FROM build as dev
|
||||
|
||||
COPY --from=additional-packages /root/.local/lib/python3.8/site-packages /usr/lib/python3.8/site-packages/
|
||||
COPY . /glances
|
||||
|
||||
# EXPOSE PORT (XMLRPC / WebUI)
|
||||
EXPOSE 61209 61208
|
||||
|
||||
WORKDIR /glances
|
||||
|
||||
# Define default command.
|
||||
CMD python3 -m glances -C /glances/conf/glances.conf $GLANCES_OPT
|
||||
|
||||
|
||||
#Create running images without any building dependency
|
||||
FROM alpine:3.13 as minimal
|
||||
|
||||
RUN apk add --no-cache \
|
||||
python3 \
|
||||
curl \
|
||||
lm-sensors \
|
||||
wireless-tools \
|
||||
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/
|
||||
|
||||
# EXPOSE PORT (XMLRPC / WebUI)
|
||||
EXPOSE 61209 61208
|
||||
|
||||
# Define default command.
|
||||
CMD python3 -m glances -C /glances/conf/glances.conf $GLANCES_OPT
|
||||
|
||||
|
||||
FROM minimal as full
|
||||
|
||||
COPY --from=additional-packages /root/.local/lib/python3.8/site-packages /usr/local/python3.8/site-packages/
|
|
@ -0,0 +1,75 @@
|
|||
#
|
||||
# Glances Dockerfile (based on Debian)
|
||||
#
|
||||
# https://github.com/nicolargo/glances
|
||||
#
|
||||
|
||||
FROM python:3.9-slim-buster as build
|
||||
|
||||
# Install package
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
python3-dev \
|
||||
curl \
|
||||
build-essential \
|
||||
lm-sensors \
|
||||
wireless-tools \
|
||||
iputils-ping && \
|
||||
apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
|
||||
FROM build as remoteInstall
|
||||
# Install the dependencies beforehand to make them cacheable
|
||||
COPY requirements.txt .
|
||||
RUN pip3 install --no-cache-dir --user -r requirements.txt
|
||||
|
||||
# Force install otherwise it could be cached without rerun
|
||||
ARG CHANGING_ARG
|
||||
RUN pip3 install --no-cache-dir --user glances[all]
|
||||
|
||||
|
||||
FROM build as additional-packages
|
||||
|
||||
COPY *requirements.txt .
|
||||
|
||||
RUN CASS_DRIVER_NO_CYTHON=1 pip3 install --no-cache-dir --user -r optional-requirements.txt
|
||||
|
||||
|
||||
FROM build as dev
|
||||
|
||||
COPY --from=additional-packages /root/.local/lib/python3.9/site-packages /usr/lib/python3.9/site-packages/
|
||||
COPY . /glances
|
||||
|
||||
# EXPOSE PORT (XMLRPC / WebUI)
|
||||
EXPOSE 61209 61208
|
||||
|
||||
WORKDIR /glances
|
||||
|
||||
# Define default command.
|
||||
CMD python3 -m glances -C /glances/conf/glances.conf $GLANCES_OPT
|
||||
|
||||
|
||||
#Create running images without any building dependency
|
||||
FROM python:3.9-slim-buster as minimal
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
curl \
|
||||
lm-sensors \
|
||||
wireless-tools \
|
||||
iputils-ping && \
|
||||
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/
|
||||
|
||||
# EXPOSE PORT (XMLRPC / WebUI)
|
||||
EXPOSE 61209 61208
|
||||
|
||||
# Define default command.
|
||||
CMD python3 -m glances -C /glances/conf/glances.conf $GLANCES_OPT
|
||||
|
||||
|
||||
FROM minimal as full
|
||||
|
||||
COPY --from=additional-packages /root/.local/lib/python3.9/site-packages /usr/local/lib/python3.9/site-packages/
|
|
@ -1,39 +0,0 @@
|
|||
#
|
||||
# Glances Dockerfile (based on Ubuntu)
|
||||
#
|
||||
# https://github.com/nicolargo/glances
|
||||
#
|
||||
|
||||
ARG ARCH=
|
||||
FROM ${ARCH}python:3-buster
|
||||
|
||||
# Install package
|
||||
# Must used calibre package to be able to run external module
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
RUN \
|
||||
apt-get update && \
|
||||
apt-get install -y \
|
||||
curl \
|
||||
gcc \
|
||||
git \
|
||||
lm-sensors \
|
||||
wireless-tools \
|
||||
iputils-ping && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN pip install psutil bottle
|
||||
|
||||
# Define working directory
|
||||
WORKDIR /glances
|
||||
|
||||
COPY *requirements.txt .
|
||||
|
||||
RUN CASS_DRIVER_NO_CYTHON=1 pip install -r optional-requirements.txt
|
||||
|
||||
COPY . /glances
|
||||
|
||||
# EXPOSE PORT (XMLRPC / WebUI)
|
||||
EXPOSE 61209 61208
|
||||
|
||||
# Define default command.
|
||||
CMD python3 -m glances -C /glances/conf/glances.conf $GLANCES_OPT
|
|
@ -1,24 +0,0 @@
|
|||
#
|
||||
# Glances Dockerfile based on Alpine OS
|
||||
#
|
||||
# https://github.com/nicolargo/glances
|
||||
#
|
||||
|
||||
# Pull base image.
|
||||
FROM alpine
|
||||
|
||||
# Install Glances (develop branch)
|
||||
RUN apk add python3 py3-psutil py3-bottle docker-py git
|
||||
RUN git clone -b develop https://github.com/nicolargo/glances.git
|
||||
|
||||
# Define working directory.
|
||||
WORKDIR /glances
|
||||
|
||||
# EXPOSE PORT (For XMLRPC)
|
||||
EXPOSE 61209
|
||||
|
||||
# EXPOSE PORT (For Web UI)
|
||||
EXPOSE 61208
|
||||
|
||||
# Define default command.
|
||||
CMD /usr/bin/python3 -m glances -C /glances/conf/glances.conf $GLANCES_OPT
|
Loading…
Reference in New Issue