diff --git a/Dockerfile b/Dockerfile index e5eda29..7f0d26b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,6 +7,7 @@ ARG base_commit=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa FROM ruby:${RUBY_VERSION}-slim AS runtime-base ARG BUNDLER_VERSION +ARG DEBIAN_FRONTEND=noninteractive ENV LANG=C.UTF-8 \ BUNDLE_JOBS=4 \ @@ -28,6 +29,8 @@ RUN apt-get update -qq \ FROM runtime-base AS build-base +ARG DEBIAN_FRONTEND=noninteractive + RUN apt-get update -qq \ && apt-get install -y --no-install-recommends \ build-essential \ @@ -37,7 +40,6 @@ RUN apt-get update -qq \ libyaml-dev \ pkg-config \ python3 \ - python3-pip \ && rm -rf /var/lib/apt/lists/* COPY Gemfile Gemfile.lock ./ @@ -84,6 +86,7 @@ CMD ["sh", "-lc", "bundle exec rails db:migrate && bundle exec rails s -p 3000 - FROM runtime-base AS test ARG base_commit=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +ARG DEBIAN_FRONTEND=noninteractive ENV RAILS_ENV=test \ GIT_COMMIT_SHA=${base_commit} @@ -92,9 +95,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 diff --git a/config/application.rb b/config/application.rb index e6e619b..dbdbb57 100644 --- a/config/application.rb +++ b/config/application.rb @@ -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 diff --git a/db/seeds.rb b/db/seeds.rb index a5ed829..9245444 100644 --- a/db/seeds.rb +++ b/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