mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 12:04:08 +00:00
Speedup docker build time (#463)
This commit is contained in:
13
Dockerfile
13
Dockerfile
@@ -7,6 +7,10 @@ FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base
|
|||||||
# Rails app lives here
|
# Rails app lives here
|
||||||
WORKDIR /rails
|
WORKDIR /rails
|
||||||
|
|
||||||
|
# Install base packages
|
||||||
|
RUN apt-get update -qq && \
|
||||||
|
apt-get install --no-install-recommends -y curl libvips postgresql-client
|
||||||
|
|
||||||
# Set production environment
|
# Set production environment
|
||||||
ENV RAILS_ENV="production" \
|
ENV RAILS_ENV="production" \
|
||||||
BUNDLE_DEPLOYMENT="1" \
|
BUNDLE_DEPLOYMENT="1" \
|
||||||
@@ -18,8 +22,7 @@ ENV RAILS_ENV="production" \
|
|||||||
FROM base as build
|
FROM base as build
|
||||||
|
|
||||||
# Install packages needed to build gems
|
# Install packages needed to build gems
|
||||||
RUN apt-get update -qq && \
|
RUN apt-get install --no-install-recommends -y build-essential git libpq-dev pkg-config
|
||||||
apt-get install --no-install-recommends -y build-essential git libpq-dev libvips pkg-config
|
|
||||||
|
|
||||||
# Install application gems
|
# Install application gems
|
||||||
COPY Gemfile Gemfile.lock ./
|
COPY Gemfile Gemfile.lock ./
|
||||||
@@ -40,10 +43,8 @@ RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile
|
|||||||
# Final stage for app image
|
# Final stage for app image
|
||||||
FROM base
|
FROM base
|
||||||
|
|
||||||
# Install packages needed for deployment
|
# Clean up installation packages to reduce image size
|
||||||
RUN apt-get update -qq && \
|
RUN rm -rf /var/lib/apt/lists /var/cache/apt/archives
|
||||||
apt-get install --no-install-recommends -y curl libvips postgresql-client && \
|
|
||||||
rm -rf /var/lib/apt/lists /var/cache/apt/archives
|
|
||||||
|
|
||||||
# Copy built artifacts: gems, application
|
# Copy built artifacts: gems, application
|
||||||
COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}"
|
COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}"
|
||||||
|
|||||||
Reference in New Issue
Block a user