This repository has been archived by the owner on Oct 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix development/test environment workflow using Make and Docker
- Loading branch information
Showing
5 changed files
with
49 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
FROM elixir:1.5.1 | ||
ENV DEBIAN_FRONTEND="noninteractive" | ||
|
||
RUN mkdir -p /usr/src/app | ||
WORKDIR /usr/src/app | ||
|
||
COPY ./mix.* /usr/src/app/ | ||
RUN yes | mix do deps.get \ | ||
&& yes | MIX_ENV=test mix do deps.get, deps.compile | ||
COPY mix.exs mix.lock /usr/src/app/ | ||
COPY config /usr/src/app/config | ||
RUN mix local.hex --force \ | ||
&& mix local.rebar --force \ | ||
&& mix deps.get \ | ||
&& mix deps.compile | ||
|
||
COPY . /usr/src/app | ||
CMD ["elixir"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,41 @@ | ||
.DEFAULT_GOAL:=test | ||
.PHONY: run bash test tail-mqtt tail-mqtt-tls stop prune | ||
.DEFAULT_GOAL:=help | ||
SHELL:=/bin/bash | ||
|
||
RUN_SERVICE:=hulaaki | ||
HULAAKI_SERVICE:=hulaaki | ||
MQTT_SERVICE:=mqtt_server | ||
|
||
run: | ||
$(if $(CMD), docker-compose run --rm $(RUN_SERVICE) $(CMD), $(error -- CMD must be set)) | ||
DOCKER_COMPOSE:=docker-compose -f docker-compose.yml | ||
DOCKER_COMPOSE_RUN_HULAAKI:=$(DOCKER_COMPOSE) run --rm $(HULAAKI_SERVICE) | ||
|
||
bash: CMD=/bin/bash | ||
bash: run | ||
.PHONY: help build start stop stop-clean tail-logs run-hulaaki bash test prune | ||
|
||
test: CMD=mix test | ||
test: run | ||
help: ## Display this help | ||
$(info) | ||
@awk 'BEGIN {FS = ":.*##"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST) | ||
|
||
build: ## (Force) Build the docker images (automatically run by `make start`) | ||
$(DOCKER_COMPOSE) build | ||
|
||
start: build ## Start the MQTT service container daemonised | ||
$(DOCKER_COMPOSE) up -d $(MQTT_SERVICE) | ||
|
||
stop: ## Stop all the service containers | ||
$(DOCKER_COMPOSE) down | ||
|
||
start: | ||
docker-compose up -d $(MQTT_SERVICE) | ||
stop-clean: ## Stop all the service containers, cleanup project images, dangling/orphaned volumes | ||
$(DOCKER_COMPOSE) down --rmi local --volumes --remove-orphans | ||
|
||
tail-logs: | ||
docker-compose logs -f $(MQTT_SERVICE) | ||
tail-logs: ## Tail the logs for MQTT service container | ||
$(DOCKER_COMPOSE) logs -f $(MQTT_SERVICE) | ||
|
||
run-hulaaki: ## Run a one-off command in a new hulaaki service container. Specify using CMD (eg. make run-web CMD=mix test) | ||
$(if $(CMD), $(DOCKER_COMPOSE_RUN_HULAAKI) $(CMD), $(error -- CMD must be set)) | ||
|
||
bash: CMD=/bin/bash | ||
bash: run-hulaaki ## Spawn a bash shell for hulaaki service | ||
|
||
test: CMD=mix test | ||
test: run-hulaaki ## Run the test for hulaaki service | ||
|
||
stop: | ||
docker-compose down | ||
docker system prune -f | ||
prune: ## Cleanup dangling/orphaned docker resources globally | ||
docker system prune --volumes -f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters