Skip to content

Commit

Permalink
Add Dockerfiles for build images of CDT project
Browse files Browse the repository at this point in the history
This is the state of the files as of cdt-infra
commit 497e7b2a643ff6ea12a56a21c17dd2d170e918c8 with
the Readme updated for the new locations
  • Loading branch information
jonahgraham committed Apr 26, 2024
1 parent 88355ec commit 9fb6260
Show file tree
Hide file tree
Showing 19 changed files with 971 additions and 0 deletions.
1 change: 1 addition & 0 deletions docker/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build-images.sh
33 changes: 33 additions & 0 deletions docker/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Dockerfiles
============

The docker images for Eclipse CDT's [Jenkins instance](https://ci.eclipse.org/cdt/) are stored at [quay.io](https://quay.io/organization/eclipse-cdt)
and built using the following scripts. The individual directories below this one contain Dockerfiles which contain a little more information. Note that
the split between the Dockerfiles is somewhat arbitrary and historical. Only the cdt-infra-eclipse-full image is known to be referenced outside
of the cdt repo.

build-images.sh
===============

Builds the images locally. A download of [Xcode_9.4.1.xip](https://download.developer.apple.com/Developer_Tools/Xcode_9.4.1/Xcode_9.4.1.xip) (visit [here](https://developer.apple.com/download/more/) first to logon to Apple if needed) is needed to do a complete build. To save on rebuild times, the xip can be removed from the directory to use the cached cdt-infra-build-macos-sdk image.

deploy-images.sh
================

Builds images (from cache), uploads them to quay.io/eclipse-cdt namespace and then
updates all the Jenkinsfile and yaml files to refer to these new images.

Using the docker images
=======================

The docker images exist mostly for use in Jenkins, see the [pod templates](https://github.com/eclipse-cdt/cdt/blob/main/jenkins/pod-templates).

They can be used to recreate a consistent environment in other cases too. For example, you can run a full build on a machine that does not already have the tools by using docker:

```
docker run --rm -it -v $(git rev-parse --show-toplevel):/work -w /work/$(git rev-parse --show-prefix) --cap-add=SYS_PTRACE --security-opt seccomp=unconfined quay.io/eclipse-cdt/cdt-infra-eclipse-full:latest COMMAND HERE
```

For examples of the above in practice, see [cdt-gdb-adapter's integration tests readme](https://github.com/eclipse-cdt/cdt-gdb-adapter/blob/master/src/integration-tests/README.md) and the native section of [CDT's readme](https://github.com/eclipse-cdt/cdt/blob/main/BUILDING.md#native)


16 changes: 16 additions & 0 deletions docker/build-images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

set -eux

# Xcode_13.1.xip is needed to build the OSx cross compiler image from https://developer.apple.com/download/all/?q=xcode
# As an optimization for the rebuild times, the image is only built if the xip is present.
if [ -f Xcode_13.1.xip ]; then
docker build --rm --build-arg Xcodexip=Xcode_13.1.xip -f cdt-infra-build-macos-sdk/ubuntu-18.04/Dockerfile -t cdt-infra-build-macos-sdk:ubuntu-18.04 .
else
echo "MacOSX SDK & Toolchain build is being skipped"
fi

docker build --rm -f cdt-infra-base/ubuntu-18.04/Dockerfile -t cdt-infra-base:ubuntu-18.04 .
docker build --rm -f cdt-infra-all-gdbs/ubuntu-18.04/Dockerfile -t cdt-infra-all-gdbs:ubuntu-18.04 .
docker build --rm -f cdt-infra-eclipse-full/ubuntu-18.04/Dockerfile -t cdt-infra-eclipse-full:ubuntu-18.04 .
docker build --rm -f cdt-infra-plus-eclipse-install/ubuntu-18.04/Dockerfile -t cdt-infra-plus-eclipse-install:ubuntu-18.04 .
26 changes: 26 additions & 0 deletions docker/cdt-infra-all-gdbs/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Building GDBs in a separate image
=================================

The GDBs take a long time to build and it is very inconvenient to have to build them
because something else in a Docker file has changed. Therefore, this image *only*
builds the GDBs using the download-build-gdb.sh script.

Other images can then use these prebuilt GDBs by copying them to their image.

For example, to copy all the GDBs use this line:

```
COPY --from=cdt-infra-all-gdbs:ubuntu-18.04 /shared/common/gdb/gdb-all /shared/common/gdb/gdb-all
```

Or, to copy a specific version only, do this:

```
# Copy install directory
COPY --from=cdt-infra-all-gdbs:ubuntu-18.04 /shared/common/gdb/gdb-all/install/gdb-8.2.1 /shared/common/gdb/gdb-all/install/gdb-8.2.1
# Copy versioned links
COPY --from=cdt-infra-all-gdbs:ubuntu-18.04 /shared/common/gdb/gdb-all/bin/gdb.8.2 /shared/common/gdb/gdb-all/bin/gdb.8.2
COPY --from=cdt-infra-all-gdbs:ubuntu-18.04 /shared/common/gdb/gdb-all/bin/gdb.8.2.1 /shared/common/gdb/gdb-all/bin/gdb.8.2.1
COPY --from=cdt-infra-all-gdbs:ubuntu-18.04 /shared/common/gdb/gdb-all/bin/gdbserver.8.2 /shared/common/gdb/gdb-all/bin/gdbserver.8.2
COPY --from=cdt-infra-all-gdbs:ubuntu-18.04 /shared/common/gdb/gdb-all/bin/gdbserver.8.2.1 /shared/common/gdb/gdb-all/bin/gdbserver.8.2.1
```
42 changes: 42 additions & 0 deletions docker/cdt-infra-all-gdbs/ubuntu-18.04/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
FROM ubuntu:18.04

USER root


RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
curl \
git \
gnupg \
openssh-client \
pkg-config \
wget \
zip \
locales \
build-essential \
bison \
flex \
libgmp-dev \
libexpat1-dev \
libmpfr-dev \
libncurses-dev \
pkg-config \
zlib1g-dev \
texinfo \
&& rm -rf /var/lib/apt/lists/* \
&& locale-gen en_US.UTF-8

# Need locale to be UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

# Build GDB
COPY scripts/download-build-gdb.sh /opt/scripts/download-build-gdb.sh
ENV GDB_BASE /shared/common/gdb/gdb-all
ENV GDB_VERSIONS all
# build without debug info to reduce size
ENV CFLAGS -g0
ENV CXXFLAGS -g0
RUN chmod u+x /opt/scripts/download-build-gdb.sh && mkdir -p /shared/common/gdb/gdb-all && /opt/scripts/download-build-gdb.sh -b $GDB_BASE $GDB_VERSIONS \
&& rm -rf $GDB_BASE/download && rm -rf $GDB_BASE/build
2 changes: 2 additions & 0 deletions docker/cdt-infra-base/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This directory contains dockerfiles for CDT Infra to provide a basic Java environment.

139 changes: 139 additions & 0 deletions docker/cdt-infra-base/ubuntu-18.04/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# This file is derived from:
# - https://github.com/eclipse-cbi/dockerfiles/blob/bf1f1a18f4910d007de67765f8df083102150a7c/distros/Dockerfile
# - https://github.com/eclipse-cbi/dockerfiles/blob/bf1f1a18f4910d007de67765f8df083102150a7c/gtk3-wm/ubuntu-metacity/18.04/Dockerfile
# Consult https://github.com/eclipse-cbi/dockerfiles for possible updates
# differences from source are commented
FROM ubuntu:18.04

### user name recognition at runtime w/ an arbitrary uid - for OpenShift deployments
COPY scripts/uid_entrypoint /usr/local/bin/uid_entrypoint
RUN chmod u+x /usr/local/bin/uid_entrypoint && \
chgrp 0 /usr/local/bin/uid_entrypoint && \
chmod g=u /usr/local/bin/uid_entrypoint /etc/passwd

# Add dumb-init entry point: https://github.com/eclipse-cdt/cdt-infra/pull/26
RUN apt-get update && apt-get install -y --no-install-recommends \
dumb-init \
&& rm -rf /var/lib/apt/lists/*

ENTRYPOINT [ "uid_entrypoint", "dumb-init" ]

ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
libgtk-3-0 \
tigervnc-standalone-server \
tigervnc-common \
metacity \
x11-xserver-utils \
libgl1-mesa-dri \
xfonts-base \
xfonts-scalable \
xfonts-100dpi \
xfonts-75dpi \
fonts-liberation \
fonts-liberation2 \
fonts-freefont-ttf \
fonts-dejavu \
fonts-dejavu-core \
fonts-dejavu-extra \
&& rm -rf /var/lib/apt/lists/*

ENV HOME=/home/vnc
ENV DISPLAY :0

RUN mkdir -p ${HOME}/.vnc && chmod -R 775 ${HOME} \
&& echo "123456" | vncpasswd -f > ${HOME}/.vnc/passwd \
&& chmod 600 ${HOME}/.vnc/passwd

# In addition to metacity in upstream version, provide icewm and mutter manager scripts
# and use icewm as default (experiments showed that on 16.04 metacity was more reliable,
# but on 18.04 icewm is more reliable when running tests)
COPY scripts/xstartup_*.sh ${HOME}/.vnc/
COPY scripts/xstartup_metacity.sh ${HOME}/.vnc/xstartup.sh
RUN chmod 755 ${HOME}/.vnc/xstartup*.sh

####
# From this point forward is the extra standard tools for CDT

# git and other tools

RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
curl \
openssh-client \
wget \
zip \
unzip \
gnupg \
locales \
libxtst6 \
&& rm -rf /var/lib/apt/lists/*

RUN locale-gen en_US.UTF-8
# Need locale to be UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8


# Get release versions from Adoptium API: https://api.adoptium.net/q/swagger-ui/#/Release%20Info/getReleaseNames
ENV JDK17_VERSION jdk-17.0.11+9
ENV JDK21_VERSION jdk-21.0.3+9
ENV JAVA17_HOME /usr/lib/jvm/${JDK17_VERSION}
ENV JAVA21_HOME /usr/lib/jvm/${JDK21_VERSION}

# Get Java from adoptium + header files for win32 & mac for cross compiling JNI libraries on Java 8, 11, 17
# TODO: Move these runs into a script, the only difference between each invocation is the env variables
RUN export JVERSION=${JDK17_VERSION} \
&& export JHOME=${JAVA17_HOME} \
&& mkdir /tmp/x && mkdir -p /usr/lib/jvm \
&& curl -sL "https://api.adoptium.net/v3/binary/version/${JVERSION}/linux/x64/jdk/hotspot/normal/eclipse?project=jdk" > /tmp/x/openjdk-linux.tar.gz \
&& mkdir /tmp/x/linux && cd /tmp/x/linux && tar xvf /tmp/x/openjdk-linux.tar.gz \
&& mv /tmp/x/linux/${JVERSION} /usr/lib/jvm \
&& curl -sL "https://api.adoptium.net/v3/binary/version/${JVERSION}/windows/x64/jdk/hotspot/normal/eclipse?project=jdk" > /tmp/x/openjdk-win32.zip \
&& curl -sL "https://api.adoptium.net/v3/binary/version/${JVERSION}/mac/x64/jdk/hotspot/normal/eclipse?project=jdk" > /tmp/x/openjdk-mac.tar.gz \
&& mkdir /tmp/x/win32 && cd /tmp/x/win32 && unzip /tmp/x/openjdk-win32.zip \
&& mkdir /tmp/x/mac && cd /tmp/x/mac && tar xvf /tmp/x/openjdk-mac.tar.gz \
&& cd $JHOME/include && for i in *.h; do diff -w $i /tmp/x/win32/${JVERSION}/include/$i ; done \
&& cd $JHOME/include && for i in *.h; do diff -w $i /tmp/x/mac/${JVERSION}/Contents/Home/include/$i ; done \
&& mv /tmp/x/win32/${JVERSION}/include/win32 $JHOME/include \
&& mv /tmp/x/mac/${JVERSION}/Contents/Home/include/darwin $JHOME/include \
&& find $JHOME/include \
&& rm -rf /tmp/x
RUN export JVERSION=${JDK21_VERSION} \
&& export JHOME=${JAVA21_HOME} \
&& mkdir /tmp/x && mkdir -p /usr/lib/jvm \
&& curl -sL "https://api.adoptium.net/v3/binary/version/${JVERSION}/linux/x64/jdk/hotspot/normal/eclipse?project=jdk" > /tmp/x/openjdk-linux.tar.gz \
&& mkdir /tmp/x/linux && cd /tmp/x/linux && tar xvf /tmp/x/openjdk-linux.tar.gz \
&& mv /tmp/x/linux/${JVERSION} /usr/lib/jvm \
&& curl -sL "https://api.adoptium.net/v3/binary/version/${JVERSION}/windows/x64/jdk/hotspot/normal/eclipse?project=jdk" > /tmp/x/openjdk-win32.zip \
&& curl -sL "https://api.adoptium.net/v3/binary/version/${JVERSION}/mac/x64/jdk/hotspot/normal/eclipse?project=jdk" > /tmp/x/openjdk-mac.tar.gz \
&& mkdir /tmp/x/win32 && cd /tmp/x/win32 && unzip /tmp/x/openjdk-win32.zip \
&& mkdir /tmp/x/mac && cd /tmp/x/mac && tar xvf /tmp/x/openjdk-mac.tar.gz \
&& cd $JHOME/include && for i in *.h; do diff -w $i /tmp/x/win32/${JVERSION}/include/$i ; done \
&& cd $JHOME/include && for i in *.h; do diff -w $i /tmp/x/mac/${JVERSION}/Contents/Home/include/$i ; done \
&& mv /tmp/x/win32/${JVERSION}/include/win32 $JHOME/include \
&& mv /tmp/x/mac/${JVERSION}/Contents/Home/include/darwin $JHOME/include \
&& find $JHOME/include \
&& rm -rf /tmp/x


# Default to JAVA21 being in use
ENV PATH="${JAVA21_HOME}/bin:${PATH}"
ENV JAVA_HOME ${JAVA21_HOME}

# Maven - Note that this is the default, but the Jenkinsfile may override it with JIPP version
ENV MAVEN_VERSION 3.9.6
RUN curl -fsSL https://archive.apache.org/dist/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz | tar xzf - -C /usr/share \
&& mv /usr/share/apache-maven-$MAVEN_VERSION /usr/share/maven \
&& ln -s /usr/share/maven/bin/mvn /usr/bin/mvn
ENV MAVEN_HOME /usr/share/maven


#Fix permissions for OpenShift & standard k8s
RUN chown -R 1000:0 ${HOME} \
&& chmod -R g+rwX ${HOME}

ENV USER_NAME vnc
USER 1000
WORKDIR ${HOME}
3 changes: 3 additions & 0 deletions docker/cdt-infra-build-macos-sdk/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This directory contains dockerfiles to build a Cross platform MacOS SDK.

A download of [Xcode_13.1.xip](https://developer.apple.com/download/all/?q=xcode) (visit [here](https://developer.apple.com/download/more/) first to logon to Apple if needed) is needed to build this image.
25 changes: 25 additions & 0 deletions docker/cdt-infra-build-macos-sdk/ubuntu-18.04/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This dockerfile is used to build the MacOSX SDK
FROM ubuntu:18.04

RUN apt-get update
RUN apt-get install -y clang make build-essential
RUN apt-get install -y libssl-dev lzma-dev liblzma-dev libxml2-dev git cmake patch python cpio bzip2 xz-utils libbz2-dev

# Xcode_13.1.xip needs to be downloaded from
# https://developer.apple.com/download/all/?q=xcode - specically:
ARG Xcodexip=Xcode_13.1.xip
WORKDIR /opt
COPY ${Xcodexip} /opt/${Xcodexip}
RUN git clone https://github.com/tpoechtrager/osxcross.git
RUN cd /opt/osxcross && ./tools/gen_sdk_package_pbzx.sh /opt/${Xcodexip}
RUN mv /opt/osxcross/*.xz /opt/osxcross/tarballs
ENV UNATTENDED=1
RUN cd /opt/osxcross && ./build.sh

# Start next stage build
FROM ubuntu:18.04
COPY --from=0 /opt/osxcross/target /opt/osxcross/target
ENV PATH="/opt/osxcross/target/bin:${PATH}"
# At this point the osxcross toolchain is not usable,
# it needs to be copied into another container and that
# container needs clang & llvm installed too.
1 change: 1 addition & 0 deletions docker/cdt-infra-eclipse-full/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This directory contains dockerfiles for complete CDT Infra to build everything for Eclipse CDT
57 changes: 57 additions & 0 deletions docker/cdt-infra-eclipse-full/ubuntu-18.04/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
FROM cdt-infra-base:ubuntu-18.04

USER root

RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
git \
gdb \
libgmp-dev \
libexpat1-dev \
libipt1 \
libmpfr-dev \
libncurses-dev \
ninja-build \
pkg-config \
python3-all-dev python3-pip python3-setuptools \
zlib1g-dev \
gdbserver \
gcc-mingw-w64-x86-64 \
g++-mingw-w64-x86-64 \
gcc-aarch64-linux-gnu \
g++-aarch64-linux-gnu \
gcc-powerpc64le-linux-gnu \
g++-powerpc64le-linux-gnu \
clang \
libxml2-utils \
gettext-base \
xserver-xephyr \
&& apt-get install -y llvm \
&& apt-get install -y --no-install-recommends texinfo bison flex \
&& rm -rf /var/lib/apt/lists/* \
&& pip3 install --upgrade pip

#Specifc CDT deps

#Meson
RUN pip3 install meson

# GDB pre-built in a different image
COPY --from=cdt-infra-all-gdbs:ubuntu-18.04 /shared/common/gdb/gdb-all /shared/common/gdb/gdb-all
ENV PATH="/shared/common/gdb/gdb-all/bin:${PATH}"

# Get pre-built MacOSX toolchain from other image (this also
# requires clang to be listed in the installs above)
COPY --from=cdt-infra-build-macos-sdk:ubuntu-18.04 /opt/osxcross/target /opt/osxcross/target
ENV PATH="/opt/osxcross/target/bin:${PATH}"

#Fix permissions for OpenShift & standard k8s
RUN chown -R 1000:0 ${HOME} \
&& chmod -R g+rwX ${HOME}


ENV USER_NAME vnc
USER 1000
WORKDIR ${HOME}

CMD ["/home/vnc/.vnc/xstartup.sh"]
1 change: 1 addition & 0 deletions docker/cdt-infra-plus-eclipse-install/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This directory contains dockerfiles for complete CDT Infra + Eclipse Installations.
27 changes: 27 additions & 0 deletions docker/cdt-infra-plus-eclipse-install/ubuntu-18.04/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM ubuntu:18.04

ENV HOME=/home/vnc
RUN apt-get update
RUN apt-get install -y curl tar gzip
#Eclipse SDK & Fix permissions for OpenShift & standard k8s
RUN mkdir -p ${HOME}/buildtools && cd ${HOME}/buildtools \
&& curl -sL https://download.eclipse.org/eclipse/downloads/drops4/R-4.23-202203080310/eclipse-SDK-4.23-linux-gtk-x86_64.tar.gz | tar xvz \
&& mv eclipse eclipse-SDK-4.23 \
&& curl -sL https://download.eclipse.org/eclipse/downloads/drops4/R-4.31-202402290520/eclipse-SDK-4.31-linux-gtk-x86_64.tar.gz | tar xvz \
&& mv eclipse eclipse-SDK-4.31 \
&& chown -R 1000:0 ${HOME} \
&& chmod -R g+rwX ${HOME}

FROM cdt-infra-eclipse-full:ubuntu-18.04
USER root

COPY --from=0 ${HOME}/buildtools ${HOME}/buildtools
RUN apt-get update \
&& apt-get install -y clang-format \
&& rm -rf /var/lib/apt/lists/*
RUN apt-get update
RUN apt-get install -y ssh-askpass

USER 1000

CMD ["/home/vnc/.vnc/xstartup.sh"]
Loading

0 comments on commit 9fb6260

Please sign in to comment.