fix(docker): skip demo seeds in production

This commit is contained in:
Daniel Schädler 2026-04-29 17:02:10 +02:00
parent 08cefb1ace
commit 7b8fc67593
3 changed files with 32 additions and 25 deletions

View File

@ -37,7 +37,6 @@ RUN apt-get update -qq \
libyaml-dev \
pkg-config \
python3 \
python3-pip \
&& rm -rf /var/lib/apt/lists/*
COPY Gemfile Gemfile.lock ./
@ -92,9 +91,8 @@ RUN apt-get update -qq \
&& apt-get install -y --no-install-recommends \
libsqlite3-0 \
python3 \
python3-pip \
&& rm -rf /var/lib/apt/lists/* \
&& python3 -m pip install --break-system-packages --no-cache-dir invoke
python3-invoke \
&& rm -rf /var/lib/apt/lists/*
COPY --from=bundle-test /usr/local/bundle /usr/local/bundle
COPY --from=bundle-test /app/vendor/bundle /app/vendor/bundle

View File

@ -36,6 +36,7 @@ module TurniereBackend
config.api_only = true
config.action_cable.disable_request_forgery_protection = true
config.action_cable.allowed_request_origins = [%r{\Ahttps?://.*\z}]
config.active_storage.variant_processor = :disabled
config.middleware.insert_before 0, Rack::Cors do
allow do

View File

@ -1,7 +1,13 @@
# frozen_string_literal: true
if Rails.env.production? && ENV.fetch('TURNIERE_ENABLE_DEMO_SEEDS', nil) != '1'
warn 'Skipping demo seeds in production. Set TURNIERE_ENABLE_DEMO_SEEDS=1 to force them.'
else
begin
require 'faker'
rescue LoadError
warn 'Skipping demo seeds because faker is unavailable.'
else
user = User.create! username: Faker::Internet.username, email: Faker::Internet.email, password: Faker::Internet.password
tournament = user.tournaments.create! name: Faker::Creature::Dog.name
@ -24,3 +30,5 @@ end
end
stage.save!
end
end
end