mirror of
https://github.com/System-End/theseus.git
synced 2026-04-19 16:38:18 +00:00
78 lines
2.3 KiB
Text
78 lines
2.3 KiB
Text
# syntax=docker/dockerfile:1
|
|
# check=error=true;skip=SecretsUsedInArgOrEnv
|
|
|
|
# Worker Dockerfile for running GoodJob background jobs
|
|
# Build: docker build -f Dockerfile.worker -t theseus-worker .
|
|
# Run: docker run -d -e RAILS_MASTER_KEY=<value from config/master.key> --name theseus-worker theseus-worker
|
|
|
|
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version
|
|
ARG RUBY_VERSION=3.4.4
|
|
FROM docker.io/library/ruby:$RUBY_VERSION-slim
|
|
|
|
# Set production environment
|
|
ENV RAILS_ENV="production" \
|
|
BUNDLE_DEPLOYMENT="1" \
|
|
BUNDLE_PATH="/usr/local/bundle" \
|
|
BUNDLE_WITHOUT="development"
|
|
|
|
# Install base packages and build dependencies
|
|
RUN apt-get update -qq && apt-get install --no-install-recommends -y \
|
|
curl \
|
|
libjemalloc2 \
|
|
libvips \
|
|
postgresql-client \
|
|
wget \
|
|
build-essential \
|
|
git \
|
|
libpq-dev \
|
|
node-gyp \
|
|
pkg-config \
|
|
python-is-python3 \
|
|
imagemagick \
|
|
libmagickwand-dev \
|
|
ghostscript \
|
|
libyaml-dev \
|
|
chromium
|
|
|
|
RUN sed -i '/disable ghostscript format types/,+6d' /etc/ImageMagick-6/policy.xml
|
|
|
|
# Install Node.js and Yarn
|
|
ARG NODE_VERSION=23.6.0
|
|
ARG YARN_VERSION=1.22.22
|
|
ENV PATH=/usr/local/node/bin:$PATH
|
|
RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz -C /tmp/ && \
|
|
/tmp/node-build-master/bin/node-build "${NODE_VERSION}" /usr/local/node && \
|
|
npm install -g yarn@$YARN_VERSION && \
|
|
rm -rf /tmp/node-build-master
|
|
|
|
# Rails app lives here
|
|
WORKDIR /rails
|
|
|
|
# Install application gems
|
|
COPY Gemfile Gemfile.lock ./
|
|
RUN bundle install && \
|
|
rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \
|
|
bundle exec bootsnap precompile --gemfile
|
|
|
|
# Install node modules
|
|
COPY package.json yarn.lock ./
|
|
RUN yarn install --frozen-lockfile
|
|
|
|
# Copy application code
|
|
COPY . .
|
|
|
|
# Precompile bootsnap code (skip asset precompilation for worker)
|
|
RUN bundle exec bootsnap precompile app/ lib/ && \
|
|
rm -rf node_modules
|
|
|
|
# Run and own only the runtime files as a non-root user for security
|
|
RUN groupadd --system --gid 1000 rails && \
|
|
useradd rails --uid 1000 --gid 1000 --create-home --shell /bin/bash && \
|
|
chown -R rails:rails db log storage tmp
|
|
USER 1000:1000
|
|
|
|
# Entrypoint prepares the database.
|
|
ENTRYPOINT ["/rails/bin/docker-entrypoint"]
|
|
|
|
# Start GoodJob worker
|
|
CMD ["bundle", "exec", "good_job", "start"]
|