Node Express demo project
Developers testing Nexus3 repository manager start here:
Use .env.template to create a local .env file to store the relevent variables or replace variables placeholder in the below commands before running commands
source .env
NPM
This operation confirms that all package dependencies are being pulled via Nexus as your main NPM proxy
npm conf set always-auth true
npm conf set registry $NPM_REPO_URL
npm conf set email $NPM_EMAIL
npm conf set _auth $NPM_RO_BASE64_STRING
cat package.json.template |sed "s/NPM_PACKAGE_VERSION/${NPM_PACKAGE_VERSION}/" > package.json
npm install
DOCKER
- Build docker image to pull package from Nexus3 hosted NPM repository
docker build --tag $IMAGE_NAME:$IMAGE_TAG --build-arg NPM_EMAIL=$NPM_EMAIL --build-arg NPM_REPO_URL=$NPM_REPO_URL --build-arg NPM_RO_BASE64_STRING=$NPM_RO_BASE64_STRING .
- Login and pull the demo container from Nexus3 hosted docker repository
docker login -u $DOCKER_RO_USER -p $DOCKER_RO_PW $DOCKER_URL
# use --rm to perform automatic container cleanup when container is stopped
docker run -d --rm -p $PORT:$PORT --name demo_express $DOCKER_URL/$IMAGE_NAME:$IMAGE_TAG
# Application can be access from the browser on http://localhost:$PORT
docker stop demo_express
Only available to Devops admins to populate new empty Nexus instance
####
source .env
npm conf set registry $NPM_REPO_URL && \
npm conf set email $NPM_EMAIL && \
npm conf set _auth $NPM_RW_BASE64_STRING
cat package.json.template |sed "s/NPM_PACKAGE_VERSION/${NPM_PACKAGE_VERSION}/" > package.json
npm publish
# Uses devops admin's person user token as NPM_RO_BASE64_STRING to test pulling packages
docker build --tag $IMAGE_NAME:$IMAGE_TAG --build-arg NPM_EMAIL=$NPM_EMAIL --build-arg NPM_REPO_URL=$NPM_REPO_URL --build-arg NPM_RO_BASE64_STRING=$NPM_RO_BASE64_STRING .
docker tag $IMAGE_NAME:$IMAGE_TAG $DOCKER_URL/$IMAGE_NAME:$IMAGE_TAG
docker login -u $DOCKER_RW_USER -p $DOCKER_RW_PW $DOCKER_URL
docker push $DOCKER_URL/$IMAGE_NAME:$IMAGE_TAG
#
# End Devops admin section
####
Quick all in one command for devops admins
. e2e_test.sh