Skip to content

Commit

Permalink
Unify make bldr-run Makefile target to work on native Linux & Mac.
Browse files Browse the repository at this point in the history
This change brings the 2 Procfiles into one version that should work
under most circumstances under Linux and Mac. The notable exception is
for systems that already have a `redis-server` process running, such as
a Homebrew-installed package on macOS or a system-installed package on
Ubuntu for example.

The 2 remaining Makefile targets are:

* `bldr-run` - which launches the Builder services necessary for
  developing against. By default on the Mac this will run in a devshell
  using Docker and will be run natively on Linux without Docker.
* `bldr-shell` - which launches a devshell (i.e. a Docker container)
  with forwarded ports but doesn't run any of the services

As the `BUILDING.md` instructions describe how to work natively on Mac
(i.e. not using Docker but targeting macOS directly), you can set
`export IN_DOCKER=false` for `make bldr-run` to compile and run on the
Mac.

The driving user feature for this change was to be able to run `make
bldr-run` on a Linux host without needing to resort to the same
bind mount/Docker overhead which slows down the development cycle.

Signed-off-by: Fletcher Nichol <fnichol@nichol.ca>
  • Loading branch information
fnichol committed Jan 5, 2017
1 parent 4f0b3a2 commit d7b7919
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 29 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,4 +1,5 @@
.DS_Store
dump.rdb
target
terraform.tfstate*
.delivery/cli.toml
Expand Down
37 changes: 15 additions & 22 deletions Makefile
@@ -1,4 +1,9 @@
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
forego := support/mac/bin/forego
else
forego := support/linux/bin/forego
endif
ifneq (${IN_DOCKER},)
IN_DOCKER := ${IN_DOCKER}
else ifeq ($(UNAME_S),Darwin)
Expand All @@ -25,8 +30,10 @@ ifeq ($(IN_DOCKER),true)
run := $(common_run) shell
bldr_run := $(common_run) -p 9636:9636 -p 8080:8080 shell
docs_run := $(common_run) -p 9633:9633 shell
forego := support/linux/bin/forego
else
run :=
bldr_run :=
docs_run :=
endif
ifneq ($(DOCKER_HOST),)
Expand All @@ -43,9 +50,6 @@ VERSION := $(shell cat VERSION)

.DEFAULT_GOAL := build-bin

bldr-build: $(addprefix bldr-build-,$(SRV))
.PHONY: bldr-build

build: build-bin build-lib build-srv ## builds all the components
build-all: build
.PHONY: build build-all
Expand Down Expand Up @@ -107,6 +111,14 @@ shell: image ## launches a development shell
$(run)
.PHONY: shell

bldr-shell: build-srv ## launches a development shell with forwarded ports but doesn't run anything
$(bldr_run)
.PHONY: bldr-shell

bldr-run: build-srv ## launches a development shell running the API
$(bldr_run) sh -c '$(forego) start -f support/Procfile -e support/bldr.env'
.PHONY: bldr-run

serve-docs: docs ## serves the project documentation from an HTTP server
@echo "==> View the docs at:\n\n http://`\
echo $(docs_host) | sed -e 's|^tcp://||' -e 's|:[0-9]\{1,\}$$||'`:9633/\n\n"
Expand Down Expand Up @@ -162,25 +174,6 @@ build-$1: image ## builds the $1 component
endef
$(foreach component,$(ALL),$(eval $(call BUILD,$(component))))

define BLDR_BUILD
bldr-build-$1: image ## builds the $1 component
cd components/$1 && cargo build
.PHONY: bldr-build-$1

endef
$(foreach component,$(ALL),$(eval $(call BLDR_BUILD,$(component))))

bldr-run: bldr-build
support/mac/bin/forego start -f support/Procfile.mac -e support/bldr.env

bldr-shell: build-srv ## launches a development shell with forwarded ports but doesn't run anything
$(bldr_run)
.PHONY: bldr-shell

bldr-run-shell: build-srv ## launches a development shell running the API
$(bldr_run) sh -c '/src/support/linux/bin/forego start -f support/Procfile.linux -e support/bldr.env'
.PHONY: bldr-run-shell

define UNIT
unit-$1: image ## executes the $1 component's unit test suite
$(run) sh -c 'cd components/$1 && cargo test'
Expand Down
File renamed without changes.
7 changes: 0 additions & 7 deletions support/Procfile.mac

This file was deleted.

0 comments on commit d7b7919

Please sign in to comment.