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 \
|
libyaml-dev \
|
||||||
pkg-config \
|
pkg-config \
|
||||||
python3 \
|
python3 \
|
||||||
python3-pip \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
COPY Gemfile Gemfile.lock ./
|
COPY Gemfile Gemfile.lock ./
|
||||||
|
|
@ -92,9 +91,8 @@ RUN apt-get update -qq \
|
||||||
&& apt-get install -y --no-install-recommends \
|
&& apt-get install -y --no-install-recommends \
|
||||||
libsqlite3-0 \
|
libsqlite3-0 \
|
||||||
python3 \
|
python3 \
|
||||||
python3-pip \
|
python3-invoke \
|
||||||
&& rm -rf /var/lib/apt/lists/* \
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
&& python3 -m pip install --break-system-packages --no-cache-dir invoke
|
|
||||||
|
|
||||||
COPY --from=bundle-test /usr/local/bundle /usr/local/bundle
|
COPY --from=bundle-test /usr/local/bundle /usr/local/bundle
|
||||||
COPY --from=bundle-test /app/vendor/bundle /app/vendor/bundle
|
COPY --from=bundle-test /app/vendor/bundle /app/vendor/bundle
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ module TurniereBackend
|
||||||
config.api_only = true
|
config.api_only = true
|
||||||
config.action_cable.disable_request_forgery_protection = true
|
config.action_cable.disable_request_forgery_protection = true
|
||||||
config.action_cable.allowed_request_origins = [%r{\Ahttps?://.*\z}]
|
config.action_cable.allowed_request_origins = [%r{\Ahttps?://.*\z}]
|
||||||
|
config.active_storage.variant_processor = :disabled
|
||||||
|
|
||||||
config.middleware.insert_before 0, Rack::Cors do
|
config.middleware.insert_before 0, Rack::Cors do
|
||||||
allow do
|
allow do
|
||||||
|
|
|
||||||
50
db/seeds.rb
50
db/seeds.rb
|
|
@ -1,26 +1,34 @@
|
||||||
# frozen_string_literal: true
|
# 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
|
@teams = []
|
||||||
tournament = user.tournaments.create! name: Faker::Creature::Dog.name
|
16.times do
|
||||||
|
team = tournament.teams.create! name: Faker::Movies::HarryPotter.character
|
||||||
@teams = []
|
@teams << team
|
||||||
16.times do
|
end
|
||||||
team = tournament.teams.create! name: Faker::Movies::HarryPotter.character
|
4.times do |i|
|
||||||
@teams << team
|
stage = tournament.stages.create!
|
||||||
end
|
stage.level = i
|
||||||
4.times do |i|
|
matches_amount = 2**i
|
||||||
stage = tournament.stages.create!
|
matches_amount.times do |j|
|
||||||
stage.level = i
|
match = stage.matches.create!
|
||||||
matches_amount = 2**i
|
match.match_scores.create! team: @teams.sample, points: rand(10)
|
||||||
matches_amount.times do |j|
|
match.match_scores.create! team: @teams.sample, points: rand(10)
|
||||||
match = stage.matches.create!
|
match.position = j
|
||||||
match.match_scores.create! team: @teams.sample, points: rand(10)
|
match.state = rand(5)
|
||||||
match.match_scores.create! team: @teams.sample, points: rand(10)
|
match.save!
|
||||||
match.position = j
|
end
|
||||||
match.state = rand(5)
|
stage.save!
|
||||||
match.save!
|
end
|
||||||
end
|
end
|
||||||
stage.save!
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue