fix: free default ubuntu uid/gid before creating astrai user
- ubuntu:24.04 base image ships a default 'ubuntu' user/group at uid/gid 1000, so the default USER_UID/USER_GID build args collided and docker build failed at groupadd with "GID '1000' already exists" - remove the default ubuntu user/group first (tolerating images without it) so the astrai non-root user is created with the host uid/gid as intended
This commit is contained in:
+6
-2
@@ -57,10 +57,14 @@ COPY docs/ ./docs/
|
||||
COPY pyproject.toml .
|
||||
COPY README.md .
|
||||
|
||||
# Create non-root user matching the host uid/gid (passed via build args)
|
||||
# Create non-root user matching the host uid/gid (passed via build args).
|
||||
# ubuntu:24.04 ships a default 'ubuntu' user/group at uid/gid 1000, so remove
|
||||
# it first to free those ids before creating astrai.
|
||||
ARG USER_UID=1000
|
||||
ARG USER_GID=1000
|
||||
RUN groupadd -g "${USER_GID}" astrai \
|
||||
RUN userdel -r ubuntu 2>/dev/null || true \
|
||||
&& groupdel ubuntu 2>/dev/null || true \
|
||||
&& groupadd -g "${USER_GID}" astrai \
|
||||
&& useradd -m -u "${USER_UID}" -g astrai astrai \
|
||||
&& chown -R astrai:astrai /app
|
||||
ENV HOME=/home/astrai
|
||||
|
||||
Reference in New Issue
Block a user