FROM ruby:2.7

# Install dependencies
RUN deps='libmagic-dev chromium nodejs' && \
    apt-get update && \
    apt-get install --no-install-recommends -y $deps && \
    rm -Rf /var/lib/apt/lists/* /var/cache/apt/*

ENV PORT=3000 \
    SMTP_SERVER_PORT=2525 \
    RAILS_ENV=development \
    RAILS_LOG_TO_STDOUT=true \
    RAILS_SERVE_STATIC_FILES=true \
    \
    CHROMIUM_FLAGS=--no-sandbox \
    \
    BUNDLE_PATH=/usr/local/bundle \
    BUNDLE_APP_CONFIG=/usr/local/bundle/config

WORKDIR /app

RUN gem install bundler
RUN bundle config build.nokogiri "--use-system-libraries"

EXPOSE 3000

# cleanup, and by default start web process from Procfile
ENTRYPOINT ["./docker-entrypoint.sh"]
CMD ["./proc-start", "web"]
