FROM ruby:3.2.2-bookworm # We'll need the exact version of PostgreSQL client, matching our server version, so let's get it from official repos. RUN curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg >/dev/null RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ bookworm-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list # Now install the exact version of the client we need, along with a few other packages. RUN apt-get update && apt-get install -y \ postgresql-client-12 \ ca-certificates \ cron \ curl \ gnupg \ libvips # We need NodeJS & Yarn for precompiling assets. RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list RUN echo 'Package: nodejs\nPin: origin deb.nodesource.com\nPin-Priority: 1001' > /etc/apt/preferences.d/nodesource RUN apt-get update && apt-get install nodejs -y RUN corepack enable # Create a writable home directory for www-data RUN mkdir /var/www RUN chown -R www-data:www-data /var/www # Set up Tini. ENV TINI_VERSION v0.19.0 ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini RUN chmod +x /tini # Use the www-data user to run the application USER www-data WORKDIR /app # Install gems. COPY --chown=www-data:www-data Gemfile . COPY --chown=www-data:www-data Gemfile.lock . RUN gem install bundler -v '2.5.7' RUN bundle install -j4 # Install JS dependencies using Yarn. COPY --chown=www-data:www-data package.json . COPY --chown=www-data:www-data yarn.lock . COPY --chown=www-data:www-data .yarnrc.docker.yml .yarnrc.yml COPY --chown=www-data:www-data .yarn/releases .yarn/releases # Ignore checksum until issue with react-csv-reader is resolved. ENV YARN_CHECKSUM_BEHAVIOR=ignore # Install NodeJS dependencies. RUN yarn install # Copy over remaining files and set up for precompilation. COPY --chown=www-data:www-data . /app COPY --chown=www-data:www-data example.env .env COPY --chown=www-data:www-data config/database.evaluation.yml config/database.yml # Export the locales.json file. RUN bundle exec i18n export # Compile ReScript files to JS. RUN yarn run re:build # Run Vite's build step now so that app boots up quickly. RUN bundle exec bin/vite build RUN mkdir -p tmp/pids # Use Tini. ENTRYPOINT ["/tini", "--"] # Run under tini to ensure proper signal handling. CMD bin/evaluate