summaryrefslogtreecommitdiffstats
path: root/docker-files
diff options
context:
space:
mode:
authorMarkus Pöschl <Poeschl@users.noreply.github.com>2021-05-14 13:42:53 +0200
committerMarkus Pöschl <Poeschl@users.noreply.github.com>2021-05-15 14:39:24 +0200
commit281382c030110c42841dbd84f5ebbd6616f17cf3 (patch)
treeb3194eaf4b72a8d443ea5fc4c09daa088f37dfe9 /docker-files
parent781c9961cb26da0821f6fc460e1fc1640cb5f8ec (diff)
Migrate the dev image also in the multi-stage build
Diffstat (limited to 'docker-files')
-rw-r--r--docker-files/README.md20
-rw-r--r--docker-files/debian.Dockerfile22
-rw-r--r--docker-files/dev.Dockerfile39
3 files changed, 38 insertions, 43 deletions
diff --git a/docker-files/README.md b/docker-files/README.md
new file mode 100644
index 00000000..874f34a5
--- /dev/null
+++ b/docker-files/README.md
@@ -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 .
+``
diff --git a/docker-files/debian.Dockerfile b/docker-files/debian.Dockerfile
index 75e60c7c..ff9a522a 100644
--- a/docker-files/debian.Dockerfile
+++ b/docker-files/debian.Dockerfile
@@ -18,10 +18,13 @@ RUN apt-get update && \
iputils-ping && \
apt-get clean && rm -rf /var/lib/apt/lists/*
+
+FROM build as remoteInstall
# Force rebuild otherwise it could be cached without rerun
ARG VCS_REF
RUN pip3 install --no-cache-dir --user glances[all]
+
FROM build as additional-packages
COPY *requirements.txt .
@@ -29,7 +32,19 @@ COPY *requirements.txt .
RUN CASS_DRIVER_NO_CYTHON=1 pip3 install --no-cache-dir --user -r optional-requirements.txt
-#Create running image without any building dependency
+FROM build as dev
+
+COPY . /glances
+COPY --from=additional-packages /root/.local/lib/python3.9/site-packages /usr/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
+
+
+#Create running images without any building dependency
FROM ${ARCH}python:3.9-slim-buster as minimal
RUN apt-get update && \
@@ -40,8 +55,8 @@ RUN apt-get update && \
iputils-ping && \
apt-get clean && rm -rf /var/lib/apt/lists/*
-COPY --from=build /root/.local/bin /usr/local/bin/
-COPY --from=build /root/.local/lib/python3.9/site-packages /usr/local/lib/python3.9/site-packages/
+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
@@ -53,4 +68,3 @@ 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/
-
diff --git a/docker-files/dev.Dockerfile b/docker-files/dev.Dockerfile
deleted file mode 100644
index 9fbf7924..00000000
--- a/docker-files/dev.Dockerfile
+++ /dev/null
@@ -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