From 5b8fe3aeb5b907bd2ebd6867fd5266c3bbe0a54d Mon Sep 17 00:00:00 2001 From: Jeff Mixon Date: Sat, 14 Jan 2017 12:51:18 -0800 Subject: [PATCH 1/3] Better Docker Improves the Docker experience by leveraging Data volumes, dropping root permissions, using a more lightweight and secure base image (node:alpine), and moving unwieldy run arguments into a docker-compose file. The net result is you can now issue a single command `docker-compose up --build` to have a fully-functional verdaccio instance running. --- Dockerfile | 22 ++++++++++++++++------ README.md | 23 ++++++++++++++++++----- docker-compose.yaml | 12 ++++++++++++ 3 files changed, 46 insertions(+), 11 deletions(-) create mode 100644 docker-compose.yaml diff --git a/Dockerfile b/Dockerfile index b248b3a32..5d362e25b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,23 @@ -FROM node:6.1.0-onbuild +FROM node:alpine + +ENV appdir /usr/local/app + +RUN mkdir -p $appdir +WORKDIR $appdir +COPY . $appdir +RUN npm install RUN mkdir -p /verdaccio/storage /verdaccio/conf - -WORKDIR /verdaccio - ADD conf/docker.yaml /verdaccio/conf/config.yaml +RUN addgroup -S verdaccio && adduser -S -g verdaccio verdaccio && \ +chown -R verdaccio:verdaccio $appdir && \ +chown -R verdaccio:verdaccio /verdaccio + +USER verdaccio + EXPOSE 4873 -VOLUME ["/verdaccio/conf", "/verdaccio/storage"] +VOLUME ["/verdaccio"] -CMD ["/usr/src/app/bin/verdaccio", "--config", "/verdaccio/conf/config.yaml", "--listen", "0.0.0.0:4873"] +CMD ["sh", "-c", "${appdir}/bin/verdaccio --config /verdaccio/conf/config.yaml --listen 0.0.0.0:4873"] diff --git a/README.md b/README.md index cff14a26d..bb41b9017 100644 --- a/README.md +++ b/README.md @@ -69,13 +69,26 @@ To build the docker image for raspberry pi execute: `npm run build-docker:rpi` To run the docker container: +1. Get the latest version of [docker-compose](https://github.com/docker/compose). +2. Build and run the container: +```bash +$ docker-compose up --build ``` -docker run -it --rm --name verdaccio -p 4873:4873 \ - -v //conf:/verdaccio/conf \ - -v //storage:/verdaccio/storage \ - -v //local_storage:/verdaccio/local_storage \ - verdaccio + +Docker will generate a named volume in which to store persistent application data. You can use `docker inspect` or `docker volume inspect` to reveal the physical location of the volume and edit the configuration, such as: + +```bash +$ docker volume inspect verdaccio_verdaccio +[ + { + "Name": "verdaccio_verdaccio", + "Driver": "local", + "Mountpoint": "/var/lib/docker/volumes/verdaccio_verdaccio/_data", + "Labels": null, + "Scope": "local" + } +] ``` Please note that for any of the above docker commands you need to have docker installed on your machine and the docker executable should be available on your `$PATH`. diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 000000000..d81dc16b8 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,12 @@ +version: '2' +services: + verdaccio: + build: . + container_name: verdaccio + ports: + - "4873:4873" + volumes: + - verdaccio:/verdaccio +volumes: + verdaccio: + driver: local From 6fd47b333e32c9f4c1f24c22f5cf1454a05b5bc6 Mon Sep 17 00:00:00 2001 From: Konstantin Baierer Date: Wed, 3 May 2017 00:03:51 +0200 Subject: [PATCH 2/3] Address feedback by @cosaquee and @juanpicado in verdaccio/verdaccio#110 --- Dockerfile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5d362e25b..e9eb587ec 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,18 @@ -FROM node:alpine +FROM node:6-alpine -ENV appdir /usr/local/app +ENV APPDIR /usr/local/app -RUN mkdir -p $appdir -WORKDIR $appdir -COPY . $appdir +RUN mkdir -p "$APPDIR" +WORKDIR $APPDIR +COPY . $APPDIR RUN npm install RUN mkdir -p /verdaccio/storage /verdaccio/conf ADD conf/docker.yaml /verdaccio/conf/config.yaml RUN addgroup -S verdaccio && adduser -S -g verdaccio verdaccio && \ -chown -R verdaccio:verdaccio $appdir && \ -chown -R verdaccio:verdaccio /verdaccio + chown -R verdaccio:verdaccio "$APPDIR" && \ + chown -R verdaccio:verdaccio /verdaccio USER verdaccio @@ -20,4 +20,4 @@ EXPOSE 4873 VOLUME ["/verdaccio"] -CMD ["sh", "-c", "${appdir}/bin/verdaccio --config /verdaccio/conf/config.yaml --listen 0.0.0.0:4873"] +CMD ["sh", "-c", "${APPDIR}/bin/verdaccio --config /verdaccio/conf/config.yaml --listen 0.0.0.0:4873"] From 24411f7a6817153a336a46bbcaaf0beeb123ee65 Mon Sep 17 00:00:00 2001 From: Konstantin Baierer Date: Sun, 7 May 2017 17:38:53 +0200 Subject: [PATCH 3/3] Dockerfile: Set maintainer, COPY -> ADD --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e9eb587ec..9718435e5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,11 @@ FROM node:6-alpine +LABEL maintainer="https://github.com/verdaccio/verdaccio" ENV APPDIR /usr/local/app RUN mkdir -p "$APPDIR" WORKDIR $APPDIR -COPY . $APPDIR +ADD . $APPDIR RUN npm install RUN mkdir -p /verdaccio/storage /verdaccio/conf