1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-11-13 03:35:52 +01:00
verdaccio/docker-examples/v5/plugins/docker-build-install-plugin
2024-03-07 12:24:52 +01:00
..
docker.yaml docs: fix typos in different areas (#4535) 2024-03-07 12:24:52 +01:00
Dockerfile docs: improve docker docs for 5.x (#3476) 2022-11-08 19:52:40 +01:00
README.md docs: improve docker docs for 5.x (#3476) 2022-11-08 19:52:40 +01:00

Installing a plugin with Docker build

On this small tutorial (based on verdaccio-prometheus-middleware example) you will be able to use a published package in any random registry (npmjs by default) and use it withing a docker image without mapping need it.

Since verdaccio:5 uses yarn@2 to run the application, this tutorial is a workaround but future prove since verdaccio 6 uses pnpm to build the docker image.

There are two main steps to highlight:

  • docker.yaml: This is a copy of the original configuration file for docker and with small modifications to use the plugin verdaccio-auth-memory and custom web title for demonstration.
  • The Dockerfile take advance of the docker multi-stage build to install the plugin into the verdaccio/plugins folder withing the image, then we apply the right permissions --chown=$VERDACCIO_USER_UID:root so the plugin is recognized.

Run it

Build this image.

docker build -t verdaccio/verdaccio:local .

and to run it

docker run -it --rm --name verdaccio -p 4873:4873 verdaccio/verdaccio:local

Usage

# Docker multi-stage build - https://docs.docker.com/develop/develop-images/multistage-build/
# Use an alpine node image to install the plugin
FROM node:lts-alpine as builder

RUN mkdir -p /verdaccio/plugins \
  && cd /verdaccio/plugins \
  && npm install --global-style --no-bin-links --omit=optional verdaccio-auth-memory@latest

FROM verdaccio/verdaccio:5

# copy your modified config.yaml into the image
ADD docker.yaml /verdaccio/conf/config.yaml
# need it for install global plugins
USER root
# install plugins with npm global
RUN npm install --global verdaccio-static-token \
  && npm install --global verdaccio-auth-memory
# back to original user
USER $VERDACCIO_USER_UID