Merge branch 'codex/tur-130-production-seed-faker' into 'master'
fix(docker): skip demo seeds in production See merge request turniere/turniere-backend!71
This commit is contained in:
commit
0141d78e4e
10
Dockerfile
10
Dockerfile
|
|
@ -7,6 +7,7 @@ ARG base_commit=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||||
FROM ruby:${RUBY_VERSION}-slim AS runtime-base
|
FROM ruby:${RUBY_VERSION}-slim AS runtime-base
|
||||||
|
|
||||||
ARG BUNDLER_VERSION
|
ARG BUNDLER_VERSION
|
||||||
|
ARG DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
ENV LANG=C.UTF-8 \
|
ENV LANG=C.UTF-8 \
|
||||||
BUNDLE_JOBS=4 \
|
BUNDLE_JOBS=4 \
|
||||||
|
|
@ -28,6 +29,8 @@ RUN apt-get update -qq \
|
||||||
|
|
||||||
FROM runtime-base AS build-base
|
FROM runtime-base AS build-base
|
||||||
|
|
||||||
|
ARG DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
RUN apt-get update -qq \
|
RUN apt-get update -qq \
|
||||||
&& apt-get install -y --no-install-recommends \
|
&& apt-get install -y --no-install-recommends \
|
||||||
build-essential \
|
build-essential \
|
||||||
|
|
@ -37,7 +40,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 ./
|
||||||
|
|
@ -84,6 +86,7 @@ CMD ["sh", "-lc", "bundle exec rails db:migrate && bundle exec rails s -p 3000 -
|
||||||
FROM runtime-base AS test
|
FROM runtime-base AS test
|
||||||
|
|
||||||
ARG base_commit=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
ARG base_commit=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||||
|
ARG DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
ENV RAILS_ENV=test \
|
ENV RAILS_ENV=test \
|
||||||
GIT_COMMIT_SHA=${base_commit}
|
GIT_COMMIT_SHA=${base_commit}
|
||||||
|
|
@ -92,9 +95,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
|
||||||
|
|
|
||||||
10
db/seeds.rb
10
db/seeds.rb
|
|
@ -1,7 +1,13 @@
|
||||||
# frozen_string_literal: true
|
# 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'
|
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
|
user = User.create! username: Faker::Internet.username, email: Faker::Internet.email, password: Faker::Internet.password
|
||||||
tournament = user.tournaments.create! name: Faker::Creature::Dog.name
|
tournament = user.tournaments.create! name: Faker::Creature::Dog.name
|
||||||
|
|
||||||
|
|
@ -24,3 +30,5 @@ end
|
||||||
end
|
end
|
||||||
stage.save!
|
stage.save!
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue