<reponame>Mixbook/tagtical
FROM public.ecr.aws/debian/debian:stretch
RUN apt-get -y update \
    && apt-get -y upgrade \
    && apt-get install -y \
    autoconf \
    build-essential \
    curl \
    default-libmysqlclient-dev \
    libgdbm-dev \
    libreadline-dev \
    libsqlite3-dev \
    libssl1.0-dev \
    mysql-client \
    wait-for-it \
    zlib1g-dev
RUN groupadd -g 9001 mixbook && useradd -s /bin/bash -d /home/mixbook -c "Mixbook User" -u 10001 -g mixbook -G staff mixbook \
    && mkdir -p /home/mixbook /var/mixbook/tagtical \
    && chown -R mixbook:mixbook /home/mixbook /var/mixbook/tagtical
USER mixbook
RUN mkdir /usr/local/src/ruby \
    && cd /usr/local/src/ruby \
    && curl https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.8.tar.gz \
    |  tar -xz --strip-components 1 \
    && autoconf \
    && ./configure --prefix="${HOME}/.ruby" \
    && make -j4 \
    && make install \
    && rm -rf /usr/local/src/ruby/*
ENV PATH="/home/mixbook/.ruby/bin:${PATH}"
RUN gem install bundler -v 1.17.3 --no-ri --no-rdoc
WORKDIR /var/mixbook/tagtical
ARG GEMFILE=gemfiles/Gemfile-rails-4.0.x
COPY --chown=mixbook:mixbook $GEMFILE ./Gemfile
COPY --chown=mixbook:mixbook tagtical.gemspec ./
RUN bundle install -j4
COPY --chown=mixbook:mixbook . ./
ENTRYPOINT ["bundle", "exec"]
