@@ -20,7 +20,7 @@ WORKDIR /rails
2020
2121# Install base packages
2222RUN apt-get update -qq && \
23- apt-get install --no-install-recommends -y curl libjemalloc2 libvips libpq5 && \
23+ apt-get install --no-install-recommends -y curl libjemalloc2 libvips postgresql-client && \
2424 ln -s /usr/lib/$(uname -m)-linux-gnu/libjemalloc.so.2 /usr/local/lib/libjemalloc.so && \
2525 rm -rf /var/lib/apt/lists /var/cache/apt/archives
2626
@@ -52,10 +52,6 @@ COPY Gemfile Gemfile.lock ./
5252
5353RUN bundle install && \
5454 rm -rf ~/.bundle/ "${BUNDLE_PATH}" /ruby/*/cache "${BUNDLE_PATH}" /ruby/*/bundler/gems/*/.git && \
55- # Some gems (e.g. blanks) ship files as mode 600; the app runs as a
56- # different UID at runtime (see config/deploy.qa.yml), so make sure
57- # installed gems are readable regardless of owner.
58- chmod -R a+rX "${BUNDLE_PATH}" && \
5955 # -j 1 disable parallel compilation to avoid a QEMU bug: https://github.com/rails/bootsnap/issues/495
6056 bundle exec bootsnap precompile -j 1 --gemfile
6157
@@ -79,20 +75,16 @@ RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile
7975# Final stage for app image
8076FROM base
8177
82- # Run and own only the runtime files as a non-root user for security
83- RUN groupadd --system --gid 1000 rails && \
84- useradd rails --uid 1000 --gid 1000 --create-home --shell /bin/bash
85- USER 1000:1000
78+ # Run and own only the runtime files as a non-root user for security. Matches
79+ # lyberadmin's uid:gid on the Puppet-managed deploy hosts (see config/deploy.qa.yml)
80+ # so no runtime --user override is needed there.
81+ RUN groupadd --system --gid 503 lyberadmin && \
82+ useradd lyberadmin --uid 503 --gid 503 --create-home --shell /bin/bash
83+ USER 503:503
8684
8785# Copy built artifacts: gems, application
88- COPY --chown=rails:rails --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}"
89- COPY --chown=rails:rails --from=build /rails /rails
90-
91- # Rails creates tmp/{cache,pids,sockets} at boot and writes log/production.log;
92- # some destinations (see config/deploy.qa.yml) run the container as a different
93- # UID than the image's baked-in rails user, so make these writable regardless
94- # of runtime UID.
95- RUN chmod -R a+rwX tmp log
86+ COPY --chown=lyberadmin:lyberadmin --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}"
87+ COPY --chown=lyberadmin:lyberadmin --from=build /rails /rails
9688
9789# Entrypoint prepares the database.
9890ENTRYPOINT ["/rails/bin/docker-entrypoint" ]
0 commit comments