Add Docker build CI job#5053
Conversation
Avoid build failures on base images where UID or GID 1000 is already assigned. Reuse the existing group and rename the existing UID 1000 user to `nanocurrency` when needed.
There was a problem hiding this comment.
Pull request overview
Adds a dedicated CI job to build the production Docker image and updates the Dockerfile’s user creation logic to better tolerate UID/GID 1000 already being present in the base image.
Changes:
- Add a new
docker_buildGitHub Actions job to builddocker/node/Dockerfile. - Update Dockerfile user/group creation to handle pre-existing UID/GID 1000.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
docker/node/Dockerfile |
Adjusts runtime image user/group setup for UID/GID 1000 collision handling. |
.github/workflows/unit_tests.yml |
Adds a CI job that runs docker build for the production node image. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| RUN getent group 1000 >/dev/null || groupadd --gid 1000 nanocurrency && \ | ||
| user_1000="$(getent passwd 1000 | cut -d: -f1 || true)" && \ | ||
| [ -z "$user_1000" ] && useradd --uid 1000 --gid 1000 --shell /bin/bash --create-home nanocurrency || \ | ||
| [ "$user_1000" = nanocurrency ] || usermod --login nanocurrency --home /home/nanocurrency --move-home "$user_1000" |
There was a problem hiding this comment.
The RUN line mixes || and && without grouping. As written, if getent group 1000 succeeds, the || short-circuits and the rest of the chain (detecting/creating/renaming the UID 1000 user) is skipped, so the nanocurrency user may never be created. Wrap the group check/add in parentheses (or split into separate commands) so the user-handling logic always runs after the group step, and consider restructuring the user create/rename logic to avoid falling through to usermod when useradd fails.
| RUN getent group 1000 >/dev/null || groupadd --gid 1000 nanocurrency && \ | |
| user_1000="$(getent passwd 1000 | cut -d: -f1 || true)" && \ | |
| [ -z "$user_1000" ] && useradd --uid 1000 --gid 1000 --shell /bin/bash --create-home nanocurrency || \ | |
| [ "$user_1000" = nanocurrency ] || usermod --login nanocurrency --home /home/nanocurrency --move-home "$user_1000" | |
| RUN set -eux; \ | |
| if ! getent group 1000 >/dev/null; then \ | |
| groupadd --gid 1000 nanocurrency; \ | |
| fi; \ | |
| user_1000="$(getent passwd 1000 | cut -d: -f1 || true)"; \ | |
| if [ -z "$user_1000" ]; then \ | |
| useradd --uid 1000 --gid 1000 --shell /bin/bash --create-home nanocurrency; \ | |
| elif [ "$user_1000" != nanocurrency ]; then \ | |
| usermod --login nanocurrency --home /home/nanocurrency --move-home "$user_1000"; \ | |
| fi |
No description provided.