The personal finance app for everyone (by everyone)
Ruby
build(docker): ensure build-stage packages installed with fresh apt metadata (#114)
Himank Daved162c58732cc
diff --git a/Dockerfile b/Dockerfileindex 2092d0ef86..2248d82788 100644--- a/Dockerfile+++ b/Dockerfile@@ -8,8 +8,9 @@ FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim AS baseWORKDIR /rails# Install base packages-RUN apt-get update -qq && \- apt-get install --no-install-recommends -y curl libvips postgresql-client libyaml-0-2+RUN apt-get update -qq \+ && apt-get install --no-install-recommends -y curl libvips postgresql-client libyaml-0-2 \+ && rm -rf /var/lib/apt/lists /var/cache/apt/archives# Set production environmentARG BUILD_COMMIT_SHA@@ -23,15 +24,15 @@ ENV RAILS_ENV="production" \FROM base AS build# Install packages needed to build gems-RUN apt-get install --no-install-recommends -y build-essential libpq-dev git pkg-config libyaml-dev+RUN apt-get update -qq \+ && apt-get install --no-install-recommends -y build-essential libpq-dev git pkg-config libyaml-dev \+ && rm -rf /var/lib/apt/lists /var/cache/apt/archives# Install application gemsCOPY .ruby-version Gemfile Gemfile.lock ./-RUN bundle install--RUN rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git--RUN bundle exec bootsnap precompile --gemfile -j 0+RUN bundle install \+ && rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git \+ && bundle exec bootsnap precompile --gemfile -j 0# Copy application codeCOPY . .@@ -45,19 +46,15 @@ RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile# Final stage for app imageFROM base-# Clean up installation packages to reduce image size-RUN rm -rf /var/lib/apt/lists /var/cache/apt/archives--# Copy built artifacts: gems, application-COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}"-COPY --from=build /rails /rails-# Run and own only the runtime files as a non-root user for securityRUN groupadd --system --gid 1000 rails && \- useradd rails --uid 1000 --gid 1000 --create-home --shell /bin/bash && \- chown -R rails:rails db log storage tmp+ useradd rails --uid 1000 --gid 1000 --create-home --shell /bin/bashUSER 1000:1000+# Copy built artifacts: gems, application+COPY --chown=rails:rails --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}"+COPY --chown=rails:rails --from=build /rails /rails+# Entrypoint prepares the database.ENTRYPOINT ["/rails/bin/docker-entrypoint"]