Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance docker bootstrap to also build webpack, email images #757

Merged
merged 1 commit into from
Sep 30, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions bin/dev/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@

set -e

function setup() {
local environment
environment="$1"

docker-compose -f docker/development/docker-compose.yml \
run --rm \
app bin/rails db:reset RAILS_ENV="${environment}"
function dc() {
docker-compose -f docker/development/docker-compose.yml run --rm "$@"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dc function in bin/dev/bootstrap uses the $@ variable which seems to work but is new to me; is this an approprate use? Are there any gotcha's with it?

The $@ basically means "All arguments expanded positionally" and seems entirely appropriate here.

The only gotcha I can think of is sometimes $@ can expand in unexpected ways depending on if it's contained in a set of "s - I don't remember all the rules on when / why this happens, but something about word boundaries and how IFS is set comes to mind. I don't think that should pose a problem here, though. Figured I'd drop a few of my go-to bash resources as they're a much more authoritative source than my old and forgetful brain:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking over this, and the bash links!

}

# start fresh
bin/dev/clean
setup development
setup test

# will create the app container, create both dev and test databases, and seed dev
dc app bin/rails db:reset

# only the test db needs to be explicitly seeded
dc app bin/rails db:seed RAILS_ENV=test

# build the image and make sure webpack can compile; don't start webpack-dev-server
dc webpacker bin/webpack

# build the image; don't start mailcatcher yet
dc email echo done!