Add support for transparently running the node commands through Docker as if they were local

This makes it much easier to run the node CLI commands like `feathers` or `sequalize`.

Just changing into the services/ directory and running `source activate` will
set up the environment
This commit is contained in:
R. Tyler Croy 2018-07-17 09:21:23 -07:00
parent 9bbd1364f1
commit c34e33e05b
No known key found for this signature in database
GPG Key ID: 1426C7DC3F51E16F
4 changed files with 13 additions and 6 deletions

View File

@ -1,4 +1,4 @@
NODE:=../tools/node
PATH:=./node_modules/.bin:../tools:$(PATH)
COMPOSE:=../tools/compose
IMAGE_NAME:=jenkinsciinfra/evergreen-backend
DB_DUMP=initdb.d/db.sql
@ -13,10 +13,10 @@ check: depends lint migrate
fi;
lint: depends
$(NODE) npm run eslint
npm run eslint
fix-formatting:
$(NODE) npm run eslint -- --fix
npm run eslint -- --fix
unit:
$(COMPOSE) run -e NODE_ENV=test -e ERROR_LOGGING_FILE=/srv/evergreen/error-logging.json --rm node npm run jest
@ -39,7 +39,7 @@ depends: package.json
# Checking to see if the directory exists because npm install updates the
# directory every time it runs, busting the GNU/Make cache causing rebuilds
@if [ ! -d node_modules ]; then \
$(NODE) npm install; \
npm install; \
fi;
docs: depends
@ -86,7 +86,7 @@ container-migration: Dockerfile.migrations
ingest-update-center: essentials.yaml ingest-update-center
wget -O update-center.json https://updates.jenkins.io/update-center.actual.json
$(NODE) node ./ingest-update-center
node ./ingest-update-center
clean:
$(COMPOSE) down || true

3
services/activate Normal file
View File

@ -0,0 +1,3 @@
#!/bin/sh
export PATH=./node_modules/.bin:${PWD}/../tools:${PATH}

View File

@ -13,7 +13,8 @@ exec docker run --net host --rm ${TTY_ARGS} \
--mount type=tmpfs,destination=/.npm \
--mount type=tmpfs,destination=/.config \
-v ${PWD}:${PWD} \
-e PATH=$PWD/node_modules/.bin:$PATH \
-e PATH=$PWD/node_modules/.bin:/usr/local/bin:$PATH \
-e LANG=C.UTF-8 \
$(printenv | grep -i \^evergreen | awk '{ print "-e", $1 }') \
$(printenv | grep -i \^node | awk '{ print "-e", $1 }') \
${PORTS} node:9 $@

3
tools/npm Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
exec $(dirname $0)/node npm $@