0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-30 22:34:10 -05:00

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.
This commit is contained in:
Jeff Mixon 2017-01-14 12:51:18 -08:00 committed by Konstantin Baierer
parent 7c6c2d2932
commit 5b8fe3aeb5
3 changed files with 46 additions and 11 deletions

View file

@ -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 RUN mkdir -p /verdaccio/storage /verdaccio/conf
WORKDIR /verdaccio
ADD conf/docker.yaml /verdaccio/conf/config.yaml 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 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"]

View file

@ -69,13 +69,26 @@ To build the docker image for raspberry pi execute:
`npm run build-docker:rpi` `npm run build-docker:rpi`
To run the docker container: 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 /<path to verdaccio directory>/conf:/verdaccio/conf \ 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:
-v /<path to verdaccio directory>/storage:/verdaccio/storage \
-v /<path to verdaccio directory>/local_storage:/verdaccio/local_storage \ ```bash
verdaccio $ 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`. 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`.

12
docker-compose.yaml Normal file
View file

@ -0,0 +1,12 @@
version: '2'
services:
verdaccio:
build: .
container_name: verdaccio
ports:
- "4873:4873"
volumes:
- verdaccio:/verdaccio
volumes:
verdaccio:
driver: local