Skip to content
This repository was archived by the owner on Dec 3, 2019. It is now read-only.
Open
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
21 changes: 12 additions & 9 deletions Makefile
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,27 +3,27 @@ DOCKER := docker
DOCKER_COMPOSE := docker-compose

.PHONY: all
all: run
all: run

.PHONY: nuke
nuke:
nuke:
${DOCKER} system prune -a --volumes

.PHONY: minty-fresh
minty-fresh:
.PHONY: minty-fresh
minty-fresh:
${DOCKER_COMPOSE} down --rmi all --volumes

.PHONY: rmi
rmi:
rmi:
${DOCKER} images -q | xargs docker rmi -f

.PHONY: rmdi
rmdi:
rmdi:
${DOCKER} images -a --filter=dangling=true -q | xargs ${DOCKER} rmi

.PHONY: rm-exited-containers
rm-exited-containers:
${DOCKER} ps -a -q -f status=exited | xargs ${DOCKER} rm -v
rm-exited-containers:
${DOCKER} ps -a -q -f status=exited | xargs ${DOCKER} rm -v

.PHONY: fresh-restart
fresh-restart: minty-fresh setup test run
Expand DownExpand Up@@ -95,7 +95,10 @@ bundle:

setup: build db_create db_migrate

publish: build
migrate_if_needed:
bash -c 'if docker-compose run ${RAILS_CONTAINER} rake db:migrate:status | grep "^\s*down"; then docker-compose run ${RAILS_CONTAINER} rake db:migrate; fi'

@robbkiddrobbkiddOct 23, 2018

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I recently discovered the db:abort_if_pending_migrations task which pretty much does what it says: exits the rake execution with an error if there are pending migrations.

> rake db:db:abort_if_pending_migrations
You have 10 pending migrations:
20180129223616 AddGroupToTeamMembers
20180204235116 AddMoocToCodeSchools
20180401034441 CreateRoles
20180408172532 AddRoleIdToAdminUser
20180416024105 AddEmailToTeamMember
20180420192231 AddIsPartnerToCodeSchools
20180422030623 CreateSlackUser
20180422031009 DropUserSlackId
20180430161218 AddRepNameToCodeschool
20180711212702 AddMilitarystatusToUser
Run `rails db:migrate` to update your database then try again.
> echo $?
1

And now that I know about it, of course I want to use it! What do you think about this?

migrate_if_needed:
bash -c 'docker-compose run ${RAILS_CONTAINER} rake db:abort_if_pending_migrations || docker-compose run ${RAILS_CONTAINER} rake db:migrate'


publish: build migrate_if_needed
bin/publish

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🤔 I'm not super familiar with the deployed production environment. Looking at the bin/publish script has me thinking that this wiring up of a migrate_if_needed action prior to publish would have the migrations occur in an environment that is not production, but rather in a development or CI environment that is doing Docker image tagging and kubernetes service poking.

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

Gotcha. I thought maybe the docker container that build was run on would then be promoted to production.

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

If there's someone who could walk me through/explain, I would love to write up documentation.


upgrade: publish
Expand Down