Skip to content

Commit 32e5c5f

Browse files
consumerui ui dockerfile optimization (#1394)
consumerui ui dockerfile optimization
1 parent 6f9f0bd commit 32e5c5f

File tree

1 file changed

+48
-12
lines changed

1 file changed

+48
-12
lines changed

consumerui/Dockerfile

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,58 @@
1+
# Use a minimal base image
12
FROM ubuntu:20.04
23

3-
RUN apt-get update -y && DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata && apt-get install -y python3-pip python-setuptools curl wget tar sudo apt-transport-https ca-certificates socat python-yaml vim graphviz
4+
# Set environment variables for non-interactive installs and paths
5+
ENV DEBIAN_FRONTEND=noninteractive \
6+
KUBEPLUS_HOME=/root
47

5-
RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" && sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
8+
# Update and install only required packages in a single RUN to minimize layers
9+
RUN apt-get update -y && apt-get install -y --no-install-recommends \
10+
tzdata \
11+
python3-pip \
12+
python3-setuptools \
13+
curl \
14+
wget \
15+
tar \
16+
sudo \
17+
apt-transport-https \
18+
ca-certificates \
19+
socat \
20+
python3-yaml \
21+
vim \
22+
graphviz && \
23+
# Clean up to reduce image size
24+
apt-get clean && rm -rf /var/lib/apt/lists/*
625

7-
RUN cp /usr/bin/python3.8 /usr/bin/python
26+
# Install kubectl
27+
RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" && \
28+
install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl && \
29+
rm kubectl
830

9-
RUN wget https://github.com/cloud-ark/kubeplus/raw/master/kubeplus-kubectl-plugins.tar.gz && gunzip kubeplus-kubectl-plugins.tar.gz && tar -xvf kubeplus-kubectl-plugins.tar && cp -r /plugins/* bin/
31+
# Create symbolic link for Python
32+
RUN ln -s /usr/bin/python3 /usr/bin/python
1033

11-
ENV KUBEPLUS_HOME /
34+
# Install KubePlus plugins
35+
RUN wget https://github.com/cloud-ark/kubeplus/raw/master/kubeplus-kubectl-plugins.tar.gz && \
36+
tar -xzf kubeplus-kubectl-plugins.tar.gz && \
37+
mv plugins/* /usr/local/bin/ && \
38+
rm -rf kubeplus-kubectl-plugins.tar.gz kubeplus-kubectl-plugins.tar
1239

13-
ADD requirements.txt /root/requirements.txt
14-
ADD consumerui.py /root/consumerui.py
15-
ADD grapher.py /root/grapher.py
16-
ADD templates /root/templates
17-
ADD static /root/static
18-
RUN cd /root; pip install -r requirements.txt
19-
RUN mkdir /root/.kube/
40+
# Add application source files
41+
WORKDIR /root
42+
ADD requirements.txt /root/
43+
ADD consumerui.py /root/
44+
ADD grapher.py /root/
45+
ADD templates /root/templates/
46+
ADD static /root/static/
2047

48+
# Install Python dependencies
49+
RUN pip3 install --no-cache-dir -r requirements.txt
50+
51+
# Create necessary directories
52+
RUN mkdir -p /root/.kube/
53+
54+
# Expose the application port
2155
EXPOSE 5000
56+
57+
# Set the entrypoint
2258
CMD ["python3", "/root/consumerui.py"]

0 commit comments

Comments
 (0)