I've got the following Makefile:
.PHONY: install install-prod clean
MODULE := ./node_modules/.bin
COMPOSE := docker-compose -f docker-compose.yml
install:
@echo "--- Installing dependencies!"
npm install
install-prod:
@echo "--- Installing production dependencies!"
npm install --only=production
build:
@echo "--- Babelify-ing code!"
npm run build
run:
@echo "--- Building Docker and running app!"
${COMPOSE} up --build -d app
test:
@echo "--- Running tests"
npm run test
coverall:
@echo "--- Running tests & reporting to Coverall!"
npm run coverall
clear:
@echo "--- Clearing everything!"
${COMPOSE} down
It's a simple one, but in essence, it wraps commands in a package.json
and a docker-compose.yml
for an express
app so it makes calls in a CI Pipeline
easier to understand and maintain.
I would love some feedback about whether it can be optimized, cleaner, or potentially smaller. Anything really.
1 Answer 1
It is good that you specify a .PHONY
target. For consistency, it is a good practice to add all of the targets to the .PHONY
list since none of them refers to a file. For example, like the install
target does not create a file named install
, the build
target does not create a file named build
. This means build
should be added to the .PHONY
list along with install
.
Since the Makefile does not use the MODULE
variable, you can delete the line:
MODULE := ./node_modules/.bin