- Upgraded bundler version from 2.4.5 to 2.5.6 in Dockerfile for better compatibility. - Updated gem versions for faiss and rails_live_reload to their latest versions. - Modified Ruby files to enforce strict typing with Sorbet, enhancing type safety across various models and jobs. - Added type signatures to methods in Inkbunny and FA domain models, ensuring better type checking and documentation. - Improved job argument handling in Inkbunny jobs, including priority settings for deferred jobs. - Refactored initialization logic in several models to ensure default states are set correctly. These changes aim to enhance the overall stability and maintainability of the codebase.
81 lines
2.6 KiB
Docker
81 lines
2.6 KiB
Docker
FROM ruby:3.2.6 AS native-gems
|
|
RUN rm -f /etc/apt/apt.conf.d/docker-clean; \
|
|
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
|
|
RUN \
|
|
--mount=type=cache,target=/var/cache/apt,sharing=locked \
|
|
--mount=type=cache,target=/var/lib/apt,sharing=locked \
|
|
apt-get update && \
|
|
apt-get install --no-install-recommends --no-install-suggests -y \
|
|
cmake
|
|
|
|
WORKDIR /usr/src/app
|
|
RUN gem install bundler -v '2.5.6'
|
|
COPY gems gems
|
|
WORKDIR /usr/src/app/gems/xdiff-rb
|
|
RUN bundle _2.5.6_ install
|
|
RUN rake compile
|
|
WORKDIR /usr/src/app/gems/rb-bsdiff
|
|
RUN bundle _2.5.6_ install
|
|
RUN rake compile
|
|
|
|
# Primary image
|
|
FROM ruby:3.2.6
|
|
USER root
|
|
|
|
# apt caching & install packages
|
|
RUN rm -f /etc/apt/apt.conf.d/docker-clean; \
|
|
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
|
|
|
|
RUN \
|
|
--mount=type=cache,target=/var/cache/apt,sharing=locked \
|
|
--mount=type=cache,target=/var/lib/apt,sharing=locked \
|
|
apt-get update && \
|
|
apt-get install --no-install-recommends --no-install-suggests -y \
|
|
libblas-dev liblapack-dev
|
|
|
|
# preinstall gems that take a long time to install
|
|
RUN MAKE="make -j12" gem install bundler -v '2.5.6' --verbose
|
|
RUN MAKE="make -j12" gem install faiss -v '0.3.2' --verbose
|
|
RUN MAKE="make -j12" gem install rails_live_reload -v '0.3.6' --verbose
|
|
RUN bundle config --global frozen 1
|
|
|
|
# set up nodejs 18.x deb repo
|
|
RUN mkdir -p /etc/apt/keyrings && \
|
|
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key \
|
|
| gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
|
|
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" \
|
|
| tee /etc/apt/sources.list.d/nodesource.list
|
|
|
|
RUN \
|
|
--mount=type=cache,target=/var/cache/apt,sharing=locked \
|
|
--mount=type=cache,target=/var/lib/apt,sharing=locked \
|
|
apt-get update && \
|
|
apt-get install --no-install-recommends --no-install-suggests -y \
|
|
libvips42 ca-certificates curl gnupg nodejs libpq-dev
|
|
|
|
COPY --from=native-gems /usr/src/app/gems/xdiff-rb /gems/xdiff-rb
|
|
COPY --from=native-gems /usr/src/app/gems/rb-bsdiff /gems/rb-bsdiff
|
|
|
|
WORKDIR /usr/src/app
|
|
COPY Gemfile Gemfile.lock ./
|
|
RUN bundle _2.5.6_ install
|
|
|
|
# install js dependencies
|
|
COPY package.json yarn.lock ./
|
|
RUN npm install -g yarn
|
|
RUN rails yarn:install
|
|
RUN yarn
|
|
|
|
COPY . .
|
|
|
|
# precompile assets
|
|
RUN RAILS_ENV=production bin/rails assets:precompile
|
|
RUN mkdir -p tmp/pids
|
|
|
|
# create user with id=1000 gid=1000
|
|
RUN groupadd -g 1000 app && \
|
|
useradd -m -d /home/app -s /bin/bash -u 1000 -g 1000 app
|
|
RUN chown -R app:app /usr/src/app
|
|
USER app
|
|
CMD /bin/bash
|