From 25320081620b6fd23e42d43d33d6f44e265a0657 Mon Sep 17 00:00:00 2001 From: nicolargo Date: Thu, 15 Sep 2022 11:02:11 +0200 Subject: [PATCH] Correct issue on the dev Docker --- Makefile | 18 +++++++++++++++ docker-files/README.md | 41 ++++++---------------------------- docker-files/alpine.Dockerfile | 22 +++++------------- docker-files/debian.Dockerfile | 17 +++++++++----- 4 files changed, 42 insertions(+), 56 deletions(-) diff --git a/Makefile b/Makefile index f139e4c3..cfe95595 100644 --- a/Makefile +++ b/Makefile @@ -108,6 +108,15 @@ flatpak: venv-dev-upgrade ## Generate FlatPack JSON file rm -rf ./flatpak-builder-tools @echo "Now follow: https://github.com/flathub/flathub/wiki/App-Submission" +# =================================================================== +# Docker +# =================================================================== + +docker: + 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 . + # =================================================================== # Run # =================================================================== @@ -121,6 +130,15 @@ run-debug: ## Start Glances in debug console mode (also called standalone) run-local-conf: ## Start Glances in console mode with the system conf file ./venv/bin/python -m glances +run-docker-alpine-minimal: ## Start Glances Alpine Docker minimal in console mode + docker run --rm -v /var/run/docker.sock:/var/run/docker.sock:ro --pid host --network host -it glances:local-alpine-minimal + +run-docker-alpine-full: ## Start Glances Alpine Docker full in console mode + docker run --rm -v /var/run/docker.sock:/var/run/docker.sock:ro --pid host --network host -it glances:local-alpine-full + +run-docker-alpine-dev: ## Start Glances Alpine Docker dev in console mode + docker run --rm -v /var/run/docker.sock:/var/run/docker.sock:ro --pid host --network host -it glances:local-alpine-dev + run-webserver: ## Start Glances in Web server mode ./venv/bin/python -m glances -C ./conf/glances.conf -w diff --git a/docker-files/README.md b/docker-files/README.md index 93a4e321..c198506b 100644 --- a/docker-files/README.md +++ b/docker-files/README.md @@ -1,38 +1,11 @@ # 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`. +```bash +make docker +``` -## Examples for Debian images +Then test the image with: -For the dev image: -``bash -docker build --target dev -f ./docker-files/debian.Dockerfile -t glances:dev . -`` - -For the minimal image: -``bash -docker build --target minimal -f ./docker-files/debian.Dockerfile -t glances:minimal . -`` - -For the full image: -``bash -docker build --target full -f ./docker-files/debian.Dockerfile -t glances:full . -`` - -## Examples for Alpine images - -For the dev image: -``bash -docker build --target dev -f ./docker-files/alpine.Dockerfile -t glances:dev . -`` - -For the minimal image: -``bash -docker build --target minimal -f ./docker-files/alpine.Dockerfile -t glances:minimal . -`` - -For the full image: -``bash -docker build --target full -f ./docker-files/alpine.Dockerfile -t glances:full . -`` +```bash +make run-docker-alpine-dev +``` diff --git a/docker-files/alpine.Dockerfile b/docker-files/alpine.Dockerfile index 048c7fb4..3a26c2de 100644 --- a/docker-files/alpine.Dockerfile +++ b/docker-files/alpine.Dockerfile @@ -37,7 +37,7 @@ 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] +RUN pip3 install --no-cache-dir --user "glances[all]" FROM build as additional-packages @@ -48,16 +48,15 @@ COPY *requirements.txt ./ RUN CASS_DRIVER_NO_CYTHON=1 pip3 install --no-cache-dir --user -r optional-requirements.txt ############################################################################## -# dev image +# full image ############################################################################## -FROM build as dev +FROM build as full ARG PYTHON_VERSION COPY --from=remoteInstall /root/.local/bin /usr/local/bin/ COPY --from=remoteInstall /root/.local/lib/python${PYTHON_VERSION}/site-packages /usr/lib/python${PYTHON_VERSION}/site-packages/ COPY --from=additional-packages /root/.local/lib/python${PYTHON_VERSION}/site-packages /usr/lib/python${PYTHON_VERSION}/site-packages/ -COPY . /glances COPY ./docker-compose/glances.conf /etc/glances.conf # EXPOSE PORT (XMLRPC / WebUI) @@ -72,7 +71,7 @@ CMD python3 -m glances -C /etc/glances.conf $GLANCES_OPT # minimal image ############################################################################## -#Create running images without any building dependency +# Create running images without any building dependency FROM alpine:${IMAGE_VERSION} as minimal ARG PYTHON_VERSION @@ -94,17 +93,8 @@ EXPOSE 61209 CMD python3 -m glances -C /etc/glances.conf $GLANCES_OPT ############################################################################## -# full image +# dev image (=full) ############################################################################## -FROM minimal as full -ARG PYTHON_VERSION +FROM full as dev -COPY --from=additional-packages /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 / WebUI) -EXPOSE 61209 61208 - -# Define default command. -CMD python3 -m glances -C /etc/glances.conf $GLANCES_OPT diff --git a/docker-files/debian.Dockerfile b/docker-files/debian.Dockerfile index 35163854..596e258d 100644 --- a/docker-files/debian.Dockerfile +++ b/docker-files/debian.Dockerfile @@ -34,7 +34,7 @@ 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] +RUN pip3 install --no-cache-dir --user "glances[all]" FROM build as additional-packages @@ -45,10 +45,10 @@ COPY *requirements.txt ./ RUN CASS_DRIVER_NO_CYTHON=1 pip3 install --no-cache-dir --user -r optional-requirements.txt ############################################################################## -# dev image +# full image ############################################################################## -FROM build as dev +FROM build as full ARG PYTHON_VERSION COPY --from=remoteInstall /root/.local/bin /usr/local/bin/ @@ -93,17 +93,22 @@ EXPOSE 61209 CMD python3 -m glances -C /etc/glances.conf $GLANCES_OPT ############################################################################## -# full image +# dev image (=full) ############################################################################## -FROM minimal as full +FROM build as dev ARG PYTHON_VERSION -COPY --from=additional-packages /root/.local/lib/python${PYTHON_VERSION}/site-packages /usr/local/lib/python${PYTHON_VERSION}/site-packages/ +COPY --from=remoteInstall /root/.local/bin /usr/local/bin/ +COPY --from=remoteInstall /root/.local/lib/python${PYTHON_VERSION}/site-packages /usr/lib/python${PYTHON_VERSION}/site-packages/ +COPY --from=additional-packages /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 / WebUI) EXPOSE 61209 61208 +WORKDIR /glances + # Define default command. CMD python3 -m glances -C /etc/glances.conf $GLANCES_OPT +