Skip to content
Snippets Groups Projects
Select Git revision
  • 1aeacadca41295c839a6327912f9a6f1f8d8522d
  • master default protected
  • v3-modify-mail
  • snyk-fix-207483a1e839c807f95a55077e86527d
  • translations_3b5aa4f3c755059914cfa23d7d2edcde_ru
  • translations_6e4a5e377a3e50f17e6402264fdbfcc6_ru
  • translations_3b5aa4f3c755059914cfa23d7d2edcde_fa_IR
  • translations_en-yml--master_fa_IR
  • snyk-fix-7d634f2eb65555f41bf06d6af930e812
  • translations_en-yml--master_ar
  • translations_3b5aa4f3c755059914cfa23d7d2edcde_el
  • jfederico-patch-1
  • v2
  • v3
  • v1
  • release-3.1.0.2
  • release-3.1.0.1
  • release-3.1.0
  • release-2.14.8.4
  • release-3.0.9.1
  • release-3.0.9
  • release-3.0.8.1
  • release-2.14.8.3
  • release-3.0.8
  • release-3.0.7.1
  • release-2.14.8.2
  • release-3.0.7
  • release-3.0.6.1
  • release-3.0.6
  • release-3.0.5.4
  • release-3.0.5.3
  • release-2.14.8.1
  • release-3.0.5.2
  • release-3.0.5.1
  • release-3.0.5
35 results

Dockerfile

Blame
  • user avatar
    Ahmad Farhat authored and GitHub committed
    74cb620b
    History
    Dockerfile 1.66 KiB
    FROM ruby:2.7.2-alpine AS base
    
    # Set a variable for the install location.
    ARG RAILS_ROOT=/usr/src/app
    # Set Rails environment.
    ENV RAILS_ENV production
    ENV BUNDLE_APP_CONFIG="$RAILS_ROOT/.bundle"
    
    # Make the directory and set as working.
    RUN mkdir -p $RAILS_ROOT
    WORKDIR $RAILS_ROOT
    
    ARG BUILD_PACKAGES="build-base curl-dev git"
    ARG DEV_PACKAGES="postgresql-dev sqlite-libs sqlite-dev yaml-dev zlib-dev nodejs yarn"
    ARG RUBY_PACKAGES="tzdata"
    
    # Install app dependencies.
    RUN apk update \
        && apk upgrade \
        && apk add --update --no-cache $BUILD_PACKAGES $DEV_PACKAGES $RUBY_PACKAGES
    
    COPY Gemfile* ./
    COPY Gemfile Gemfile.lock $RAILS_ROOT/
    
    RUN bundle config --global frozen 1 \
        && bundle install --deployment --without development:test:assets -j4 --path=vendor/bundle \
        && rm -rf vendor/bundle/ruby/2.7.0/cache/*.gem \
        && find vendor/bundle/ruby/2.7.0/gems/ -name "*.c" -delete \
        && find vendor/bundle/ruby/2.7.0/gems/ -name "*.o" -delete
    
    # Adding project files.
    COPY . .
    
    # Remove folders not needed in resulting image
    RUN rm -rf tmp/cache spec
    
    ############### Build step done ###############
    
    FROM ruby:2.7.2-alpine
    
    # Set a variable for the install location.
    ARG RAILS_ROOT=/usr/src/app
    ARG PACKAGES="tzdata curl postgresql-client sqlite-libs yarn nodejs bash"
    
    ENV RAILS_ENV=production
    ENV BUNDLE_APP_CONFIG="$RAILS_ROOT/.bundle"
    
    WORKDIR $RAILS_ROOT
    
    RUN apk update \
        && apk upgrade \
        && apk add --update --no-cache $PACKAGES
    
    
    COPY --from=base $RAILS_ROOT $RAILS_ROOT
    
    # Expose port 80.
    EXPOSE 80
    
    # Sets the footer of greenlight application with current build version
    ARG version_code
    ENV VERSION_CODE=$version_code
    
    # Start the application.
    CMD ["bin/start"]