ci: implement github actions for builds

* includes build of docker files for multiple arch versions
This commit is contained in:
Eduard Marbach 2020-10-01 16:02:24 +02:00
parent 47b7dc9d5d
commit 82821ec585
6 changed files with 119 additions and 135 deletions

76
.github/workflows/main.yml vendored Normal file
View File

@ -0,0 +1,76 @@
name: CI
on:
pull_request:
branches: [ develop ]
push:
branches: [ master, develop ]
tags:
- v*
jobs:
buildx:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Prepare
id: prepare
env:
DOCKER_IMAGE: ${{ secrets.DOCKER_IMAGE }}
DOCKER_PLATFORMS: linux/amd64,linux/arm/v7,linux/arm64,linux/386
run: |
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
TAGS="--tag ${DOCKER_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
TAGS="$TAGS --tag ${DOCKER_IMAGE}:latest"
fi
echo ::set-output name=docker_image::${DOCKER_IMAGE}
echo ::set-output name=version::${VERSION}
echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \
--build-arg VERSION=${VERSION} \
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
--build-arg VCS_REF=${GITHUB_SHA::8} \
${TAGS} --file ./docker-files/Dockerfile ./docker-files/
- 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: Docker Buildx (build)
run: |
docker buildx build --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }}
- name: Login to DockerHub
if: success() && github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Docker Buildx (push)
if: success() && github.event_name != 'pull_request'
run: |
docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }}
- name: Inspect image
if: always() && github.event_name != 'pull_request'
run: |
docker buildx imagetools inspect ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }}

43
docker-files/Dockerfile Normal file
View File

@ -0,0 +1,43 @@
#
# 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/*
ARG VERSION
## Install glances
## If version is dev will use git checkout
RUN if [ "$VERSION" = "dev" ] ; then \
echo Installing dev branch of glances from git; \
apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/* ; \
pip3 install psutil bottle ; \
git clone -b develop https://github.com/nicolargo/glances.git ; \
else \
echo Installing glances from pip; \
pip3 install glances[all]; \
fi
# 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

View File

@ -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 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

View File

@ -1,25 +0,0 @@
#
# Glances Dockerfile for ARM (based on Alpine ARM)
#
# https://github.com/nicolargo/glances
#
# Thanks to @Overbryd for the Dockerfile
# Source: https://github.com/nicolargo/glances/issues/1419#issuecomment-677644194
#
FROM python:3.8-slim-buster
RUN apt-get update \
&& apt-get install -y \
gcc \
python3-dev
RUN pip install \
glances[web,ip,folders,docker,cpuinfo,action]
WORKDIR /glances
# expose xmlrpc & webui
EXPOSE 61209 61208
CMD python -m glances -C /glances/conf/glances.conf $GLANCES_OPT

View File

@ -1,43 +0,0 @@
#
# Glances Dockerfile (based on Ubuntu)
#
# https://github.com/nicolargo/glances
#
# Pull base image.
FROM ubuntu:20.04
# 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 \
python3-pip \
python3-dev && \
rm -rf /var/lib/apt/lists/*
## Instal glances
RUN \
pip3 install --upgrade pip && \
pip3 install setuptools && \
pip3 install glances[action,batinfo,browser,cpuinfo,docker,export,folders,gpu,graph,ip,raid,snmp,web,wifi] && \
pip3 install --upgrade -i https://test.pypi.org/simple/ Glances
# Define working directory.
WORKDIR /glances
# EXPOSE PORT (For XMLRPC)
EXPOSE 61209
# EXPOSE PORT (For Web UI)
EXPOSE 61208
# Define default command.
CMD python3 -m glances -C /glances/conf/glances.conf $GLANCES_OPT

View File

@ -1,43 +0,0 @@
#
# Glances Dockerfile (based on Ubuntu)
#
# https://github.com/nicolargo/glances
#
# Pull base image.
FROM ubuntu:20.04
# 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 \
python3-pip \
python3-dev && \
rm -rf /var/lib/apt/lists/*
## Instal glances
RUN \
pip3 install --upgrade pip && \
pip3 install setuptools \
glances[action,batinfo,browser,cpuinfo,docker,export,folders,gpu,graph,ip,raid,snmp,web,wifi] \
glances
# Define working directory.
WORKDIR /glances
# EXPOSE PORT (For XMLRPC)
EXPOSE 61209
# EXPOSE PORT (For Web UI)
EXPOSE 61208
# Define default command.
CMD python3 -m glances -C /glances/conf/glances.conf $GLANCES_OPT