Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive
- name: Repository lampy
uses: actions/checkout@v2
with:
submodules: recursive
repository: koromerzhin/lampy
path: lampy
- name: Cache npm packages
id: npm-cache
uses: actions/cache@v2
Expand All @@ -21,10 +29,8 @@ jobs:
- name: Install npm dependencies
if: steps.npm-cache.outputs.cache-hit != 'true'
run: make node_modules
- name: 'Docker swarm init'
run: docker swarm init --default-addr-pool 10.20.0.0/16
- name: 'Create proxy network'
run: make docker create-network
- name: 'Launch Lampy'
run: make lampy
- name: 'Image pull'
run: make docker image-pull
- name: 'Build containers'
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "make"]
path = make
url = git@github.com:koromerzhin/make.git
148 changes: 14 additions & 134 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,146 +1,26 @@
isDocker := $(shell docker info > /dev/null 2>&1 && echo 1)

.DEFAULT_GOAL := help
include make/general/Makefile
STACK := expressjs
NETWORK := proxynetwork

WWW := $(WWW)_www
WWWFULLNAME := $(WWW).1.$$(docker service ps -f 'name=$(WWW)' $(WWW) -q --no-trunc | head -n1)
include make/docker/Makefile

SUPPORTED_COMMANDS := contributors docker logs git linter update inspect ssh sleep
SUPPORTED_COMMANDS := linter
SUPPORTS_MAKE_ARGS := $(findstring $(firstword $(MAKECMDGOALS)), $(SUPPORTED_COMMANDS))
ifneq "$(SUPPORTS_MAKE_ARGS)" ""
COMMAND_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
$(eval $(COMMAND_ARGS):;@:)
endif

help:
@grep -E '(^[a-zA-Z_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/'

.PHONY: isdocker
isdocker: ## Docker is launch
ifeq ($(isDocker), 0)
@echo "Docker is not launch"
exit 1
endif

node_modules:
@npm install

contributors: node_modules ## Contributors
ifeq ($(COMMAND_ARGS),add)
@npm run contributors add
else ifeq ($(COMMAND_ARGS),check)
@npm run contributors check
else ifeq ($(COMMAND_ARGS),generate)
@npm run contributors generate
else
@npm run contributors
endif

.PHONY: sleep
sleep: ## sleep
@sleep $(COMMAND_ARGS)

docker: isdocker ## Scripts docker
ifeq ($(COMMAND_ARGS),create-network)
@docker network create --driver=overlay $(NETWORK)
else ifeq ($(COMMAND_ARGS),image-pull)
@more docker-compose.yml | grep image: | sed -e "s/^.*image:[[:space:]]//" | while read i; do docker pull $$i; done
else ifeq ($(COMMAND_ARGS),deploy)
@docker stack deploy -c docker-compose.yml $(STACK)
else ifeq ($(COMMAND_ARGS),ls)
@docker stack services $(STACK)
else ifeq ($(COMMAND_ARGS),stop)
@docker stack rm $(STACK)
else
@echo "ARGUMENT missing"
@echo "---"
@echo "make docker ARGUMENT"
@echo "---"
@echo "create-network: create network"
@echo "image-pull: Get docker image"
@echo "deploy: deploy"
@echo "ls: docker service"
@echo "stop: docker stop"
endif

logs: isdocker ## Scripts logs
ifeq ($(COMMAND_ARGS),stack)
@docker service logs -f --tail 100 --raw $(STACK)
else ifeq ($(COMMAND_ARGS),www)
@docker service logs -f --tail 100 --raw $(WWWFULLNAME)
else
@echo "ARGUMENT missing"
@echo "---"
@echo "make logs ARGUMENT"
@echo "---"
@echo "stack: logs stack"
@echo "www: WWW"
COMMANDS_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
$(eval $(COMMANDS_ARGS):;@:)
endif

git: node_modules ## Scripts GIT
ifeq ($(COMMAND_ARGS),status)
@git status
else ifeq ($(COMMAND_ARGS),check)
@make contributors check -i
@make linter all -i
@make git status -i
else
@echo "ARGUMENT missing"
@echo "---"
@echo "make git ARGUMENT"
@echo "---"
@echo "check: CHECK before"
@echo "status: status"
endif

install: node_modules## Installation
install: node_modules ## Installation
@make docker deploy -i

linter: node_modules ## Scripts Linter
ifeq ($(COMMAND_ARGS),all)
linter: node_modules ### Scripts Linter
ifeq ($(COMMANDS_ARGS),all)
@make linter readme -i
else ifeq ($(COMMAND_ARGS),readme)
else ifeq ($(COMMANDS_ARGS),readme)
@npm run linter-markdown README.md
else
@echo "ARGUMENT missing"
@echo "---"
@echo "make linter ARGUMENT"
@echo "---"
@echo "all: ## Launch all linter"
@echo "readme: linter README.md"
endif

ssh: isdocker ## ssh
ifeq ($(COMMAND_ARGS),www)
@docker exec -it $(WWWFULLNAME) /bin/bash
else
@echo "ARGUMENT missing"
@echo "---"
@echo "make ssh ARGUMENT"
@echo "---"
@echo "www: WWW"
endif

inspect: isdocker ## inspect
ifeq ($(COMMAND_ARGS),www)
@docker service inspect $(WWW)
else
@echo "ARGUMENT missing"
@echo "---"
@echo "make inspect ARGUMENT"
@echo "---"
@echo "www: WWW"
endif

update: isdocker ## ssh
ifeq ($(COMMAND_ARGS),www)
@docker service update $(WWW)
else
@echo "ARGUMENT missing"
@echo "---"
@echo "make update ARGUMENT"
@echo "---"
@echo "www: WWW"
@printf "${MISSING_ARGUMENTS}" "linter"
$(call array_arguments, \
["all"]="Launch all linter" \
["readme"]="linter README.md" \
)
endif
12 changes: 6 additions & 6 deletions app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

version: "3.4"
networks:
proxynetwork:
proxylampy:
external: true
net:
driver: overlay
Expand All @@ -22,12 +22,10 @@ services:
volumes:
- ${PWD}/app:/app
networks:
- proxynetwork
- proxylampy
- net
deploy:
labels:
- "traefik.enable=true"
- "traefik.http.routers.expressjs.rule=Host(`expressjs.traefik.me`)"
- "traefik.http.routers.expressjs-tls.tls.domains[0].main=expressjs.traefik.me"
- "traefik.http.routers.expressjs-tls.tls.domains[0].sans=expressjs-*.traefik.me"
- "traefik.http.routers.expressjs.rule=HostRegexp(`expressjs.traefik.me`, `expressjs.{ip:.*}.traefik.me`)"
- "traefik.http.services.expressjs.loadbalancer.server.port=3000"
1 change: 1 addition & 0 deletions make
Submodule make added at 29bb2e
Loading