Skip to content

Commit e822d43

Browse files
authored
Create non-root app user in Ruby base image (#2)
Creates a system user (uid 1000) in the base stage so downstream Dockerfiles can switch to it with USER app. Not activated here so the build stage keeps root for package installation.
1 parent 25eb4b5 commit e822d43

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

ruby/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ RUN apt-get update -qq \
1111
postgresql-client \
1212
&& rm -rf /var/lib/apt/lists /var/cache/apt/archives
1313

14+
# Non-root user for runtime stages (USER not set here so build stage keeps root)
15+
RUN useradd --system --uid 1000 app && chown app:app /app
16+
1417
# Set production environment
1518
ENV BUNDLE_DEPLOYMENT="1" \
1619
BUNDLE_PATH="/usr/local/bundle" \

0 commit comments

Comments
 (0)