You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

226 lines
8.1 KiB

FROM ubuntu:22.04
# Switch to root and set environment
USER root
ENV DEBIAN_FRONTEND=noninteractive
# Install desktop environment, VNC server, and ALL dependencies upfront
RUN apt-get update && apt-get install -y \
xfce4 \
xfce4-goodies \
tightvncserver \
novnc \
websockify \
supervisor \
dbus-x11 \
xfonts-base \
xauth \
curl \
wget \
git \
unzip \
zip \
tar \
software-properties-common \
apt-transport-https \
ca-certificates \
gnupg \
lsb-release
# Set up VNC
RUN mkdir -p /root/.vnc
RUN echo 'mypassword' | vncpasswd -f > /root/.vnc/passwd
RUN chmod 600 /root/.vnc/passwd
# Create VNC startup script
RUN echo '#!/bin/bash\n\
export USER=root\n\
export HOME=/root\n\
vncserver -kill :1 > /dev/null 2>&1 || true\n\
vncserver :1 -geometry 1280x720 -depth 24\n\
websockify --web=/usr/share/novnc/ 6080 localhost:5901' > /root/start-vnc.sh \
&& chmod +x /root/start-vnc.sh
# Configure VNC startup
RUN echo '#!/bin/bash\n\
export USER=root\n\
export HOME=/root\n\
export XKL_XMODMAP_DISABLE=1\n\
startxfce4 &' > /root/.vnc/xstartup \
&& chmod +x /root/.vnc/xstartup
# Install development tools (Ubuntu 22.04 has modern packages!)
RUN apt-get install -y \
openjdk-11-jdk \
openjdk-17-jdk \
gcc \
g++ \
clang \
clang-format \
clang-tidy \
gdb \
valgrind \
cmake \
make \
ninja-build \
build-essential \
pkg-config \
libboost-all-dev \
libeigen3-dev \
libgtest-dev \
libgmock-dev \
python3 \
python3-pip \
python3-dev \
python3-numpy \
ant \
autotools-dev \
automake \
libtool \
openssh-server \
sudo \
supervisor
# Install VS Code
RUN wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg \
&& install -o root -g root -m 644 packages.microsoft.gpg /etc/apt/trusted.gpg.d/ \
&& sh -c 'echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/trusted.gpg.d/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list' \
&& apt-get update \
&& apt-get install -y code
# Create jenkins user
RUN useradd -m -d /home/jenkins -s /bin/bash jenkins \
&& echo "jenkins:jenkins" | chpasswd \
&& adduser jenkins sudo \
&& echo "jenkins ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
# Install Jenkins agent
RUN wget -O /opt/swarm-client.jar https://repo.jenkins-ci.org/public/org/jenkins-ci/plugins/swarm-client/3.25/swarm-client-3.25.jar
# Install Android Studio
RUN wget -q https://redirector.gvt1.com/edgedl/android/studio/ide-zips/2023.1.1.28/android-studio-2023.1.1.28-linux.tar.gz \
&& tar -xzf android-studio-*.tar.gz -C /opt/ \
&& rm android-studio-*.tar.gz
# Install Android SDK
RUN mkdir -p /opt/android-sdk/cmdline-tools \
&& wget -q https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip \
&& unzip commandlinetools-linux-*_latest.zip -d /opt/android-sdk/cmdline-tools/ \
&& mv /opt/android-sdk/cmdline-tools/cmdline-tools /opt/android-sdk/cmdline-tools/latest \
&& rm commandlinetools-linux-*_latest.zip
ENV ANDROID_HOME=/opt/android-sdk
ENV PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools
# Install Android packages
RUN yes | sdkmanager --licenses
RUN sdkmanager "platform-tools" "platforms;android-33" "build-tools;33.0.2" "emulator" "ndk;25.2.9519653" "cmake;3.22.1"
ENV ANDROID_NDK_HOME=$ANDROID_HOME/ndk/25.2.9519653
ENV PATH=$PATH:$ANDROID_NDK_HOME
# Install Flutter
RUN git clone https://github.com/flutter/flutter.git -b stable /opt/flutter
ENV PATH=$PATH:/opt/flutter/bin
# Install Node.js
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
&& apt-get install -y nodejs
# Install OpenCV for Android (lightweight download)
RUN mkdir -p /opt/opencv \
&& cd /opt/opencv \
&& wget -q https://github.com/opencv/opencv/releases/download/4.8.1/opencv-4.8.1-android-sdk.zip \
&& unzip opencv-4.8.1-android-sdk.zip \
&& rm opencv-4.8.1-android-sdk.zip \
&& mv OpenCV-android-sdk opencv-android
# Install OpenCV desktop version (optimized build - this is the long part)
RUN apt-get install -y \
libgtk-3-dev \
libavcodec-dev \
libavformat-dev \
libswscale-dev \
libv4l-dev \
libxvidcore-dev \
libx264-dev \
libjpeg-dev \
libpng-dev \
libtiff-dev \
gfortran \
libopenexr-dev \
libatlas-base-dev \
python3-dev \
python3-numpy \
libtbb2 \
libtbb-dev \
libdc1394-dev
RUN cd /opt/opencv \
&& wget -q https://github.com/opencv/opencv/archive/4.8.1.zip \
&& unzip 4.8.1.zip \
&& rm 4.8.1.zip \
&& cd opencv-4.8.1 \
&& mkdir build && cd build \
&& cmake -D CMAKE_BUILD_TYPE=Release \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D CMAKE_CXX_STANDARD=17 \
-D BUILD_EXAMPLES=OFF \
-D BUILD_TESTS=OFF \
-D BUILD_PERF_TESTS=OFF \
-D BUILD_opencv_apps=OFF \
-D BUILD_DOCS=OFF \
-D WITH_TBB=ON \
-D WITH_V4L=ON \
-D WITH_QT=OFF \
-D WITH_OPENGL=ON \
-D OPENCV_GENERATE_PKGCONFIG=ON .. \
&& make -j$(nproc) \
&& make install \
&& ldconfig
ENV OPENCV_ANDROID_SDK=/opt/opencv/opencv-android
# Install Python packages (ignore the warnings - they're not errors)
RUN pip3 install opencv-python opencv-contrib-python conan
# Install vcpkg (now with zip dependency fixed)
RUN git clone https://github.com/Microsoft/vcpkg.git /opt/vcpkg \
&& cd /opt/vcpkg \
&& ./bootstrap-vcpkg.sh
ENV PATH=$PATH:/opt/vcpkg
# Install Docker
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg \
&& echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null \
&& apt-get update \
&& apt-get install -y docker-ce docker-ce-cli containerd.io
RUN usermod -aG docker jenkins
# Set permissions
RUN chown -R jenkins:jenkins /opt/android-sdk \
&& chown -R jenkins:jenkins /opt/flutter \
&& chown -R jenkins:jenkins /opt/opencv
# Create desktop shortcuts
RUN mkdir -p /root/Desktop \
&& echo "[Desktop Entry]\nName=Android Studio\nExec=/opt/android-studio/bin/studio.sh\nIcon=/opt/android-studio/bin/studio.png\nType=Application\nTerminal=false" > /root/Desktop/android-studio.desktop \
&& chmod +x /root/Desktop/android-studio.desktop \
&& echo "[Desktop Entry]\nName=VS Code\nExec=code\nIcon=com.visualstudio.code\nType=Application\nTerminal=false" > /root/Desktop/vscode.desktop \
&& chmod +x /root/Desktop/vscode.desktop \
&& echo "[Desktop Entry]\nName=Terminal\nExec=xfce4-terminal\nIcon=utilities-terminal\nType=Application\nTerminal=false" > /root/Desktop/terminal.desktop \
&& chmod +x /root/Desktop/terminal.desktop
# Create workspace and samples
RUN mkdir -p /workspace/opencv-samples \
&& echo '#include <opencv2/opencv.hpp>\n#include <iostream>\n\nint main() {\n std::cout << "OpenCV Version: " << CV_VERSION << std::endl;\n cv::Mat img = cv::Mat::zeros(300, 300, CV_8UC3);\n cv::putText(img, "OpenCV Works!", cv::Point(30, 150), cv::FONT_HERSHEY_SIMPLEX, 1, cv::Scalar(0, 255, 0), 2);\n cv::imwrite("/workspace/test_output.jpg", img);\n std::cout << "Test image saved to /workspace/test_output.jpg" << std::endl;\n return 0;\n}' > /workspace/opencv-samples/test_opencv.cpp \
&& echo 'cmake_minimum_required(VERSION 3.16)\nproject(OpenCVTest)\nset(CMAKE_CXX_STANDARD 17)\nfind_package(OpenCV REQUIRED)\nadd_executable(test_opencv test_opencv.cpp)\ntarget_link_libraries(test_opencv ${OpenCV_LIBS})' > /workspace/opencv-samples/CMakeLists.txt
WORKDIR /workspace
# Expose VNC port
EXPOSE 6080
# Start VNC and desktop
CMD ["/root/start-vnc.sh"]