Skip to content

Replace cimg base image with ubuntu:latest #95

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

sarahchen6
Copy link

@sarahchen6 sarahchen6 commented May 13, 2025

With our transition from CircleCI to Gitlab, we want to replace the cimg base image with the smaller, faster, safer ubuntu:24.04 image.

pip3 install awscli
pip3 install requests requests-unixsocket2
apt-get update
pip3 install --break-system-packages awscli requests requests-unixsocket2
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

used --break-system-packages to avoid issues with installing packages alongside the system's (blog ref)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting! Wasn't aware of this param :)

Copy link

@delner delner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General Docker changes look good to me. Not sure how to answer the question about pip and --break-system-packages.

@sarahchen6 sarahchen6 marked this pull request as ready for review May 14, 2025 19:38
@sarahchen6 sarahchen6 requested a review from bric3 May 14, 2025 19:39
Copy link

@bric3 bric3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the built image is missing a few tools used in the scripts here and there in dd-trace-java.

Got a few questions / remarks though, that may be addressed later.

  1. I noticed the versioning is based on year + month

    version="$(date +%y.%m)"

    Since this is like a major change shall we label this differently? That said this could affect other part of the build pipelines.

  2. Circle CI image appear to use the circleci user, this requires commands to be run as sudo. Should we reproduce this behavior?

Dockerfile Outdated
Comment on lines 73 to 78
RUN apt-get update && \
apt-get install -y curl tar apt-transport-https ca-certificates gnupg \
socat less debian-goodies autossh ca-certificates-java python3-pip && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
mkdir -p /usr/local/lib/docker/cli-plugins /usr/local/bin
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: use heredoc style

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is not enough, we'll miss other executables such as jq, yq, git, gh (the github cli), docker among others.

Another thing that may bites us is the locale environment variables, we may want to have LANG=en_US.UTF-8, LC_ALL=en_US.UTF-8 (likely doable via this apt-get install -y locales && locale-gen en_US.UTF-8 and setting the envs ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8'.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added locale environment variables! How could we get a comprehensive list of all of the executables we'd need to add? By parsing through dd-trace-java..? 😅

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I guess, or maybe dive into the cimg layer.

You can do so using dive or IntelliJ IDEA docker support.

@sarahchen6 sarahchen6 force-pushed the sarahchen6/change-base-image branch from 3763033 to bdee917 Compare May 14, 2025 22:11
@sarahchen6
Copy link
Author

sarahchen6 commented May 14, 2025

Since this is like a major change shall we label this differently? That said this could affect other part of the build pipelines.

@bric3 What do you mean by labelling differently? From this PR, it seems like the intention is to label each image by when it was last pulled, so year/month seems to make sense 🤔

@sarahchen6
Copy link
Author

sarahchen6 commented May 15, 2025

Circle CI image appear to use the circleci user, this requires commands to be run as sudo. Should we reproduce this behavior?

@bric3 Good point! Looking into this, it seems like it is good security practice for the Dockerfile to run as a non-root user (one ref). However, we can still install everything at the root without using the sudo command and just switch to a non-root user during runtime at the end.

Copy link
Contributor

@PerfectSlayer PerfectSlayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good.

Few comments about cleaning it up further:

  • Is the yq, docker and docker-compose still needed? I used to install them manually to override the outdated version from the CircleCI image but I don't know if they are used.
  • Similarly I don't know if autoforward is still used 🤷
  • And I ask to @smola what ubuntu17 is for and if it is still relevant

Do you know how to test the image from your PR in the CI to test it?

sudo cp -rf --remove-destination /etc/java-17-openjdk/* /usr/lib/jvm/ubuntu17/lib/
sudo cp -f --remove-destination /etc/java-17-openjdk/jvm-amd64.cfg /usr/lib/jvm/ubuntu17/lib/
apt-get update
apt-get install -y openjdk-17-jdk
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@smola Do you remember why we added the ubuntu17 variant in the first place in #56 ?
Is there some difference with Temurin / OpenJDK 17?

pip3 install awscli
pip3 install requests requests-unixsocket2
apt-get update
pip3 install --break-system-packages awscli requests requests-unixsocket2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting! Wasn't aware of this param :)

@PerfectSlayer
Copy link
Contributor

You might want to revisit the cron time too:
https://github.com/DataDog/dd-trace-java-docker-build/blob/master/.github/workflows/ci.yml#L10-L12

@sarahchen6 sarahchen6 changed the title Replace cimg base image with ubuntu:24.04 Replace cimg base image with ubuntu:latest May 16, 2025
Copy link

@bric3 bric3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the tags, it's just that the current image inherit cimg, while this PR changes it to ubuntu, I pondered on making the change of the base image more visible via tags.

@@ -143,6 +175,9 @@ COPY --from=all-jdk /usr/lib/jvm/ubuntu17 /usr/lib/jvm/ubuntu17
COPY --from=all-jdk /usr/lib/jvm/graalvm17 /usr/lib/jvm/graalvm17
COPY --from=all-jdk /usr/lib/jvm/graalvm21 /usr/lib/jvm/graalvm21

# Switch to non-root user during runtime for security
USER non-root-user
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Do we want a workdir in these images as well ?

E.g. the non-root-user's home, that can be created via --create-home in the useradd above commands

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! -m has the same functionality as --create-home (ref). I did not set WORKDIR to this created directory though, so let me do that.

Comment on lines +87 to +88
apt-get install -y curl tar apt-transport-https ca-certificates gnupg \
socat less debian-goodies autossh ca-certificates-java python3-pip locales
Copy link

@bric3 bric3 May 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Re on the need for jq, git I think, and if they come as dependencies, I believe they deserve to be explicitly asked to apt-get. The github cli gh is definitely used in the pipelines, but I'm not sure where iot is installed.

I also wonder if docker needs to be installed as well, I believe the build is using test-containers which can make use of it. And just raising this I realise I have no idea how do work docker in docker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants