-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #101 from nspcc-dev/feature/96-improve_makefile
Improve Makefile
- Loading branch information
Showing
4 changed files
with
41 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
|
||
# production | ||
/build | ||
/panel.fs.neo.org | ||
/output | ||
*output.json | ||
/release | ||
|
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,66 +1,53 @@ | ||
#!/usr/bin/make -f | ||
|
||
PORT = 3000 | ||
NODE_VERSION ?= 14 | ||
VERSION ?= "$(shell git describe --tags --match "v*" --abbrev=8 2>/dev/null | sed -r 's,^v([0-9]+\.[0-9]+)\.([0-9]+)(-.*)?$$,\1 \2 \3,' | while read mm patch suffix; do if [ -z "$$suffix" ]; then echo $$mm.$$patch; else patch=`expr $$patch + 1`; echo $$mm.$${patch}-pre$$suffix; fi; done)" | ||
SHELL = bash | ||
|
||
ifeq ($(shell uname), Linux) | ||
STAT:=-u $(shell stat -c "%u:%g" .) | ||
endif | ||
|
||
# Build and run optimized server. | ||
.PHONY: all | ||
all: build | ||
@npm install --location=local serve | ||
@./node_modules/.bin/serve -s output -p $(PORT) | ||
VERSION ?= "$(shell git describe --tags --match "v*" --abbrev=8 2>/dev/null | sed -r 's,^v([0-9]+\.[0-9]+)\.([0-9]+)(-.*)?$$,\1 \2 \3,' | while read mm patch suffix; do if [ -z "$$suffix" ]; then echo $$mm.$$patch; else patch=`expr $$patch + 1`; echo $$mm.$${patch}-pre$$suffix; fi; done)" | ||
SITE_DIR ?= panel.fs.neo.org | ||
RELEASE_DIR ?= $(SITE_DIR)-$(VERSION) | ||
RELEASE_PATH ?= $(SITE_DIR)-$(VERSION).tar.gz | ||
CURRENT_UID ?= $(shell id -u $$USER) | ||
|
||
# Run npm build. | ||
.PHONY: build | ||
build: clean install | ||
@npm run build | ||
PORT = 3000 | ||
|
||
# Run npm install. | ||
.PHONY: install | ||
install: | ||
@npm install | ||
$(SITE_DIR): | ||
docker run \ | ||
-v $$(pwd)/src:/usr/src/app/src \ | ||
-v $$(pwd)/public:/usr/src/app/public \ | ||
-v $$(pwd)/package.json:/usr/src/app/package.json \ | ||
-v $$(pwd)/.env:/usr/src/app/.env \ | ||
-v $$(pwd)/$(SITE_DIR):/usr/src/app/$(SITE_DIR) \ | ||
-e CURRENT_UID=$(CURRENT_UID) \ | ||
-w /usr/src/app node:14-alpine \ | ||
sh -c 'npm install && REACT_APP_VERSION=$(VERSION) npm run build && chown -R $$CURRENT_UID: $(SITE_DIR)' | ||
|
||
# Run npm start. | ||
.PHONY: start | ||
start: install | ||
@npm start | ||
|
||
# Run npm test. | ||
.PHONY: test | ||
test: | ||
@npm run test | ||
start: | ||
docker run \ | ||
-p $(PORT):3000 \ | ||
-v `pwd`:/usr/src/app \ | ||
-w /usr/src/app node:14-alpine \ | ||
sh -c 'npm install --silent && npm run build && npm install -g serve && serve -s $(SITE_DIR) -p 3000' | ||
|
||
# Create archive with build output. | ||
.PHONY: release | ||
release: build | ||
@rm -rf release | ||
@mkdir release | ||
@tar -czvf release/neofs-panel.tar.gz -C output . | ||
release: $(SITE_DIR) | ||
cp $(SITE_DIR)/index.html $(SITE_DIR)/agreement | ||
@ln -sf $(SITE_DIR) $(RELEASE_DIR) | ||
@tar cfvhz $(RELEASE_PATH) $(RELEASE_DIR) | ||
|
||
# Remove all produced artifacts. | ||
.PHONY: clean | ||
clean: | ||
@rm -rf release | ||
@rm -rf output | ||
@rm -rf node_modules | ||
@echo "Cleaning up ..." | ||
@rm -rf $(SITE_DIR) $(RELEASE_DIR) $(RELEASE_PATH) | ||
|
||
# Run `make %` in Golang container, for more information run `make help.docker/%` | ||
.PHONY: docker/% | ||
docker/%: | ||
@echo "=> Running 'make $*' in clean Docker environment" | ||
@docker run --rm -it \ | ||
--name panel_fs_neo_org \ | ||
-v `pwd`:/usr/src/app \ | ||
-p $(PORT):$(PORT) \ | ||
-w /usr/src/app \ | ||
$(STAT) \ | ||
node:$(NODE_VERSION) sh -c 'make $*' | ||
|
||
include help.mk | ||
.PHONY: release_name | ||
release_name: | ||
@echo $(RELEASE_PATH) | ||
|
||
.PHONY: version | ||
version: | ||
@echo $(VERSION) | ||
|
||
.PHONY: test | ||
test: | ||
@npm run test |
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 |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
"scripts": { | ||
"resolutions": "npx npm-force-resolutions && npm install -D [email protected]", | ||
"start": "REACT_APP_VERSION=$(make version) react-scripts start", | ||
"build": "BUILD_PATH='./output' react-scripts build", | ||
"build": "BUILD_PATH='./panel.fs.neo.org' react-scripts build", | ||
"test": "jest --updateSnapshot", | ||
"eject": "react-scripts eject" | ||
}, | ||
|