Skip to content

Commit

Permalink
Use docker images for Verdaccio to simplify environment and dependenc…
Browse files Browse the repository at this point in the history
…ies (hyperledger-archives#3726)

* Use docker images for Verdaccio to simplify environment and dependencies

Signed-off-by: Mark S. Lewis <[email protected]>

* Specify an npmrc for publishing in dev start of playground-api

Avoid overwriting the user's real .npmrc.

Signed-off-by: Mark S. Lewis <[email protected]>

* Fix license check

- Add license to publish npmrc
- Rename publish-npmrc to publish.npmrc to make license check happy
- Rename scripts/start.sh to devStart.sh to clarify purpose

Signed-off-by: Mark S. Lewis <[email protected]>
  • Loading branch information
bestbeforetoday authored and Simon Stone committed Apr 20, 2018
1 parent 856f042 commit 8bfe4ec
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 30 deletions.
5 changes: 1 addition & 4 deletions packages/composer-playground-api/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
Expand Down Expand Up @@ -60,6 +60,3 @@ out
*.swp

# Build generated files should be ignored by git, but not by npm.

scripts/storage
.pm2
3 changes: 1 addition & 2 deletions packages/composer-playground-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@
"mocha": "3.4.2",
"nyc": "11.1.0",
"proxyquire": "1.7.11",
"sinon": "2.3.8",
"verdaccio": "2.6.4"
"sinon": "2.3.8"
},
"dependencies": {
"async": "2.5.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,40 +1,53 @@
#
# This is the default config file. It allows all users to do anything,
# so don't use it on production systems.
# This is the config file used for the docker images.
# It allows all users to do anything, so don't use it on production systems.
#
# Do not configure host and port under `listen` in this file
# as it will be ignored when using docker.
# see https://github.com/verdaccio/verdaccio/blob/master/wiki/docker.md#docker-and-custom-port-configuration
#
# Look here for more config file examples:
# https://github.com/verdaccio/verdaccio/tree/master/conf
#

# path to a directory with all packages
storage: ./storage
storage: /verdaccio/storage

auth:
htpasswd:
file: ./htpasswd
file: /verdaccio/conf/htpasswd
# Maximum amount of users allowed to register, defaults to "+inf".
# You can set this to -1 to disable registration.
#max_users: 1000

# a list of other known repositories we can talk to
uplinks:
npmjs:
url: https://registry.npmjs.org/
max_fails: 1000

packages:
'@*/*':
# scoped packages
access: $all
publish: $all
proxy: npmjs

'**':
# allow all users (including non-authenticated users) to read and
# publish all packages
#
# you can specify usernames/groupnames (depending on your auth plugin)
# and three keywords: "$all", "$anonymous", "$authenticated"
access: $all

# allow all known users to publish packages
# (anyone can register by default, remember?)
publish: $all

# if package is not available locally, proxy requests to 'npmjs' registry
proxy: npmjs

# log settings
logs:
- {type: stdout, format: pretty, level: http}
#- {type: file, path: verdaccio.log, level: info}
listen:
- localhost:4873 # default value
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
Expand All @@ -17,36 +17,29 @@
set -ev

# Environment vaiable directs Playground (connector server) to an npmrc to supply to network install
export NPMRC_FILE=/tmp/npmrc

# Switch to package root directory
cd "$(dirname "${BASH_SOURCE[0]}")/.."
export NPMRC_FILE='/tmp/npmrc'

# Delete any existing configuration
rm -rf ./scripts/storage
scriptDir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
packagesDir="$(cd "${scriptDir}/../.." && pwd)"

# Create the npmrc for use by Playground
if [ `uname` = "Darwin" ]; then
export GATEWAY=docker.for.mac.localhost
gateway=docker.for.mac.localhost
else
export GATEWAY="$(docker inspect hlfv1_default | grep Gateway | cut -d \" -f4)"
gateway="$(docker inspect hlfv1_default | grep Gateway | cut -d \" -f4)"
fi
echo "registry=http://${GATEWAY}:4873" > ${NPMRC_FILE}
echo "registry=http://${gateway}:4873" > "${NPMRC_FILE}"

# Start the npm proxy
./node_modules/.bin/verdaccio --listen '0.0.0.0:4873' --config scripts/config.yaml &
verdaccio_pid=$!
docker-compose --file "${scriptDir}/docker-compose.yaml" up --detach

# Publish development versions of packages required at runtime
for package in composer-common composer-runtime composer-runtime-hlfv1; do
npm publish --registry 'http://localhost:4873' "../${package}"
npm publish --userconfig "${scriptDir}/publish.npmrc" "${packagesDir}/${package}"
done

# Start the Playground API
npm start

# Stop the npm proxy
kill ${verdaccio_pid}

# Wipe out configuration
rm -rf ./scripts/storage
docker-compose --file "${scriptDir}/docker-compose.yaml" down
15 changes: 15 additions & 0 deletions packages/composer-playground-api/scripts/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: '3'

services:
verdaccio:
image: verdaccio/verdaccio
container_name: verdaccio
ports:
- 4873:4873
volumes:
- ./conf:/verdaccio/conf
networks:
- verdaccio

networks:
verdaccio:
14 changes: 14 additions & 0 deletions packages/composer-playground-api/scripts/publish.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

//localhost:4873/:_authToken="foo"
registry=http://localhost:4873

0 comments on commit 8bfe4ec

Please sign in to comment.