Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 30 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,49 @@ FROM docker.io/library/ruby:$RUBY_VERSION-slim AS base
WORKDIR /rails

# Install base packages
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y curl libjemalloc2 libvips postgresql-client && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update -qq && \
apt-get install --no-install-recommends -y curl libjemalloc2 libvips postgresql-client xz-utils imagemagick

# install prebuilt node binary
ARG TARGETARCH
RUN case "$TARGETARCH" in \
amd64) NODE_ARCH=x64 ;; \
arm64) NODE_ARCH=arm64 ;; \
armhf) NODE_ARCH=armv7l ;; \
*) echo "Unsupported architecture: $TARGETARCH" && exit 1 ;; \
esac && \
curl -o node-v22.16.0-linux-${NODE_ARCH}.tar.xz https://nodejs.org/dist/v22.16.0/node-v22.16.0-linux-${NODE_ARCH}.tar.xz && \
tar -xJf node-v22.16.0-linux-${NODE_ARCH}.tar.xz && \
mv node-v22.16.0-linux-${NODE_ARCH} /usr/local/node && \
rm -rf node-v22.16.0-linux-${NODE_ARCH}.tar.xz

# Set production environment
ENV RAILS_ENV="production" \
BUNDLE_DEPLOYMENT="1" \
BUNDLE_PATH="/usr/local/bundle" \
BUNDLE_WITHOUT="development"
BUNDLE_WITHOUT="development" \
PATH="/usr/local/node/bin:/usr/local/node/lib/node_modules:$PATH"

RUN --mount=type=cache,target=/root/.npm \
npm install -g defuddle-cli

# Throw-away build stage to reduce size of final image
FROM base AS build

# Install packages needed to build gems
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y build-essential git libpq-dev libyaml-dev pkg-config && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update -qq && \
apt-get install --no-install-recommends -y build-essential git libpq-dev libyaml-dev pkg-config

# Install application gems
COPY Gemfile Gemfile.lock ./
RUN bundle install && \
RUN --mount=type=cache,target=/tmp/bundle-cache \
cp -r /tmp/bundle-cache/* "${BUNDLE_PATH}/" 2>/dev/null || true && \
bundle install && \
cp -r "${BUNDLE_PATH}"/* /tmp/bundle-cache/ && \
rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \
bundle exec bootsnap precompile --gemfile

Expand Down
4 changes: 2 additions & 2 deletions app/jobs/feed_refresher_job.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
class FeedRefresherJob < ApplicationJob
queue_as :default

def perform(feed = nil)
def perform(feed: nil)
if feed.nil?
Feed.all.each { |f| FeedRefresherJob.perform_later(f) }
Feed.find_each { |f| FeedRefresherJob.perform_later(feed: f) }
else
feed.refresh!
end
Expand Down
2 changes: 1 addition & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Application < Rails::Application
config.good_job.cron = {
feed_refresh: { # each recurring job must have a unique key
cron: "every 3 hours", # cron-style scheduling format by fugit gem
class: "FeedRefreshJob", # name of the job class as a String; must reference an Active Job job class
class: "FeedRefresherJob", # name of the job class as a String; must reference an Active Job job class
description: "Refreshed feeds and creates new entries", # optional description that appears in Dashboard,
enabled_by_default: -> { Rails.env.production? } # Only enable in production, otherwise can be enabled manually through Dashboard
}
Expand Down