Skip to content

Commit 46f52ca

Browse files
committed
Add ubuntu2204.v1
1 parent d0d845e commit 46f52ca

File tree

5 files changed

+277
-3
lines changed

5 files changed

+277
-3
lines changed

README.md

Lines changed: 111 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,117 @@
22

33
This repository maintains the Dockerfile and scripts to build Apache CloudStack in docker images.
44

5-
## Ubuntu 22.04 (for Ubuntu distributions)
5+
## Compatibility matrix
66

7-
## Rocky Linux 8 (for Rocky Linux 8/9, AlmaLinux 8/9, Orache Linux 8/9, RHEL 8/9)
7+
| **Dockerfile** | **CloudStack versions** | **Note** |
8+
|---------------------|-------------------------------|----------------------|
9+
| ubuntu2204.v1 | 4.18.x, 4.19.x | For Ubuntu distros |
10+
| rocky8.v1 | 4.18.x, 4.19.x | For RHEL/Rocky Linux/AlmaLinux/OracleLinux distros |
811

9-
## CentOS 7
12+
## Usage
1013

14+
### (Optional) Build docker image
15+
16+
The pre-built image can be found at https://hub.docker.com/repository/docker/weizhouapache/cloudstack-builder
17+
18+
```
19+
cd ubuntu2204.v1
20+
docker build -f Dockerfile -t weizhouapache/cloudstack-builder:ubuntu2204.v1 .
21+
```
22+
23+
### 1. Build packages with configuration file
24+
25+
```
26+
./build.sh -c <configuration file name>
27+
```
28+
29+
Below are configurations in the configuration file.
30+
31+
| **Variablies** | **Description** | **Note** |
32+
|---------------------|-------------------------------|----------------------|
33+
| `SOURCE` | The directory where the source code is, or the URL of the git repository. | Mounted to /source/ if it is a directory. |
34+
| `OUTPUT` | The directory where the packages will be in. | Mounted to /output/ in the docker container. |
35+
| `SUDO` | Please set to `sudo` if you use a non-root user | Default: None. |
36+
| `VERSION` | The CloudStack version, branch name or commit SHA | Default: None. |
37+
| `BUILD_OPTS` | The build options. Refer to `Build Options` | Default: None. |
38+
39+
A sample of environment variables can be found at `config.ubuntu.sample`.
40+
41+
### 2. Build packages with parameters
42+
43+
```
44+
Usage: ./build.sh
45+
-r <the repository of the image. Default is weizhouapache/cloudstack-builder>
46+
-i <the name of the image>
47+
-s <the source directory or git repository>
48+
-o <the output directory>
49+
-v <the CloudStack version, branch name or commit SHA>
50+
-b <the build options>
51+
-u # use sudo
52+
-c <the name of config file which includes all settings above>
53+
-d # dry-run
54+
-h # help message
55+
```
56+
57+
Examples
58+
```
59+
# Build from a local directory
60+
./build.sh -i ubuntu2204.v1 -s /data/cloudstack -o /tmp -b "-Dnoredist -DskipTests -Dsystemvm-kvm -Dsystemvm-xen -Dsystemvm-vmware"
61+
62+
# Build from git repository
63+
./build.sh -i ubuntu2204.v1 -s https://github.com/apache/cloudstack.git -o /tmp -v main -b "-Dnoredist -DskipTests -Dsystemvm-kvm -Dsystemvm-xen -Dsystemvm-vmware" -u
64+
```
65+
66+
### 3. Build packages by `docker` command
67+
68+
An example how to build packages from local directory
69+
```
70+
SUDO=
71+
SOURCE=./
72+
OUTPUT=/tmp/
73+
CONTAINER_NAME="cloudstack-builder-$(echo $RANDOM | tr '[0-9]' '[a-z]')"
74+
75+
$SUDO mkdir -p ~/.m2/
76+
$SUDO mkdir -p ${OUTPUT}
77+
$SUDO docker run -ti \
78+
-n $CONTAINER_NAME \
79+
-v ~/.m2:/root/.m2/ \
80+
-v ${SOURCE}:/source/ \
81+
-v ${OUTPUT}:/output/ \
82+
--env BUILD_OPTS="-Dnoredist -DskipTests -Dsystemvm-kvm -Dsystemvm-xen -Dsystemvm-vmware" \
83+
weizhouapache/cloudstack-builder:ubuntu2204.v1
84+
```
85+
86+
An example how to build packages from git repository
87+
88+
```
89+
SUDO=
90+
SOURCE=https://github.com/apache/cloudstack.git
91+
VERSION=4.19.0.0
92+
OUTPUT=/tmp/
93+
BUILD_OPTS="-Dnoredist -DskipTests -Dsystemvm-kvm -Dsystemvm-xen -Dsystemvm-vmware"
94+
CONTAINER_NAME="cloudstack-builder-$(echo $RANDOM | tr '[0-9]' '[a-z]')"
95+
96+
$SUDO mkdir -p ~/.m2/
97+
$SUDO mkdir -p ${OUTPUT}
98+
$SUDO docker run -ti \
99+
-n $CONTAINER_NAME \
100+
-v ~/.m2:/root/.m2/ \
101+
-v ${OUTPUT}:/output/ \
102+
-e SOURCE \
103+
-e OUTPUT \
104+
-e BUILD_OPTS \
105+
weizhouapache/cloudstack-builder:ubuntu2204.v1
106+
```
107+
## Build Options
108+
109+
| **OS** | **Option** | **Note** |
110+
|-------------|--------------------|----------------------|
111+
| Ubuntu | -Dnoredist | Support non-Open Source Software (e.g. VMware) |
112+
| | -DskipTests | Skip unit tests |
113+
| | -Dsystemvm-kvm | Bundle with SystemVM template for KVM |
114+
| | -Dsystemvm-vmware | Bundle with SystemVM template for VMware |
115+
| | -Dsystemvm-xen | Bundle with SystemVM template for XenServer/XCP-ng |
116+
117+
118+
The default value for ubuntu images is `-Dnoredist -DskipTests -Dsystemvm-kvm -Dsystemvm-xen -Dsystemvm-vmware`

build.sh

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#!/bin/bash
2+
3+
usage() {
4+
printf "Usage: $0
5+
-r <the repository of the image. Default is weizhouapache/cloudstack-builder>
6+
-i <the name of the image>
7+
-s <the source directory or git repository>
8+
-o <the output directory>
9+
-v <the CloudStack version, branch name or commit SHA>
10+
-b <the build options>
11+
-u # use sudo
12+
-c <the name of config file which includes all settings above>
13+
-d # dry-run
14+
-h # help message\n"
15+
exit 1
16+
}
17+
18+
REPO="weizhouapache/cloudstack-builder"
19+
SUDO=
20+
21+
while getopts r:i:s:o:v:b:uc:dh OPT
22+
do
23+
case "$OPT" in
24+
r) REPO="$OPTARG";;
25+
i) IMAGE="$OPTARG";;
26+
s) SOURCE="$OPTARG";;
27+
o) OUTPUT="$OPTARG";;
28+
v) VERSION="$OPTARG";;
29+
b) BUILD_OPTS="$OPTARG";;
30+
u) SUDO="sudo";;
31+
c) CONFIG="$OPTARG";;
32+
d) DRY_RUN="yes";;
33+
h) usage
34+
exit 0;;
35+
*) # UNKNOWN
36+
usage
37+
exit 1;;
38+
esac
39+
done
40+
41+
if [ ! -z $CONFIG ]; then
42+
source $CONFIG
43+
fi
44+
45+
if [ -z $SOURCE ] || [ -z $IMAGE ] || [ -z $OUTPUT ]; then
46+
echo "The image name, source and output directory are required"
47+
usage
48+
fi
49+
50+
FULL_IMAGE=$REPO:$IMAGE
51+
echo "Using image: $FULL_IMAGE"
52+
echo "Using source: $SOURCE"
53+
echo "Using output: $OUTPUT"
54+
echo "Using version: $VERSION"
55+
echo "Using build options: \"$BUILD_OPTS\""
56+
echo "Using sudo: $SUDO"
57+
echo ""
58+
59+
CONTAINER_NAME="cloudstack-builder-$(echo $RANDOM | tr '[0-9]' '[a-z]')"
60+
COMMAND="$SUDO docker run -ti --name $CONTAINER_NAME"
61+
62+
# Using local maven cache
63+
MAVEN_CACHE=$($SUDO readlink -f ~/.m2/)
64+
$SUDO mkdir -p $MAVEN_CACHE
65+
COMMAND="$COMMAND -v $MAVEN_CACHE:/root/.m2/"
66+
67+
if [ -d $SOURCE ]; then
68+
COMMAND="$COMMAND -v ${SOURCE}:/source/"
69+
else
70+
COMMAND="$COMMAND --env SOURCE=${SOURCE}"
71+
fi
72+
if [ ! -z $OUTPUT ]; then
73+
$SUDO mkdir -p ${OUTPUT}
74+
COMMAND="$COMMAND -v ${OUTPUT}:/output/"
75+
fi
76+
if [ ! -z $VERSION ]; then
77+
COMMAND="$COMMAND --env VERSION=${VERSION}"
78+
fi
79+
if [ ! -z "$BUILD_OPTS" ]; then
80+
export BUILD_OPTS=$BUILD_OPTS
81+
COMMAND="$COMMAND --env BUILD_OPTS"
82+
fi
83+
COMMAND="$COMMAND $FULL_IMAGE"
84+
85+
if [ "$DRY_RUN" = "yes" ];then
86+
echo "COMMAND is: ${COMMAND}"
87+
else
88+
echo "Running command: ${COMMAND}"
89+
${COMMAND}
90+
$SUDO docker rm $CONTAINER_NAME
91+
fi

