mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-16 21:56:25 -05:00
feat: adds support for external plugin directory (#532)
This commit is contained in:
parent
a14a737241
commit
11dcf798cc
11 changed files with 41 additions and 4 deletions
|
@ -27,7 +27,7 @@ RUN npm config set registry http://registry.npmjs.org/ && \
|
|||
yarn cache clean && \
|
||||
yarn install --production=true --pure-lockfile
|
||||
|
||||
RUN mkdir -p /verdaccio/storage /verdaccio/conf
|
||||
RUN mkdir -p /verdaccio/storage /verdaccio/plugins /verdaccio/conf
|
||||
|
||||
ADD conf/docker.yaml /verdaccio/conf/config.yaml
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
# path to a directory with all packages
|
||||
storage: ./storage
|
||||
# path to a directory with plugins to include
|
||||
plugins: ./plugins
|
||||
|
||||
web:
|
||||
# WebUI is enabled as default, if you want disable it, just uncomment this line
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
# path to a directory with all packages
|
||||
storage: /verdaccio/storage
|
||||
# path to a directory with plugins to include
|
||||
plugins: /verdaccio/plugins
|
||||
|
||||
web:
|
||||
# WebUI is enabled as default, if you want disable it, just uncomment this line
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# path to a directory with all packages
|
||||
storage: ./storage
|
||||
# path to a directory with plugins to include
|
||||
plugins: ./plugins
|
||||
|
||||
web:
|
||||
# WebUI is enabled as default, if you want disable it, just uncomment this line
|
||||
|
|
|
@ -42,6 +42,14 @@ Is the location of the default storage. **Verdaccio is by default based on local
|
|||
storage: ./storage
|
||||
```
|
||||
|
||||
### Plugins
|
||||
|
||||
Is the location of the plugin directory. Useful for Docker/Kubernetes based deployments.
|
||||
|
||||
```yaml
|
||||
plugins: ./plugins
|
||||
```
|
||||
|
||||
### Authentification
|
||||
|
||||
The authentification set up is done here, the default auth is based on `htpasswd` and is built-in. You can modify this behaviour via [plugins](plugins.md). For more information about this section read the [auth page](auth.md).
|
||||
|
|
|
@ -58,15 +58,19 @@ The above line will pull the latest prebuilt image from dockerhub, if you haven'
|
|||
If you have [build an image locally](#build-your-own-docker-image) use `verdaccio` as the last argument.
|
||||
|
||||
|
||||
You can use `-v` to bind mount `conf` and `storage` to the hosts filesystem:
|
||||
You can use `-v` to bind mount `conf`, `storage` and `plugins` to the hosts filesystem:
|
||||
```bash
|
||||
V_PATH=/path/for/verdaccio; docker run -it --rm --name verdaccio -p 4873:4873 \
|
||||
-v $V_PATH/conf:/verdaccio/conf \
|
||||
-v $V_PATH/storage:/verdaccio/storage \
|
||||
-v $V_PATH/plugins:/verdaccio/plugins \
|
||||
verdaccio/verdaccio
|
||||
```
|
||||
>Note: Verdaccio runs as a non-root user (uid=100, gid=101) inside the container, if you use bind mount to override default, you need to make sure the mount directory is assigned to the right user. In above example, you need to run `sudo chown -R 100:101 /opt/verdaccio` otherwise you will get permission errors at runtime. [Use docker volume](https://docs.docker.com/storage/volumes/) is recommended over using bind mount.
|
||||
|
||||
### Plugins
|
||||
Plugins can be installed in a separate directory and mounted using Docker or Kubernetes, however make sure you build plugins with native dependencies using the same base image as the Verdaccio Dockerfile.
|
||||
|
||||
### Docker and custom port configuration
|
||||
Any `host:port` configured in `conf/config.yaml` under `listen` is currently ignored when using docker.
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
"devDependencies": {
|
||||
"@commitlint/cli": "6.1.3",
|
||||
"@commitlint/config-conventional": "6.1.3",
|
||||
"@verdaccio/types": "3.4.1",
|
||||
"@verdaccio/types": "3.4.2",
|
||||
"babel-cli": "6.26.0",
|
||||
"babel-core": "6.26.0",
|
||||
"babel-eslint": "8.2.2",
|
||||
|
|
|
@ -37,6 +37,7 @@ class Config implements AppConfig {
|
|||
server_id: string;
|
||||
self_path: string;
|
||||
storage: string | void;
|
||||
plugins: string | void;
|
||||
$key: any;
|
||||
$value: any;
|
||||
|
||||
|
@ -45,6 +46,7 @@ class Config implements AppConfig {
|
|||
this.logger = LoggerApi.logger;
|
||||
this.self_path = config.self_path;
|
||||
this.storage = config.storage;
|
||||
this.plugins = config.plugins;
|
||||
|
||||
for (let configProp in config) {
|
||||
if (self[configProp] == null) {
|
||||
|
|
|
@ -37,7 +37,8 @@ function isES6(plugin) {
|
|||
/**
|
||||
* Load a plugin following the rules
|
||||
* - First try to load from the internal directory plugins (which will disappear soon or later).
|
||||
* - A seccond attempt from node_modules, in case to have multiple match as for instance verdaccio-ldap
|
||||
* - A second attempt from the external plugin directory
|
||||
* - A third attempt from node_modules, in case to have multiple match as for instance verdaccio-ldap
|
||||
* and sinopia-ldap. All verdaccio prefix will have preferences.
|
||||
* @param {*} config a reference of the configuration settings
|
||||
* @param {*} pluginConfigs
|
||||
|
@ -56,6 +57,21 @@ export default function loadPlugin<T>(
|
|||
// try local plugins first
|
||||
plugin = tryLoad(Path.resolve(__dirname + '/../plugins', pluginId));
|
||||
|
||||
// try the external plugin directory
|
||||
if (plugin === null && config.plugins) {
|
||||
const pluginDir = config.plugins;
|
||||
plugin = tryLoad(Path.resolve(pluginDir, pluginId));
|
||||
|
||||
// npm package
|
||||
if (plugin === null && pluginId.match(/^[^\.\/]/)) {
|
||||
plugin = tryLoad(Path.resolve(pluginDir, `verdaccio-${pluginId}`));
|
||||
// compatibility for old sinopia plugins
|
||||
if (!plugin) {
|
||||
plugin = tryLoad(Path.resolve(pluginDir, `sinopia-${pluginId}`));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// npm package
|
||||
if (plugin === null && pluginId.match(/^[^\.\/]/)) {
|
||||
plugin = tryLoad(`verdaccio-${pluginId}`);
|
||||
|
|
|
@ -23,6 +23,7 @@ export type StringValue = verdaccio$StringValue;
|
|||
|
||||
export type StartUpConfig = {
|
||||
storage: string;
|
||||
plugins?: string;
|
||||
self_path: string;
|
||||
}
|
||||
|
||||
|
|
BIN
yarn.lock
BIN
yarn.lock
Binary file not shown.
Loading…
Reference in a new issue