-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
89 lines (66 loc) · 2.72 KB
/
Copy pathMakefile
File metadata and controls
89 lines (66 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# Makefile for asset-monitoring
#
# Mirrors the Rakefile. Run `make` or `make help` to see available commands.
SHELL := /bin/bash
.SHELLFLAGS := -eu -o pipefail -c
APP_HOST ?= 0.0.0.0
APP_PORT ?= 8080
CONTAINERFILE ?= Containerfile
IMAGE ?= quay.io/dkirwan/asset-monitoring:latest
BUILD_IMAGE ?= quay.io/dkirwan/asset-monitoring:dev
ifneq ($(filter true 1 yes,$(USE_DEV_IMAGE)),)
RUN_IMAGE := $(BUILD_IMAGE)
else
RUN_IMAGE := $(IMAGE)
endif
DATA_DIR ?= $(CURDIR)/data
CONTAINER_DATA_DIR ?= /data
PRICE_HISTORY_DB_PATH ?= $(CONTAINER_DATA_DIR)/asset_history.db
PORTFOLIO_DB_PATH ?= $(CONTAINER_DATA_DIR)/portfolio.db
PRICE_HISTORY_RETENTION_DAYS ?= 365
BUNDLE ?= bundle
BUNDLE_EXEC ?= $(BUNDLE) exec
RACKUP := $(BUNDLE_EXEC) rackup config.ru --host $(APP_HOST) -p $(APP_PORT)
# RVM binstubs call ruby_executable_hooks; keep GEM_HOME/bin on PATH for make recipes.
export PATH := $(shell ruby -e 'paths=[]; paths << File.join(ENV["GEM_HOME"], "bin") if ENV["GEM_HOME"]; print paths.join(":") + (paths.empty? ? "" : ":")'):$(PATH)
.PHONY: help install server dev console \
spec test rubocop lint check coverage \
security audit brakeman \
podman-build podman-run podman_build podman_run
.DEFAULT_GOAL := help
help: ## Display available commands
@cat tasks/help.txt
install: ## Install dependencies via Bundler
$(BUNDLE) install
server: ## Start the application server
$(RACKUP)
dev: ## Start the application server with auto-reload (development)
$(BUNDLE_EXEC) rerun -- $(RACKUP)
console: ## Start an interactive Pry console with the app loaded
METRICS_SCHEDULER_DISABLED=1 $(BUNDLE_EXEC) pry -Ilib -r asset_monitoring
spec: ## Run RSpec tests
$(BUNDLE_EXEC) rspec
test: spec ## Alias for spec
rubocop: ## Run RuboCop linter
$(BUNDLE_EXEC) rubocop
lint: rubocop ## Alias for rubocop
check: rubocop spec ## Run all checks (rubocop + specs)
coverage: ## Run tests with coverage report
COVERAGE=true $(BUNDLE_EXEC) rspec
audit: ## Run Bundler audit
$(BUNDLE_EXEC) bundle-audit check --update
brakeman: ## Run Brakeman
$(BUNDLE_EXEC) brakeman --no-pager
security: audit brakeman ## Run security checks (bundle-audit + brakeman)
podman-build: ## Build the container image as quay.io/dkirwan/asset-monitoring:dev
podman build -t $(BUILD_IMAGE) -f $(CONTAINERFILE) .
podman-run: ## Run the container (SQLite in ./data bind-mounted to /data)
@mkdir -p $(DATA_DIR)
podman run --rm -p $(APP_PORT):$(APP_PORT) \
-e PRICE_HISTORY_RETENTION_DAYS=$(PRICE_HISTORY_RETENTION_DAYS) \
-e PRICE_HISTORY_DB_PATH=$(PRICE_HISTORY_DB_PATH) \
-e PORTFOLIO_DB_PATH=$(PORTFOLIO_DB_PATH) \
-v $(DATA_DIR):$(CONTAINER_DATA_DIR):Z,U \
$(RUN_IMAGE)
podman_build: podman-build ## Alias for podman-build
podman_run: podman-run ## Alias for podman-run