diff --git a/.env b/.env index fa2d9cfe8..7b7487450 100644 --- a/.env +++ b/.env @@ -1,2 +1,3 @@ STATIC_FOLDER=themes/basic/static -TEMPLATE_FOLDER=themes/basic/templates \ No newline at end of file +TEMPLATE_FOLDER=themes/basic/templates +NPM_REGISTRY= \ No newline at end of file diff --git a/Makefile b/Makefile index aa191a913..c9a2ccd11 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,7 @@ RESET := $(shell tput -Txterm sgr0) THEME?=basic STATIC_FOLDER?=themes\/${THEME}\/static TEMPLATE_FOLDER?=themes\/${THEME}\/templates +NPM_REGISTRY?=registry.npmjs.org SYSTEM=$(shell uname) ifeq ($(SYSTEM), Darwin) SED = sed -ix @@ -18,6 +19,22 @@ else SED = sed -i endif +ifeq (${THEME}, react) + ifneq ($(wildcard ./src/themes/react/static/node_modules),) + INSTALL_NPM= + else + INSTALL_NPM=npm-install + endif + ifneq ($(wildcard ./src/themes/react/static/js/dist),) + BUILD_JS= + else + BUILD_JS=build-js + endif + START_OPTIONS = initial-env $(INSTALL_NPM) $(BUILD_JS) +else + START_OPTIONS = initial-env +endif + .PHONY: \ all \ check \ @@ -53,9 +70,10 @@ redeploy: ##@Service Redeploy single service, Use like "make redeploy service=da initial-env: ##@Configuration Initial Configuration for dashboard $(SED) 's/\(STATIC_FOLDER=\).*/\1${STATIC_FOLDER}/' .env $(SED) 's/\(TEMPLATE_FOLDER=\).*/\1${TEMPLATE_FOLDER}/' .env + $(SED) 's/\(NPM_REGISTRY=\).*/\1${NPM_REGISTRY}/' .env start: ##@Service Start service - @$(MAKE) initial-env + @$(MAKE) $(START_OPTIONS) bash scripts/start.sh stop: ##@Service Stop service diff --git a/docker-compose-build-js.yml b/docker-compose-build-js.yml index 821b5c839..cd9d072e1 100644 --- a/docker-compose-build-js.yml +++ b/docker-compose-build-js.yml @@ -18,4 +18,4 @@ services: container_name: build-js volumes: # This should be removed in product env - ./src/themes/react/static:/app - command: bash -c "cd /app && npm run build" + command: bash -c "cd /app && npm run build && rm -rf *.json.gz" diff --git a/docker-compose-npm-install.yml b/docker-compose-npm-install.yml index e317a5214..72b6438c3 100644 --- a/docker-compose-npm-install.yml +++ b/docker-compose-npm-install.yml @@ -18,4 +18,6 @@ services: container_name: npm-install volumes: # This should be removed in product env - ./src/themes/react/static:/app - command: bash -c "cd /app && npm install --loglevel http" + environment: + - NPM_REGISTRY=$NPM_REGISTRY + command: bash -c "cd /app && npm install --loglevel http --registry https://$NPM_REGISTRY"