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:
parent
7c6c2d2932
commit
5b8fe3aeb5
3 changed files with 46 additions and 11 deletions
22
Dockerfile
22
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"]
|
||||
|
|
23
README.md
23
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 /<path to verdaccio directory>/conf:/verdaccio/conf \
|
||||
-v /<path to verdaccio directory>/storage:/verdaccio/storage \
|
||||
-v /<path to verdaccio directory>/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`.
|
||||
|
|
12
docker-compose.yaml
Normal file
12
docker-compose.yaml
Normal file
|
@ -0,0 +1,12 @@
|
|||
version: '2'
|
||||
services:
|
||||
verdaccio:
|
||||
build: .
|
||||
container_name: verdaccio
|
||||
ports:
|
||||
- "4873:4873"
|
||||
volumes:
|
||||
- verdaccio:/verdaccio
|
||||
volumes:
|
||||
verdaccio:
|
||||
driver: local
|
Loading…
Reference in a new issue