Skip to content

Commit 2bff1a1

Browse files
Merge pull request #88 from stoneshi-yunify/master
refactor base image
2 parents fb3dc58 + 1ba38de commit 2bff1a1

29 files changed

+167
-1246
lines changed

Makefile

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,5 @@
11
COMMIT := $(shell git rev-parse --short HEAD)
22
VERSION := dev-$(shell git describe --tags $(shell git rev-list --tags --max-count=1))
33

4-
build-base-podman:
5-
docker build base -f base/podman/Dockerfile -t kubespheredev/builder-base:$(VERSION)-podman
6-
push-base-podman:
7-
docker push kubespheredev/builder-base:$(VERSION)-podman
8-
9-
build-maven-podman:
10-
docker build maven -f maven/podman/Dockerfile -t kubespheredev/builder-maven:$(VERSION)-podman
11-
push-maven-podman:
12-
docker push kubespheredev/builder-maven:$(VERSION)-podman
13-
14-
build-maven-jdk11:
15-
docker build maven -f maven/Dockerfile -t kubespheredev/builder-maven:$(VERSION)-jdk11 \
16-
--build-arg JDK_VERSION=11
17-
push-maven-jdk11:
18-
docker push kubespheredev/builder-maven:$(VERSION)-jdk11
19-
20-
build-maven-jdk17:
21-
docker build maven -f maven/Dockerfile -t kubespheredev/builder-maven:$(VERSION)-jdk17 \
22-
--build-arg JDK_VERSION=17 --build-arg JDK_HOME=/usr/java/default
23-
push-maven-jdk17:
24-
docker push kubespheredev/builder-maven:$(VERSION)-jdk17
25-
26-
build-maven-jdk17-podman:
27-
docker build maven -f maven/podman/Dockerfile -t kubespheredev/builder-maven:$(VERSION)-jdk17-podman \
28-
--build-arg JDK_VERSION=17 --build-arg JDK_HOME=/usr/java/default
29-
push-maven-jdk17-podman:
30-
docker push kubespheredev/builder-maven:$(VERSION)-jdk17-podman
4+
build-base:
5+
docker buildx build base -f base/Dockerfile -t kubesphere/builder-base:$(VERSION)

OWNERS

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,17 @@
11
approvers:
2-
- zryfish
3-
- rayzhou2017
4-
- shaowenchen
5-
- linuxsuren
2+
- stoneshi-yunify
3+
- renyunkang
64
- chilianyi
7-
- yudong2015
85

96
reviewers:
107
- rayzhou2017
11-
- zryfish
12-
- shaowenchen
138
- benjaminhuo
149
- calvinyv
15-
- FeynmanZhou
16-
- huanggze
17-
- huojiao2006
18-
- Ma-Dan
19-
- magicsong
2010
- pixiake
21-
- runzexia
2211
- wansir
23-
- wnxn
2412
- zheng1
25-
- soulseen
26-
- linuxsuren
27-
- JohnNiang
13+
- stoneshi-yunify
14+
- renyunkang
2815
- chilianyi
29-
- yudong2015
16+
17+

README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,19 @@ This repo stores the build files of image for these podTemplate.
1919
Welcome to contribute.
2020

2121
## Images
22+
Images for both production and development:
23+
24+
| Name | Introduction | Docker Pulls |
25+
|---------------------------|--------------------------|---------------------------------------------------------------------------------------------------------------------------------------|
26+
| `kubesphere/builder-base` | [README](base/README.md) | [![Docker Pulls](https://img.shields.io/docker/pulls/kubesphere/builder-go.svg)](https://hub.docker.com/r/kubesphere/builder-go/tags) |
27+
28+
## Legacy Images
29+
Legacy images built on centos:7 are no longer developed but may be still working.
2230

2331
For production:
2432

2533
| Name | Docker Pulls |
2634
|---|---|
27-
| `kubesphere/builder-base` | [![Docker Pulls](https://img.shields.io/docker/pulls/kubesphere/builder-base.svg)](https://hub.docker.com/r/kubesphere/builder-base/tags) |
2835
| `kubesphere/builder-go` | [![Docker Pulls](https://img.shields.io/docker/pulls/kubesphere/builder-go.svg)](https://hub.docker.com/r/kubesphere/builder-go/tags) |
2936
| `kubesphere/builder-maven` | [![Docker Pulls](https://img.shields.io/docker/pulls/kubesphere/builder-maven.svg)](https://hub.docker.com/r/kubesphere/builder-maven/tags) |
3037
| `kubesphere/builder-gradle` | [![Docker Pulls](https://img.shields.io/docker/pulls/kubesphere/builder-gradle.svg)](https://hub.docker.com/r/kubesphere/builder-gradle/tags) |
@@ -36,7 +43,6 @@ For development:
3643

3744
| Name | Docker Pulls |
3845
|---|---|
39-
| `kubespheredev/builder-base` | [![Docker Pulls](https://img.shields.io/docker/pulls/kubespheredev/builder-base.svg)](https://hub.docker.com/r/kubespheredev/builder-base/tags) |
4046
| `kubespheredev/builder-go` | [![Docker Pulls](https://img.shields.io/docker/pulls/kubespheredev/builder-go.svg)](https://hub.docker.com/r/kubespheredev/builder-go/tags) |
4147
| `kubespheredev/builder-maven` | [![Docker Pulls](https://img.shields.io/docker/pulls/kubespheredev/builder-maven.svg)](https://hub.docker.com/r/kubespheredev/builder-maven/tags) |
4248
| `kubespheredev/builder-gradle` | [![Docker Pulls](https://img.shields.io/docker/pulls/kubespheredev/builder-gradle.svg)](https://hub.docker.com/r/kubespheredev/builder-gradle/tags) |
@@ -45,15 +51,14 @@ For development:
4551
| `kubespheredev/builder-python` | [![Docker Pulls](https://img.shields.io/docker/pulls/kubespheredev/builder-python.svg)](https://hub.docker.com/r/kubespheredev/builder-python/tags) |
4652

4753
## How to Build
54+
Check out the Makefile.
4855

49-
Enter the directory and execute:
56+
For example, build the base image:
5057

5158
```bash
52-
docker build -f Dockerfile .
59+
make build-base
5360
```
5461

55-
It's a better way to provide jenkinsfile for compiling images, like base agent.
56-
5762
## Join & Contact Community
5863

5964
- Slack [#sig-devops](https://kubesphere.slack.com/messages/sig-devops)

base/Dockerfile

Lines changed: 129 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
11
FROM 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
1020
RUN 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
4262
RUN 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
7292
RUN 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)
86106
RUN 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
90167
RUN mkdir -p /etc/containers
91168
COPY *.conf /etc/containers/
92-
93169
VOLUME /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
96199
WORKDIR /home/jenkins
97200

base/README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,20 @@
1-
Base image with docker and podman
1+
Base image with latest common sdks and utilities built with ubuntu, include:
2+
- docker cli
3+
- podman
4+
- kubectl
5+
- kustomize
6+
- helm
7+
- jdk
8+
- gradle
9+
- sonar-scanner
10+
- python
11+
- maven
12+
- ant
13+
- dotnet
14+
- go
15+
- nodejs
16+
- yarn
17+
- npm
18+
- ks
19+
- ...
220

dotnet/Dockerfile

Lines changed: 0 additions & 15 deletions
This file was deleted.

dotnet/Jenkinsfile

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)