mirror of https://github.com/nicolargo/glances.git
fix: dev build contains all optional req
- requires base image to be full fledged python -> results in bigger image size for dev.
This commit is contained in:
parent
228818ee55
commit
28f1143976
|
|
@ -1,5 +1,8 @@
|
|||
name: CI
|
||||
|
||||
env:
|
||||
DEFAULT_DOCKER_IMAGE: nicolargo/glances
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ develop ]
|
||||
|
|
@ -15,33 +18,45 @@ jobs:
|
|||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Prepare
|
||||
id: prepare
|
||||
- name: Cache Docker layers
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: /tmp/.buildx-cache
|
||||
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-buildx-
|
||||
|
||||
- name: Set envs
|
||||
env:
|
||||
DOCKER_IMAGE: ${{ secrets.DOCKER_IMAGE }}
|
||||
DOCKER_IMAGE: ${{ secrets.DOCKER_IMAGE || env.DEFAULT_DOCKER_IMAGE }}
|
||||
DOCKER_PLATFORMS: linux/amd64,linux/arm/v7,linux/arm64,linux/386
|
||||
run: |
|
||||
DOCKERFILE=./docker-files/dev.Dockerfile
|
||||
PUSH_IMAGE=false
|
||||
VERSION=latest
|
||||
|
||||
|
||||
if [[ $GITHUB_REF == refs/heads/master ]]; then
|
||||
PUSH_IMAGE=true
|
||||
fi
|
||||
|
||||
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
||||
VERSION=${GITHUB_REF#refs/tags/v}
|
||||
PUSH_IMAGE=true
|
||||
DOCKERFILE=./docker-files/Dockerfile
|
||||
fi
|
||||
|
||||
if [[ $GITHUB_REF == refs/heads/develop ]]; then
|
||||
VERSION=dev
|
||||
PUSH_IMAGE=true
|
||||
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/
|
||||
echo "DOCKERFILE=${DOCKERFILE}" >> $GITHUB_ENV
|
||||
echo "VERSION=${VERSION}" >> $GITHUB_ENV
|
||||
echo "PUSH_IMAGE=${PUSH_IMAGE}" >> $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
|
||||
echo "PLATFORMS=${DOCKER_PLATFORMS}" >> $GITHUB_ENV
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
|
|
@ -54,23 +69,24 @@ jobs:
|
|||
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
|
||||
if: ${{env.PUSH_IMAGE == true}}
|
||||
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 }}
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
push: ${{env.PUSH_IMAGE == 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.PLATFORMS}}
|
||||
cache-from: type=local,src=/tmp/.buildx-cache
|
||||
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max
|
||||
|
|
|
|||
|
|
@ -13,25 +13,16 @@ ENV DEBIAN_FRONTEND noninteractive
|
|||
RUN \
|
||||
apt-get update && \
|
||||
apt-get install -y \
|
||||
curl \
|
||||
gcc \
|
||||
lm-sensors \
|
||||
wireless-tools \
|
||||
iputils-ping && \
|
||||
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
|
||||
# Force rebuild otherwise it could be cached without rerun
|
||||
ARG VCS_REF
|
||||
RUN pip install glances[all]
|
||||
|
||||
# Define working directory.
|
||||
WORKDIR /glances
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
#
|
||||
# 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
|
||||
|
||||
COPY . /glances
|
||||
|
||||
# Define working directory
|
||||
WORKDIR /glances
|
||||
|
||||
RUN CASS_DRIVER_NO_CYTHON=1 pip install -r optional-requirements.txt
|
||||
|
||||
# EXPOSE PORT (XMLRPC / WebUI)
|
||||
EXPOSE 61209 61208
|
||||
|
||||
# Define default command.
|
||||
CMD python3 -m glances -C /glances/conf/glances.conf $GLANCES_OPT
|
||||
Loading…
Reference in New Issue