fix(docker): skip demo seeds in production
This commit is contained in:
parent
08cefb1ace
commit
7b8fc67593
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
50
db/seeds.rb
50
db/seeds.rb
|
|
@ -1,26 +1,34 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'faker'
|
||||
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
|
||||
|
||||
user = User.create! username: Faker::Internet.username, email: Faker::Internet.email, password: Faker::Internet.password
|
||||
tournament = user.tournaments.create! name: Faker::Creature::Dog.name
|
||||
|
||||
@teams = []
|
||||
16.times do
|
||||
team = tournament.teams.create! name: Faker::Movies::HarryPotter.character
|
||||
@teams << team
|
||||
end
|
||||
4.times do |i|
|
||||
stage = tournament.stages.create!
|
||||
stage.level = i
|
||||
matches_amount = 2**i
|
||||
matches_amount.times do |j|
|
||||
match = stage.matches.create!
|
||||
match.match_scores.create! team: @teams.sample, points: rand(10)
|
||||
match.match_scores.create! team: @teams.sample, points: rand(10)
|
||||
match.position = j
|
||||
match.state = rand(5)
|
||||
match.save!
|
||||
@teams = []
|
||||
16.times do
|
||||
team = tournament.teams.create! name: Faker::Movies::HarryPotter.character
|
||||
@teams << team
|
||||
end
|
||||
4.times do |i|
|
||||
stage = tournament.stages.create!
|
||||
stage.level = i
|
||||
matches_amount = 2**i
|
||||
matches_amount.times do |j|
|
||||
match = stage.matches.create!
|
||||
match.match_scores.create! team: @teams.sample, points: rand(10)
|
||||
match.match_scores.create! team: @teams.sample, points: rand(10)
|
||||
match.position = j
|
||||
match.state = rand(5)
|
||||
match.save!
|
||||
end
|
||||
stage.save!
|
||||
end
|
||||
end
|
||||
stage.save!
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue