NB: Assumes OS X
The following commands are not tied to a particular repository.
-
Homebrew for managing software packages on OS X
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Note: if you are on a newer Mac you may be instructed to put this in your bash_profile:
eval "$(/opt/homebrew/bin/brew shellenv)"
If you have this line, make sure it is near the TOP of the file before any other if clauses from below
-
BA CLI for commands like
ba login
andba exec
. -
Install
direnv
and configure your shell to enable automatic environment variable loadingbrew install direnv
# in e.g. ~/.bash_profile if which direnv > /dev/null; then eval "$(direnv hook bash)" fi
- If you use zsh instead of bash, replace
direnv hook bash
withdirenv hook zsh
. See the hooks documentation page in the direnv GitHub repository for more details.
- If you use zsh instead of bash, replace
-
Install Postgres (we currently use v12)
- Note that you
brew link --force postgresql@12
because our version of postgresql is old and no longer the default inbrew
, and you want to set its respective old postgresql client libraries (e.g.psql
,pg_restore
) to be your default so that actions likebundle exec rake db:migrate
uses them. If you have other versions of these libraries installed via brew, and you later want them to go back to having them be your default, you will need tobrew link --force
them back into place.brew install postgresql@12 brew link --force postgresql@12 brew services start postgresql@12
- Create the
blueapron
postgres user used by all our servicescreateuser -s blueapron
- Note that you
-
Install Redis
brew install redis brew services start redis
-
Install a library for xml2
brew install libxml2
-
Install stuff needed for mimemagic
brew install shared-mime-info
-
Install or update
nodenv
(andnode-build
to get access to recent releases of node).brew update && brew install node-build nodenv brew update && brew upgrade node-build nodenv
-
Configure your shell to enable shims
# in e.g. ~/.bash_profile if which nodenv > /dev/null; then eval "$(nodenv init -)" fi
-
Install Node
nodenv install -s $(cat ./.node-version)
-
Install packages
npm install -g yarn nodenv rehash yarn
-
For ember projects You may need to do this per-repo that will be interacting with ember:
npm install -g ember-cli
-
Install or update
rbenv
(andruby-build
to get access to recent releases of ruby).brew update && brew install ruby-build rbenv brew update && brew upgrade ruby-build rbenv
-
Configure your shell to enable shims
# in e.g. ~/.bash_profile if which rbenv > /dev/null; then eval "$(rbenv init -)" fi
-
Install Ruby
rbenv install -s $(cat .ruby-version)
-
Install bundler
gem update --system gem install bundler
-
If on apple silicon, let bundler know, so you don't have problems like this with your
google-protobuf
andgrpc
gemsbundle config set force_ruby_platform true
-
Get the environment variables that bundler will need to install private gems
ba config get -r wms-server -b wms -e staging | grep BUNDLE
goba v8.0.6 ==> ba config get -r wms-server -b wms -e staging Using staging(blue) BUNDLE_ENTERPRISE__CONTRIBSYS__COM: SOME_CONTRIBSYS_TOKEN BUNDLE_GEM__FURY__IO: SOME_GEMFURY_TOKEN
-
Give bundler this information
bundle config --global gem.fury.io SOME_GEMFURY_TOKEN bundle config --global enterprise.contribsys.com SOME_CONTRIBSYS_TOKEN
-
Tell bundler where to find the library for xml2
bundle config --global build.libxml-ruby --with-xml2-config="$(brew --prefix libxml2)/bin/xml2-config"
-
Install gems
rbenv rehash bundle install
NB: Assumes a rails application.
To start with a fresh slate, run the following:
bundle exec rake db:drop db:setup
This will ...
- Drop your test and development databases.
- Reset them both according to the app's schema file (either
db/schema.rb
ordb/structure.sql
). - Seed your development database by running the
db/seeds.rb
script.
If the db/seeds.rb
file looks like an empty auto-generated file, then running it of course does nothing. If you think it would be helpful to have some data seeded in your development database, reach out to your teammates to learn how they do it, as it varies from app to app. But in short, you could either add some logic to this db/seeds.rb
file, or you could flash your database with a database dump file copied from staging. To do this, you will need to get a copy of a database dump. Go to jenkins, and look for the build pipeline for your application. Click it, and then look for a job named your-application-name-maintenance-job-db_dump_stage
(or *_production
). Click it, rerun it, and wait for it to finish. When it finishes, look at its console output. At the bottom will be a URL to an S3 bucket. Click it to download the dump. Once you have it, apply it to your database like so:
pg_restore --verbose --clean -j 4 --no-acl -O -U blueapron -h localhost -d YOUR_DATABASE_NAME YOUR_DUMPFILE_NAME
To know what your database name is, see the config/database.yml
file. It is probably your service name with a *_development
suffix.
Note that if you only intend to run the test suite, you don't need to bother with seeding data.
See this other guide.