IuryNogueira/myreef

View on GitHub
backend_v2/Dockerfile

Summary

Maintainability
Test Coverage
ARG RUBY_VERSION
 
FROM ruby:$RUBY_VERSION-slim as base
 
 
# Rails app lives here
WORKDIR /app
 
# Throw-away build stage to reduce size of final image
FROM base as build
 
# Install packages needed to build gems
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y build-essential git libpq-dev libvips pkg-config
 
# RUN apt-get update -qq && apt-get install -y postgresql-client
 
# Install application gems
COPY Gemfile Gemfile.lock ./
RUN bundle install && \
rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \
bundle exec bootsnap precompile --gemfile
 
# Copy application code
COPY . .
 
# Precompile bootsnap code for faster boot times
RUN bundle exec bootsnap precompile app/ lib/
 
# Final stage for app image
FROM base
 
# Install packages needed for deployment
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y curl libvips postgresql-client netcat-traditional && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives
 
# Copy built artifacts: gems, application
COPY --from=build /usr/local/bundle /usr/local/bundle
COPY --from=build /app /app
 
# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
CMD ["sh", "/app/entrypoint.sh"]