Skip to content

Commit

Permalink
Refactor the dockerfile | Exit the script when error encountered
Browse files Browse the repository at this point in the history
  • Loading branch information
chiukapoor committed Oct 30, 2024
1 parent 7789221 commit 57804d8
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 20 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/pr-minikube.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: CI-Minikube
on:
- pull_request
workflow_dispatch:
# - pull_request
env:
ACTIONS_RUNNER_DEBUG: true
KUBEPLUS_TEST_OUTPUT: yes
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: CI
on:
# pull_request:
workflow_dispatch:
# push:
# branches:
# - master
pull_request:
push:
branches:
- master
env:
ACTIONS_RUNNER_DEBUG: true
KUBEPLUS_TEST_OUTPUT: yes
Expand Down
43 changes: 28 additions & 15 deletions deploy/Dockerfile.kubeconfiggenerator
Original file line number Diff line number Diff line change
@@ -1,25 +1,38 @@
FROM ubuntu:20.04

USER root
RUN apt-get update && apt-get upgrade && apt-get install -y curl openssl jq python3 python3-pip wget ca-certificates && pip3 install pyyaml
#COPY kubectl /root/

# Update, install dependencies, and clean up apt cache
RUN apt-get update && apt-get upgrade -y

RUN apt-get install -y --no-install-recommends curl openssl jq python3 python3-pip wget ca-certificates

RUN rm -rf /var/lib/apt/lists/*

RUN pip3 install pyyaml

# Copy files to the image
COPY kubeconfiggenerator.py /root/.
COPY kubeconfiggenerator.sh /root/.
ADD requirements.txt /root/requirements.txt
RUN cd /root; pip3 install -r requirements.txt
#RUN cp /root/kubectl bin/. && chmod +x /root/kubectl && chmod +x bin/kubectl &&
RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
RUN install -o root -g root -m 0755 kubectl bin/kubectl
RUN cp bin/kubectl /root/kubectl
RUN chmod +x /root/kubectl && chmod +x bin/kubectl
RUN chmod +x /root/kubeconfiggenerator.sh
RUN wget https://get.helm.sh/helm-v3.12.1-linux-amd64.tar.gz \
&& gunzip helm-v3.12.1-linux-amd64.tar.gz \
&& tar -xvf helm-v3.12.1-linux-amd64.tar \
&& mv linux-amd64/helm bin/.

# Install Python dependencies
RUN cd /root && pip3 install -r requirements.txt

# Install kubectl and clean up
RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" && \
install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl && \
rm kubectl

#ENTRYPOINT ["/root/kubeconfiggenerator.sh"]
# Set executable permissions for scripts
RUN chmod +x /root/kubeconfiggenerator.sh /root/kubeconfiggenerator.py

# Install Helm, clean up tar files
RUN wget https://get.helm.sh/helm-v3.12.1-linux-amd64.tar.gz && \
tar -xzf helm-v3.12.1-linux-amd64.tar.gz && \
mv linux-amd64/helm /usr/local/bin/helm && \
rm -rf helm-v3.12.1-linux-amd64.tar.gz linux-amd64

# Set default command to run the Python script
EXPOSE 5005
CMD ["python3", "/root/kubeconfiggenerator.py"]

3 changes: 3 additions & 0 deletions deploy/build-artifact-kubeconfiggenerator.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/bash

# Exit on error
set -e

if (( $# < 1 )); then
echo "./build-artifact-kubeconfiggenerator.sh <latest | versioned>"
fi
Expand Down
1 change: 1 addition & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ if $INSTALL_KUBEPLUS; then
exit 1
fi
echo "Waiting for KubePlus to start.."
kubectl get pods --namespace $KUBEPLUS_NAMESPACE
sleep 1
elapsed=$((elapsed + 1))
done
Expand Down

0 comments on commit 57804d8

Please sign in to comment.