Skip to content

Commit

Permalink
Add express server which runs Makefile targets
Browse files Browse the repository at this point in the history
  • Loading branch information
expelledboy committed Feb 26, 2020
1 parent 42a0ad4 commit b683565
Show file tree
Hide file tree
Showing 8 changed files with 3,675 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# EditorConfig is awesome: http://EditorConfig.org

root = true

[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.{json,js,html,css,yml}]
indent_style = space
indent_size = 2
15 changes: 15 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": ["airbnb-base", "plugin:prettier/recommended"],
"env": {
"node": true,
"es6": true,
"jest": true
},
"parserOptions": {
"ecmaVersion": 2018
},
"rules": {
"no-console": "off",
"no-underscore-dangle": "off"
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM alpine:3.9 as build

RUN apk add --no-cache make nodejs npm

WORKDIR /root
COPY package*.json ./
RUN npm install

COPY src /root/src
EXPOSE 3000
CMD ["npm", "start"]
49 changes: 49 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
REGISTRY_HOST = docker.io
USERNAME = expelledboy
NAME = $(shell basename $(CURDIR))
IMAGE = $(REGISTRY_HOST)/$(USERNAME)/$(NAME)

.EXPORT_ALL_VARIABLES:
.DEFAULT: help

## ==
.PHONY: help build lint unit test clean

help: ## Print help messages
@sed -n 's/^\([a-zA-Z_-]*\):.*## \(.*\)$$/\1 -- \2/p' Makefile

build: ## Build docker image
docker build -t $(IMAGE) .

test: ## Run simple unit test
docker run -d --rm \
--name $(NAME) \
-v $(PWD):/webhook/ \
-p 3000:3000 \
$(IMAGE)
sleep 5
-curl http://localhost:3000/help
docker stop $(NAME)

# ==
.PHONY: on-tag bump publish

on-tag:
@git describe --exact-match --tags $$(git log -n1 --pretty='%h')

bump-package: IMPACT = patch
bump-package:
npm version $(IMPACT)

bump: VERSION = $(shell node -p "require('./package.json').version")
bump: bump-package ## Bump release version eg. `make IMPACT=patch bump`
git add package.json
git commit -m 'Release version $(VERSION)'
git tag $(VERSION)

publish: VERSION = $(shell git describe --always)
publish: on-tag build ## Push docker image to $(REGISTRY_HOST)
echo docker push $(IMAGE):$(VERSION)
echo docker push $(IMAGE):latest

# ==
Loading

0 comments on commit b683565

Please sign in to comment.