FROM docker.io/library/ruby:3.2-slim
#NOTE: this file must be built from the parent (../) directory
# look at the
#   rebuild-docker.sh
# script as kind of manual on how the drb_counter cointainer is managed and used


# throw errors if Gemfile has been modified since Gemfile.lock
#RUN bundle config --global frozen 1

RUN mkdir -p /usr/src/app

WORKDIR /usr/src/app
RUN apt-get update
RUN apt install -y build-essential
RUN gem install bundler:1.17.3


RUN mkdir -p /usr/src/app/config
# Test
#RUN apt-get update && apt-get install -y qt5-default libqt5webkit5-dev --no-install-recommends && rm -rf /var/lib/apt/lists/*
# Standard
#RUN apt-get update && apt-get install -y nodejs --no-install-recommends && rm -rf /var/lib/apt/lists/*
#RUN apt-get update && apt-get install -y mysql-client postgresql-client sqlite3 --no-install-recommends && rm -rf /var/lib/apt/lists/*
# Specific
#RUN apt-get update && apt-get install -y dos2unix --no-install-recommends && rm -rf /var/lib/apt/lists/*

COPY faye/Gemfile /usr/src/app/
#COPY faye/Gemfile.lock /usr/src/app/
#COPY  vendor/cache /usr/src/app/vendor/cache
#RUN bundle install --local
#RUN rm -rf /usr/src/app/.bundle
RUN bundle install

COPY ./faye /usr/src/app
#RUN cp /usr/src/app/ssl/rootCA.pem /etc/ssl/certs/mozo-ssl-rootCA.pem
#RUN cp /usr/src/app/ssl/fullchain.pem /etc/ssl/certs/mozo-ssl-fullchain.pem
#RUN update-ca-certificates

ENV FAYE_PORT=9296
EXPOSE $FAYE_PORT

#CMD thin start -R config.ru -p $FAYE_PORT
#CMD thin start -R config.ru -p $FAYE_PORT --ssl --ssl-disable-verify
#CMD falcon serve --port $FAYE_PORT
#CMD passenger start --port $FAYE_PORT --ssl --ssl-certificate ssl/fullchain.pem --ssl-certificate-key ssl/privkey.pem
#CMD thin start -R config.ru -p $FAYE_PORT --ssl --ssl-disable-verify --ssl-key-file=ssl/privkey.pem --ssl-cert-file=ssl/fullchain.pem
CMD thin start -R config.ru -p $FAYE_PORT
