Can I have a local registry?

0
I want to have a local and private registry on my laptop that can store public packages, so that I can create new workspaces without internet connection.
asked
1 answers
1

SIMATIC AX does not support the creation of a local registry. However, you can use Verdaccio, a lightweight private npm proxy registry that is easy to set up and use, to create your own local registry and then utilize it within SIMATIC AX as an external third-party registry.

You can set it up as a globally installed application or within a Docker container.

 

Here's a step-by-step guide:

 

- Verdaccio globally:

 

  • Install command:
npm install -g verdaccio
  • Start Verdaccio:

verdaccio

By default, it runs on `http://localhost:4873

  • Configure Verdaccio

The default config file is located at:

- Windows: `%AppData%/verdaccio/config.yaml`

- Mac/Linux: `~/.config/verdaccio/config.yaml`

Example `config.yaml`:

 example: config.yaml

storage: ./storage
auth:
 htpasswd:
   file: ./htpasswd
uplinks:
 npmjs:
   url: https://registry.npmjs.org/
packages:
 '@*/*':
   access: $all
   publish: $authenticated
   proxy: npmjs
 '**':
   access: $all
   publish: $authenticated
   proxy: npmjs
listen: 0.0.0.0:4873
  • Create a new usernpm adduser --registry http://localhost:4873

npm adduser --registry http://localhost:4873
  • Configure npm to use your local registry

For a single project:

npm config set registry http://localhost:4873

Or using .npmrc in your project:

registry=http://localhost:4873
  • Publishing packages:
npm publish --registry http://localhost:4873
  • Installing packages

npm install your-package --registry http://localhost:4873

- Using verdaccio with Docker:

  • Here's a simple Docker setup:
FROM node:14
RUN npm install -g verdaccio
EXPOSE 4873
CMD ["verdaccio", "--config", "/verdaccio/config.yaml"]

Docker Compose example:

version: '3'
services:
 verdaccio:
   container_name: verdaccio
   image: verdaccio/verdaccio
   ports:
     - "4873:4873"
   volumes:
     - "./storage:/verdaccio/storage"
     - "./config:/verdaccio/conf"
  • Best Practices:

1. Always backup your storage directory

2. Use authentication for publishing

3. Configure proper uplinks for fallback to public registries

4. Consider using HTTPS in production

5. Set up proper access controls for different package scopes

This setup gives you a private npm registry that can cache packages from npmjs.org and store your private packages.

 

Best regards

Tim

answered