Skip to content

Commit

Permalink
feat(tools): add test-npm-registry contaimer image
Browse files Browse the repository at this point in the history
This is also tagged on DockerHub as
petermetz/cactus-test-npm-registry:1.0.0

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
  • Loading branch information
petermetz committed Apr 19, 2021
1 parent 80c8253 commit 19afe85
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tools/docker/test-npm-registry/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM verdaccio/verdaccio:5.0.1

COPY ./config.yaml /verdaccio/conf/config.yaml
40 changes: 40 additions & 0 deletions tools/docker/test-npm-registry/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# test-npm-registry container image

Used for locally verifying publishing commands before using them on npm publicly.
The image is configured by default to not require any authentication at all and
therefore it is a great fit for testing, but most never be used for production
deployments of any kind.

The reason why this image had to be created was because some of our packages
that have front-end code embedded in them can take up more than 10MB in size
and verdaccio by default does not allow bigger request payloads than that so
we had to increase it to a higher limit via the configuration file `config.yaml`.

## Usage

1. Start the container and publish it's port `4873` to the host machine:
```sh
docker run -it --rm --publish 4873:4873 petermetz/cactus-test-npm-registry:1.0.0
```
2. Verify a canary publish with this container instead of using npmjs.com
by specifying the registry URL as http://localhost:4873 such as
```sh
npx lerna publish \
--canary \
--force-publish \
--dist-tag $(git branch --show-current) \
--preid $(git branch --show-current).$(git rev-parse --short HEAD) \
--registry http://localhost:4873
```

## Build image locally:

```sh
DOCKER_BUILDKIT=1 docker build ./tools/docker/test-npm-registry/ -t ctnr
```

## Run image locally

```sh
docker run -it --rm --publish 4873:4873 ctnr
```
57 changes: 57 additions & 0 deletions tools/docker/test-npm-registry/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#
# 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
#

# The only reason why we need a custom built docker image is because there is
# no way to configure the existing container images to have a max body size
# higher than the default 10 MB without mounting a volume with a config file
max_body_size: 1000mb

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

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

packages:
'@scope/*':
# scoped packages
access: $all
publish: $all
proxy: npmjs
'@*/*':
# 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 anyone to publish packages so there is no need to register a user
publish: $all

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

# log settings
logs:
- { type: stdout, format: pretty, level: trace }
#- {type: file, path: verdaccio.log, level: info}

listen:
- 0.0.0.0:4873

0 comments on commit 19afe85

Please sign in to comment.