Skip to content

Add Docker build CI job#5053

Merged
pwojcikdev merged 2 commits intonanocurrency:developfrom
pwojcikdev:workflow-build-docker
Mar 29, 2026
Merged

Add Docker build CI job#5053
pwojcikdev merged 2 commits intonanocurrency:developfrom
pwojcikdev:workflow-build-docker

Conversation

@pwojcikdev
Copy link
Copy Markdown
Contributor

No description provided.

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.
@pwojcikdev pwojcikdev requested a review from Copilot March 29, 2026 23:17
@pwojcikdev pwojcikdev merged commit a09f4f0 into nanocurrency:develop Mar 29, 2026
27 of 29 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_build GitHub Actions job to build docker/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.

Comment on lines +30 to +33
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"
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
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.

2 participants