Project

General

Profile

Misc #17337 ยป Dockerfile

Rinkana (Max Berends), 11/29/2020 08:35 PM

 
ARG DEBIAN_VERSION=buster
ARG RUBY_VERSION=3.0-rc
#2.7
#3.0-rc

FROM ruby:$RUBY_VERSION-slim-${DEBIAN_VERSION} AS development

ARG PG_MAJOR=13
ARG NODE_MAJOR=14
ARG BUNDLER_VERSION=2.1.4
ARG YARN_VERSION=1.22.5
ARG APP_PATH=/exclusive

ENV LANG=C.UTF-8 \
BUNDLE_JOBS=4 \
BUNDLE_RETRY=3 \
APP_PATH=/exclusive \
RAILS_ENV=development

# Build requirements
RUN apt-get update -qq \
&& apt-get install -yq --no-install-recommends \
build-essential \
gnupg2 \
curl \
less \
git

RUN curl -sSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& echo 'deb http://apt.postgresql.org/pub/repos/apt/ buster-pgdg main' ${PG_MAJOR} > /etc/apt/sources.list.d/pgdg.list

RUN curl -sL https://deb.nodesource.com/setup_${NODE_MAJOR}.x | bash -

RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& echo 'deb http://dl.yarnpkg.com/debian/ stable main' > /etc/apt/sources.list.d/yarn.list

COPY docker-aptfile /tmp/docker-aptfile

COPY entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh

RUN apt-get update -qq && \
DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \
libpq-dev \
postgresql-client-$PG_MAJOR \
nodejs \
g++ \
libsass-dev \
yarn=$YARN_VERSION-1 \
$(cat /tmp/docker-aptfile | xargs) && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
truncate -s 0 /var/log/*log

RUN gem update --system && \
gem install bundler:$BUNDLER_VERSION

RUN mkdir -p $APP_PATH
WORKDIR $APP_PATH
COPY . $APP_PATH
ENTRYPOINT ["entrypoint.sh"]


FROM development as production

ENV RAILS_ENV=production

RUN bundle install --without development test && \
yarn install

EXPOSE 3000

CMD ["rails", "server", "-b", "0.0.0.0"]
    (1-1/1)