nexus_seed
Common rails application seeding logic.
Seed development
See SEED_BUILDER documentation.
Running
Running tasks on deploy
Task files must be placed in /lib/tasks/seed_#{name}.rake
Set task name in helm values e.g. for a common
seed task:
helm:
values:
rails:
seedTasks:
- common
Configure the post deploy hook in devspace.yaml
and set COMPONENT
appropriately:
hooks:
- name: post-deploy-seed-task-hook
events: [ "after:deploy" ]
command: |-
docker run --rm --pull always registry.nexusmods.com/nexus-mods/devops/tools/seed_task_start:stable cat seed_task_start.sh |
NAMESPACE=${devspace.namespace} COMPONENT=api bash
Running tasks manually
Run common
seed task with default options:
bundle exec rake seed_common:run
Options are [:retry_limit, :sleep_interval]
E.g. to retry 100 times every 3 seconds:
bundle exec rake seed_common:run[100,3]
Removing seeded data
Use NEXUS_SEED_DESTROY
env var to locate seeded data and remove it.
Especially useful when developing seeds, run with destroy and then run again without.
NEXUS_SEED_DESTROY=true bundle exec rake seed_common:run
Local gem development
Steps to run this gem from local sources in one the nexus 'staged build' rails components:
Copy gem sources to component
cd ~/nexus-api
cp -r ../nexus_seed .
Adjust component Dockerfile to include gem sources
Within stage 1, append a COPY after the Gemfile copy:
COPY --chown=nexus:nexus Gemfile* ./
COPY --chown=nexus:nexus nexus_seed/ ./nexus_seed/
Within stage 2, append a COPY after the bundle copy:
COPY --from=stage1 /usr/local/bundle /usr/local/bundle
COPY --from=stage1 /app/nexus_seed/ /app/nexus_seed/
Adjust Gemfile to use local path
gem 'nexus_seed', :path => "/app/nexus_seed"