Skip to content
Merged
1 change: 1 addition & 0 deletions taskfiles/deps/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ tasks:
- task: "utils:install-remote-cmake-lib"
vars:
CMAKE_GEN_ARGS:
- "-DCMAKE_BUILD_TYPE=Release"
- "-DUSE_SYSTEM_INSTALLED_LIB=ON"
- "-DINSTALL_LAYOUT=DEB"
LIB_NAME: "mariadb-connector-cpp"
Expand Down
24 changes: 15 additions & 9 deletions tools/docker-images/clp-package/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,21 @@ RUN ./setup-scripts/install-prebuilt-packages.sh \
RUN apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

ENV CLP_HOME="/opt/clp"
ENV PATH="${CLP_HOME}/bin:${PATH}"
ENV PATH="${CLP_HOME}/sbin:${PATH}"
ENV PYTHONPATH="${CLP_HOME}/lib/python3/site-packages"

USER 1000:1000

COPY --link ./build/clp-package /opt/clp

# Flatten the image
FROM scratch
COPY --link --from=base / /

ARG UID=1000
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ARG UID=1000
ARG USER=clp-user
ARG UID=1000
ARG GID=1000
RUN groupadd -g "${GID}" "${UID}" \
&& useradd --create-home --base-dir /home/ --shell /bin/bash --gid "${GID}" --uid "${UID}" "{USER}"
USER "${USER}"
WORKDIR "/home/${USER}"

if you want to mimic a real user home working environment. I think it would be beneficial to pass in the user id and group id of the github CI runner that builds and runs this package.

Copy link
Contributor

Choose a reason for hiding this comment

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

But if your system works as is, I don't really see a problem with it.

Copy link
Member Author

Choose a reason for hiding this comment

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

good point. the changes on the user creation were actually done by another PR #1413 . since this PR aims to only make the spider binaries work, let's do the group creation in another PR.

@coderabbitai add an issue to track the group creation in the docker image

Copy link
Contributor

Choose a reason for hiding this comment

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Create a GitHub issue to track group creation in the docker image

gh issue create \
  --title "Improve user and group setup in clp-package Docker image" \
  --body "## Context

This issue tracks improvements to the user and group creation process in the \`clp-package\` Docker image, as discussed in PR #1414.

## Background

During review of PR #1414, it was suggested that the Docker image could benefit from proper group creation and a more realistic user home environment setup. The current implementation creates a user but does not create a dedicated group or set up a traditional home directory structure.

## Suggested Improvements

- Add group creation with configurable GID
- Create user with proper group assignment
- Set up a traditional home directory under \`/home/\`
- Make UID and GID configurable as build arguments

## References

- PR: https://github.com/y-scope/clp/pull/1414
- Comment: https://github.com/y-scope/clp/pull/1414#discussion_r2455360711
- Requested by: @junhaoliao

## Notes

These changes were deferred from PR #1414 to keep that PR focused on making the spider binaries work. PR #1413 already made some initial user creation changes." \
  --assignee junhaoliao

Length of output: 42


@junhaoliao I've created issue #1508 to track the group creation improvements for the Docker image: #1508

The issue has been assigned to you and includes references back to this PR and the discussion. Good call on keeping this PR focused on the spider binaries functionality!

ENV CLP_HOME="/opt/clp"
ENV LD_LIBRARY_PATH="${CLP_HOME}/lib" \
PATH="${CLP_HOME}/sbin:${CLP_HOME}/bin:${PATH}" \
PYTHONPATH="${CLP_HOME}/lib/python3/site-packages" \
USER="clp-user"

RUN useradd --uid ${UID} --shell /bin/bash --home-dir ${CLP_HOME} ${USER}
USER ${USER}
WORKDIR ${CLP_HOME}

COPY --link --chown=${UID} ./build/clp-package ${CLP_HOME}
COPY --link --chown=${UID} ./build/deps/cpp/mariadb-connector-cpp-install/lib/*/libmariadbcpp.so* \
${CLP_HOME}/lib/
Loading