config.ubuntu.sample

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
# The repository of the image. Default is weizhouapache/cloudstack-builder
3+
REPO=weizhouapache/cloudstack-builder
4+
5+
# The name of the image
6+
IMAGE=ubuntu2204.v1
7+
8+
# The source directory or git repository
9+
# This will be mounted or cloned to /source the docker container.
10+
SOURCE=https://github.com/apache/cloudstack.git
11+
12+
# The directory where the packages will be.
13+
# This will be mounted to /output the docker container.
14+
OUTPUT=/tmp
15+
16+
# The CloudStack version, branch name or commit SHA.
17+
VERSION=4.19.0.0
18+
19+
# The build options.
20+
# The default value for ubuntu is "-Dnoredist -DskipTests -Dsystemvm-kvm -Dsystemvm-xen -Dsystemvm-vmware"
21+
# Please refer to https://github.com/weizhouapache/docker-cloudstack-builder/blob/main/README.md
22+
BUILD_OPTS=
23+
24+
# Please set to sudo if use a non-root user
25+
SUDO=

ubuntu2204.v1/Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM ubuntu:22.04
2+
MAINTAINER Wei Zhou <weizhou@apache.org>
3+
4+
ENV DEBIAN_FRONTEND noninteractive
5+
6+
RUN apt update -qq && \
7+
apt upgrade -y && \
8+
apt-get install -y dpkg-dev python2 python3 debhelper openjdk-11-jdk genisoimage python3-mysql.connector maven lsb-release devscripts python-setuptools python3-setuptools git wget curl
9+
10+
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - \
11+
&& apt-get install -y nodejs
12+
13+
COPY entrypoint.sh /entrypoint.sh
14+
15+
ENTRYPOINT ["/entrypoint.sh"]

ubuntu2204.v1/entrypoint.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash -x
2+
3+
SOURCE_DIR=/source/
4+
OUTPUT_DIR=/output/
5+
BUILD_OPTS_DEFAULT="-Dnoredist -DskipTests -Dsystemvm-kvm -Dsystemvm-xen -Dsystemvm-vmware"
6+
7+
SOURCE=${SOURCE:-}
8+
VERSION=${VERSION:-}
9+
BUILD_OPTS=${BUILD_OPTS:-$BUILD_OPTS_DEFAULT}
10+
11+
if [[ $SOURCE =~ http.* ]] || [[ $SOURCE =~ git.* ]]; then
12+
if [ -d "$SOURCE_DIR" ]; then
13+
echo "$SOURCE_DIR already exists in the container"
14+
exit 1
15+
fi
16+
git clone $SOURCE $SOURCE_DIR
17+
elif [ -z "$SOURCE_DIR" ] || [ ! -d "$SOURCE_DIR" ] || [ ! -f "$SOURCE_DIR/pom.xml" ]; then
18+
echo "Source $SOURCE_DIR does not exist in the container"
19+
exit 1
20+
fi
21+
if [ ! -d "$OUTPUT_DIR" ]; then
22+
echo "$OUTPUT_DIR does not exist in the container"
23+
exit 1
24+
fi
25+
26+
cd $SOURCE_DIR
27+
if [ ! -z "$VERSION" ]; then
28+
git checkout $VERSION
29+
fi
30+
31+
ACS_BUILD_OPTS=$BUILD_OPTS packaging/build-deb.sh
32+
mv $SOURCE_DIR/../cloudstack*.deb $OUTPUT_DIR
33+
if [[ $SOURCE =~ http.* ]] || [[ $SOURCE =~ git.* ]]; then
34+
rm -rf $SOURCE_DIR
35+
fi

0 commit comments

Comments
 (0)