11FROM ubuntu:24.04
22
3- # Set the locale(en_US.UTF-8)
4- ENV LANG en_US.UTF-8
5- ENV LANGUAGE en_US:en
6- ENV LC_ALL en_US.UTF-8
7- ENV PATH $PATH:/usr/local/bin
3+ ARG TARGETARCH
84
9- # Install additional utils not included by default
5+ # Set working directory
6+ WORKDIR /root
7+
8+ ENV JENKINS_HOME /home/jenkins
9+
10+ # Set Bash as the default shell
11+ RUN chsh -s /bin/bash
12+ SHELL ["/bin/bash" , "-c" ]
13+
14+ # Create a script file sourced by both interactive and non-interactive bash shells
15+ ENV BASH_ENV=/root/.bash_env
16+ RUN touch "${BASH_ENV}"
17+ RUN echo '. "${BASH_ENV}"' >> /root/.bashrc
18+
19+ # Install utils
1020RUN apt-get update && \
11- apt-get install -y \
21+ apt-get install -y --no-install-recommends \
1222 ca-certificates \
23+ git \
1324 curl \
1425 perl \
1526 openssl \
@@ -32,11 +43,20 @@ RUN apt-get update && \
3243 libssl-dev \
3344 libperl-dev \
3445 zlib1g-dev \
46+ python3 \
3547 python3-pip \
3648 podman \
37- openjdk-21-jdk && \
38- apt-get clean && \
39- rm -rf /var/lib/apt/lists/*
49+ software-properties-common \
50+ apt-transport-https \
51+ openjdk-21-jdk
52+
53+ # # Settings for Java
54+ ENV JDK_HOME=/usr/lib/jvm/java-21-openjdk-${TARGETARCH}
55+ ENV JAVA_HOME=$JDK_HOME
56+ ENV PATH=$PATH:${JAVA_HOME}/bin
57+
58+ # Settings for python
59+ RUN ln -fs $(which python3) /usr/bin/python && ln -fs $(which pip3) /usr/bin/pip
4060
4161# Install docker CLI
4262RUN install -m 0755 -d /etc/apt/keyrings && \
@@ -47,28 +67,28 @@ RUN install -m 0755 -d /etc/apt/keyrings && \
4767 $(. /etc/os-release && echo " ${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
4868 tee /etc/apt/sources.list.d/docker.list > /dev/null && \
4969 apt-get update && \
50- apt-get install -y docker-ce-cli docker-buildx-plugin docker-compose-plugin && \
51- apt-get clean && \
52- rm -rf /var/lib/apt/lists/*
70+ apt-get install -y docker-ce-cli docker-buildx-plugin docker-compose-plugin
5371
5472# Install helm
55- RUN curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 && \
56- chmod 700 get_helm.sh && \
57- ./get_helm.sh && \
58- rm get_helm.sh
73+ RUN curl https://baltocdn.com/helm/signing.asc | gpg --dearmor | tee /usr/share/keyrings/helm.gpg > /dev/null && \
74+ apt-get install apt-transport-https --yes && \
75+ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/helm.gpg] https://baltocdn.com/helm/stable/debian/ all main" | tee /etc/apt/sources.list.d/helm-stable-debian.list && \
76+ apt-get update && \
77+ apt-get install -y helm
5978
6079# Install kubectl
61- RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/$(dpkg --print-architecture)/kubectl" && \
62- install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl && \
63- rm kubectl
80+ RUN curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.32/deb/Release.key | gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg && \
81+ chmod 644 /etc/apt/keyrings/kubernetes-apt-keyring.gpg && \
82+ echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.32/deb/ /' | tee /etc/apt/sources.list.d/kubernetes.list && \
83+ chmod 644 /etc/apt/sources.list.d/kubernetes.list && \
84+ apt-get update && \
85+ apt-get install -y kubectl
6486
6587# Install kustomize
66- RUN curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
67-
68- # Set up Sonar Scanner
69- ENV SONAR_SCANNER_VERSION 7.0.2.4839
88+ RUN cd /usr/local/bin && curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
7089
7190# Install Sonar Scanner CLI
91+ ENV SONAR_SCANNER_VERSION=7.0.2.4839
7292RUN arch=$(dpkg --print-architecture) && \
7393 if [ $arch = "amd64" ]; then \
7494 TARGET_ARCH=linux-x64; \
@@ -80,18 +100,101 @@ RUN arch=$(dpkg --print-architecture) && \
80100 wget -O sonar_scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${SONAR_SCANNER_VERSION}-${TARGET_ARCH}.zip && \
81101 unzip sonar_scanner.zip -d /opt && \
82102 rm sonar_scanner.zip && \
83- ln -s /opt/sonar-scanner-$SONAR_SCANNER_VERSION-${TARGET_ARCH}/bin/sonar-scanner /usr/local/bin/sonar-scanner
103+ ln -fs /opt/sonar-scanner-${ SONAR_SCANNER_VERSION} -${TARGET_ARCH}/bin/sonar-scanner /usr/local/bin/sonar-scanner
84104
85105# Install ks (Kubesphere CLI)
86106RUN curl -fL https://github.com/kubesphere-sigs/ks/releases/download/v0.0.73/ks-linux-$(dpkg --print-architecture).tar.gz | tar xzv && \
87107 mv ks /usr/local/bin/
88108
109+ # Install golang
110+ ENV GOVERSION=1.23
111+ ENV GOROOT=/usr/lib/go-${GOVERSION}
112+ ENV GOPATH=$JENKINS_HOME/go
113+ ENV PATH=$PATH:$GOROOT/bin:$GOPATH/bin
114+ RUN mkdir -p $GOPATH/bin && mkdir -p $GOPATH/src && mkdir -p $GOPATH/pkg
115+ RUN add-apt-repository -y ppa:longsleep/golang-backports && \
116+ apt-get update && \
117+ apt-get install -y golang-${GOVERSION}-go
118+
119+ RUN go env -w GOPATH=$JENKINS_HOME/go
120+
121+ # Install sdkman
122+ RUN curl -s "https://get.sdkman.io" | bash
89123
124+ # Install gradle
125+ ENV GRADLE_VERSION=8.13
126+ RUN source "/root/.sdkman/bin/sdkman-init.sh" && \
127+ sdk install gradle ${GRADLE_VERSION}
128+
129+ RUN ln -fs /root/.sdkman/candidates/gradle/current/bin/gradle /usr/local/bin/gradle
130+
131+ # Install Maven
132+ ENV MAVEN_VERSION=3.9.9
133+ RUN curl -f -L https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz | tar -C /opt -xzv
134+ ENV M2_HOME=/opt/apache-maven-$MAVEN_VERSION
135+ ENV maven.home=$M2_HOME
136+ ENV M2=$M2_HOME/bin
137+ ENV PATH=$PATH:$M2
138+
139+ # Install ant
140+ ENV ANT_VERSION=1.10.15
141+ RUN wget -q https://archive.apache.org/dist/ant/binaries/apache-ant-${ANT_VERSION}-bin.tar.gz && \
142+ tar -xzf apache-ant-${ANT_VERSION}-bin.tar.gz && \
143+ mv apache-ant-${ANT_VERSION} /opt/ant && \
144+ rm apache-ant-${ANT_VERSION}-bin.tar.gz
145+ ENV ANT_HOME=/opt/ant
146+ ENV PATH=${PATH}:${ANT_HOME}/bin
147+
148+ # Install nvm
149+ RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | PROFILE="${BASH_ENV}" bash
150+ RUN echo node > .nvmrc
151+
152+ # Download and install Node.js
153+ RUN nvm install 22
154+ RUN npm install --global watch-cli vsce typescript
155+
156+ # Install Yarn
157+ RUN npm install --global yarn
158+
159+ # Install .NET
160+ RUN add-apt-repository -y ppa:dotnet/backports && \
161+ apt-get update && \
162+ apt-get install -y dotnet-sdk-9.0
163+
164+ ENV PATH=$PATH:/root/.nuget/tools:/root/.dotnet/tools
165+
166+ # Settings for podman
90167RUN mkdir -p /etc/containers
91168COPY *.conf /etc/containers/
92-
93169VOLUME /var/lib/containers
94170
171+ # Verify installations
172+ RUN printenv
173+ RUN echo "docker: $(docker --version)"
174+ RUN echo "podman: $(podman --version)"
175+ RUN echo "java: $(java --version)"
176+ RUN echo "helm: $(helm version)"
177+ RUN echo "kubectl: $(kubectl version --client)"
178+ RUN echo "ks: $(ks version)"
179+ RUN echo "sonar-scanner: $(sonar-scanner --version)"
180+ RUN echo "dotnet: $(dotnet --version)"
181+ RUN echo "go: $(go version)"
182+ RUN echo "gradle: $(gradle --version)"
183+ RUN echo "mvn: $(mvn --version)"
184+ RUN echo "ant: $(ant -version)"
185+ RUN echo "nvm: $(nvm --version)"
186+ RUN echo "nvm current: $(nvm current)"
187+ RUN echo "npm: $(npm --version)"
188+ RUN echo "node: $(node --version)"
189+ RUN echo "yarn: $(yarn --version)"
190+ RUN echo "python: $(python --version)"
191+ RUN echo "pip: $(pip --version)"
192+ RUN echo "kustomize: $(kustomize version)"
193+
194+ # Clean up
195+ RUN apt-get clean && \
196+ rm -rf /var/lib/apt/lists/*
197+
95198# Set working directory
96199WORKDIR /home/jenkins
97200
0 commit comments