Skip to content

Commit e4bc95d

Browse files
committed
chore: address comments
1 parent 4399b9d commit e4bc95d

File tree

3 files changed

+70
-114
lines changed

3 files changed

+70
-114
lines changed

ci/Jenkinsfile.android

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pipeline {
1010
/* Image with Ubuntu 22.04, QT 6.9.0, Android SDK/NDK, Go, and Nim */
1111
docker {
1212
label 'linux'
13-
image 'statusteam/nim-status-client-build:1.0.2-qt6.9.0-android'
13+
image 'statusteam/nim-status-client-build:1.0.3-qt6.9.0-android'
1414
alwaysPull true
1515
}
1616
}
@@ -42,9 +42,9 @@ pipeline {
4242

4343
environment {
4444
USE_SYSTEM_NIM = "1"
45-
GOCACHE = "/tmp/go-cache"
46-
GOMODCACHE = "/tmp/go-mod-cache"
47-
GOTMPDIR = "/tmp"
45+
GOCACHE = "${env.WORKSPACE_TMP}/go-cache"
46+
GOMODCACHE = "${env.WORKSPACE_TMP}/go-mod-cache"
47+
GOTMPDIR = "${env.WORKSPACE_TMP}"
4848
STATUS_APK_ARTIFACT = "pkg/Status-tablet-${BUILD_NUMBER}.apk"
4949
PLATFORM = "android/arm64"
5050
QT_ANDROID_PATH = "/opt/qt/6.9.0/android_arm64_v8a"

ci/Jenkinsfile.qt-build

Lines changed: 20 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,14 @@ pipeline {
2020
)
2121
string(
2222
name: 'DOCKER_TAG',
23-
defaultValue: '1.0.2-qt6.9.0-android',
23+
defaultValue: '1.0.3-qt6.9.0-android',
2424
description: 'Docker image tag for the final image'
2525
)
2626
booleanParam(
2727
name: 'PUSH_TO_DOCKERHUB',
2828
defaultValue: true,
2929
description: 'Push the final image to DockerHub'
3030
)
31-
booleanParam(
32-
name: 'BUILD_QT_FROM_SOURCE',
33-
defaultValue: true,
34-
description: 'Build Qt from source (takes several hours)'
35-
)
3631
}
3732

3833
environment {
@@ -42,68 +37,27 @@ pipeline {
4237
}
4338

4439
stages {
45-
46-
stage('Build Qt from Source') {
47-
when {
48-
expression { params.BUILD_QT_FROM_SOURCE == true }
49-
}
50-
steps {
51-
script {
52-
// Build qt-dev-base stage for Qt source compilation
53-
dir("${MOBILE_BUILD_DIR}") {
54-
def qtDevImage = "${DOCKER_REGISTRY}/qt-dev-base-temp:${BUILD_ID}"
55-
sh """
56-
docker build \
57-
--target qt-dev-base \
58-
--build-arg TARGETARCH=amd64 \
59-
--build-arg JAVA_VERSION=17 \
60-
--build-arg ANDROID_API_LEVEL=35 \
61-
--build-arg ANDROID_NDK_VERSION=27.2.12479018 \
62-
-t ${qtDevImage} .
63-
"""
64-
65-
// Run Qt build in the container
66-
docker.image(qtDevImage).inside("-u root -v ${WORKSPACE}/qt_export:/root/export -v ${WORKSPACE}/scripts:/root/scripts") {
67-
dir('/root') {
68-
sh "/root/scripts/build_qt_android.sh"
69-
}
70-
}
71-
72-
// Clean up temp image
73-
sh "docker rmi ${qtDevImage} || true"
74-
}
75-
}
76-
}
77-
}
78-
7940
stage('Build Docker Images') {
8041
steps {
8142
script {
8243
dir("${MOBILE_BUILD_DIR}") {
83-
// Copy Qt exports if they exist
84-
sh """
85-
if [ -d ${WORKSPACE}/qt_export ]; then
86-
cp -r ${WORKSPACE}/qt_export .
87-
fi
88-
"""
8944

90-
// Build final mobile-build stage
91-
sh """
92-
docker build \
93-
--build-arg QTVER=${params.QT_VERSION} \
94-
--build-arg TARGETARCH=amd64 \
95-
--build-arg JAVA_VERSION=17 \
96-
--build-arg ANDROID_API_LEVEL=35 \
97-
--build-arg ANDROID_NDK_VERSION=27.2.12479018 \
98-
--build-arg GOLANG_VERSION=1.23.10 \
99-
--build-arg NIM_VERSION=2.0.12 \
100-
--build-arg NIX_VERSION=2.24.11 \
101-
--target mobile-build \
102-
-t ${DOCKER_REGISTRY}/${DOCKER_IMAGE_BASE}:${params.DOCKER_TAG} .
103-
"""
45+
def image = docker.build(
46+
"${DOCKER_REGISTRY}/${DOCKER_IMAGE_BASE}:${params.DOCKER_TAG}",
47+
"--build-arg QTVER=${params.QT_VERSION} " +
48+
"--build-arg TARGETARCH=amd64 " +
49+
"--build-arg JAVA_VERSION=17 " +
50+
"--build-arg ANDROID_API_LEVEL=35 " +
51+
"--build-arg ANDROID_NDK_VERSION=27.2.12479018 " +
52+
"--build-arg GOLANG_VERSION=1.23.10 " +
53+
"--build-arg NIM_VERSION=2.0.12 " +
54+
"--build-arg NIX_VERSION=2.24.11 " +
55+
"--target mobile-build ."
56+
)
57+
10458

105-
// Clean up qt_export copy
106-
sh "rm -rf qt_export || true"
59+
// Store image reference for later stages
60+
env.BUILT_IMAGE = "${DOCKER_REGISTRY}/${DOCKER_IMAGE_BASE}:${params.DOCKER_TAG}"
10761
}
10862
}
10963
}
@@ -116,12 +70,12 @@ pipeline {
11670
script {
11771
def testImage = "${DOCKER_REGISTRY}/${DOCKER_IMAGE_BASE}:${params.DOCKER_TAG}"
11872
docker.image(testImage).inside('--entrypoint=""') {
119-
sh "qmake --version || echo 'qmake not found'"
73+
sh "qmake --version"
12074
sh "nim --version"
12175
sh "go version"
12276
sh "protoc --version"
12377
sh "java -version"
124-
sh "ls -la /opt/qt/${params.QT_VERSION}/ || echo 'Qt directory not found'"
78+
sh "ls -la /opt/qt/${params.QT_VERSION}/"
12579
}
12680
}
12781
}
@@ -136,18 +90,8 @@ pipeline {
13690
}
13791
steps {
13892
script {
139-
withCredentials([
140-
usernamePassword(
141-
credentialsId: 'dockerhub-statusteam-bot',
142-
usernameVariable: 'DOCKER_USER',
143-
passwordVariable: 'DOCKER_PASS'
144-
)
145-
]) {
146-
sh """
147-
docker push ${DOCKER_REGISTRY}/${DOCKER_IMAGE_BASE}:${params.DOCKER_TAG}
148-
docker logout
149-
"""
150-
}
93+
def image = docker.image(env.BUILT_IMAGE)
94+
image.push()
15195
}
15296
}
15397
}

mobile/docker/Dockerfile

Lines changed: 46 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -111,29 +111,61 @@ RUN \
111111
&& rm -rf /var/lib/apt/lists/*
112112

113113
# =============================================================================
114-
# Stage 3: Qt Installation - extends qt-dev-base
114+
# Stage 3: Qt Builder - builds Qt from source
115+
# =============================================================================
116+
FROM qt-dev-base AS qt-builder
117+
118+
ARG QTVER
119+
120+
COPY ../../scripts/build_qt_*.sh /root/scripts/
121+
122+
# Build Qt from source
123+
RUN \
124+
echo "Building Qt from source..." && \
125+
mkdir -p /root/export && \
126+
cd /root && \
127+
/root/scripts/build_qt_android.sh && \
128+
if [ -f "/root/scripts/build_qt_desktop.sh" ]; then \
129+
/root/scripts/build_qt_desktop.sh; \
130+
fi
131+
132+
# =============================================================================
133+
# Stage 4: Qt Export - creates Qt tar.xz files from built Qt
134+
# =============================================================================
135+
FROM scratch AS qt-export
136+
137+
# Copy Qt exports from builder stage
138+
COPY --from=qt-builder /root/export/ /qt_export/
139+
140+
# =============================================================================
141+
# Stage 5: Qt Installation - installs Qt from exports
115142
# inspired by https://github.com/carlonluca/docker-qt/blob/master/Dockerfile_6.9.0
116143
# =============================================================================
117144
FROM qt-dev-base AS qt-installation
118145

119146
ARG QTVER
120147

121-
COPY qt_export/Qt-android-$QTVER.tar.xz /root/
122-
COPY qt_export/Qt-amd64-$QTVER.tar.xz* /root/
148+
# Get Qt exports from the qt-export stage
149+
COPY --from=qt-export /qt_export/ /root/qt_export/
123150

124-
# Extract Qt Android
151+
# Extract Qt if the tar.xz files exist
125152
RUN \
126153
mkdir -p /opt/qt/$QTVER && \
127-
cd /opt/qt/$QTVER && \
128-
tar xvfp /root/Qt-android-$QTVER.tar.xz && \
129-
rm /root/Qt-android-$QTVER.tar.xz
130-
131-
RUN \
132-
if [ -f /root/Qt-amd64-$QTVER.tar.xz ]; then \
154+
if [ -f "/root/qt_export/Qt-android-$QTVER.tar.xz" ]; then \
155+
echo "Installing Qt Android from export..."; \
133156
cd /opt/qt/$QTVER && \
134-
tar xvfp /root/Qt-amd64-$QTVER.tar.xz && \
135-
rm /root/Qt-amd64-$QTVER.tar.xz; \
136-
fi
157+
tar xvfp /root/qt_export/Qt-android-$QTVER.tar.xz; \
158+
else \
159+
echo "No Qt Android export found, skipping..."; \
160+
fi && \
161+
if [ -f "/root/qt_export/Qt-amd64-$QTVER.tar.xz" ]; then \
162+
echo "Installing Qt desktop from export..."; \
163+
cd /opt/qt/$QTVER && \
164+
tar xvfp /root/qt_export/Qt-amd64-$QTVER.tar.xz; \
165+
else \
166+
echo "No Qt desktop export found, skipping..."; \
167+
fi && \
168+
rm -rf /root/qt_export
137169

138170
RUN \
139171
apt-get -y autoremove \
@@ -219,7 +251,7 @@ RUN GOLANG_SHA256="535f9f81802499f2a7dbfa70abb8fda3793725fcc29460f719815f6e10b5f
219251
# Install Go tools as root first, then copy to accessible location
220252
RUN /usr/local/go/bin/go install github.com/go-bindata/go-bindata/v3/go-bindata@latest \
221253
&& /usr/local/go/bin/go install go.uber.org/mock/[email protected] \
222-
&& /usr/local/go/bin/go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28.1 \
254+
&& /usr/local/go/bin/go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.34.1 \
223255
&& cp /root/go/bin/* /usr/local/bin/ 2>/dev/null || true
224256

225257
# Configure Qt library path
@@ -362,26 +394,6 @@ RUN apt update -yq && apt install -yq software-properties-common \
362394
--slave /usr/bin/g++ g++ /usr/bin/g++-9 \
363395
&& apt-get -qq clean
364396

365-
# Install Protoc (only if not already present from previous stages)
366-
RUN if ! command -v protoc &> /dev/null; then \
367-
PROTOC_SHA256="75d8a9d7a2c42566e46411750d589c51276242d8b6247a5724bac0f9283e05a8" \
368-
&& PROTOC_TARBALL="protoc-3.20.0-linux-x86_64.zip" \
369-
&& wget -q -L "https://github.com/protocolbuffers/protobuf/releases/download/v3.20.0/${PROTOC_TARBALL}" \
370-
&& echo "${PROTOC_SHA256} ${PROTOC_TARBALL}" | sha256sum -c \
371-
&& sudo unzip -d /usr/local "${PROTOC_TARBALL}" \
372-
&& rm "${PROTOC_TARBALL}"; \
373-
fi
374-
375-
# Install Protoc-gen-go (only if not already present)
376-
RUN if ! command -v protoc-gen-go &> /dev/null; then \
377-
PROTOC_GEN_SHA256="0b2c257938a8cd9ba3506bbdbbaad45e51245b6f9e0743035ade7acf746c6be7" \
378-
&& PROTOC_GEN_TARBALL="protoc-gen-go.v1.34.1.linux.amd64.tar.gz" \
379-
&& wget -q -L "https://github.com/protocolbuffers/protobuf-go/releases/download/v1.34.1/${PROTOC_GEN_TARBALL}" \
380-
&& echo "${PROTOC_GEN_SHA256} ${PROTOC_GEN_TARBALL}" | sha256sum -c \
381-
&& sudo tar -C /usr/local/bin -xzf "${PROTOC_GEN_TARBALL}" \
382-
&& rm "${PROTOC_GEN_TARBALL}"; \
383-
fi
384-
385397
ENV PATH="/root/go/bin:${PATH}"
386398

387399
LABEL description="Build image for the Status-tablet Android APK."

0 commit comments

Comments
 (0)