0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-16 21:56:25 -05:00

migrate docker-examples (#2682)

This commit is contained in:
Diana Morales 2021-11-19 15:39:26 +01:00 committed by GitHub
parent 06448be421
commit 2533cb5813
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 465 additions and 0 deletions

View file

@ -8,6 +8,7 @@ The following examples aim to be demonstrative and can be either improved or upd
- [v4 examples](v4/README.md)
- [v5 examples](v5/README.md)
- [v6 examples](v6/README.md)
## Aditional data

View file

@ -0,0 +1,5 @@
# Verdaccio 6
> We recommend to have installed [docker-compose >= 1.29.0](https://github.com/docker/compose/releases/tag/1.29.2)
- [Docker + Nginx + Verdaccio](reverse_proxy/nginx/README.md)

View file

@ -0,0 +1,60 @@
# Verdaccio and Nginx
Running `verdaccio` via reverse proxy is a common practice. This configuration provides a quick way to run the application behind **nginx**.
This folder provides the following examples:
- root_path: Using reverse proxy with `/` as a path.
- relative_path: Using `/verdaccio/` as a subdirectory. It includes also SSL examples with reverse proxy.
To run the containers, run the following commands in this folder. The containers should start in detach mode.
```bash
docker-compose up -d
```
To recreate the nginx image you can force the build.
```bash
docker-compose up --build -d
```
To force recreate the images.
```bash
docker-compose up --build --force-recreate -d
```
To stop all containers
```bash
docker-compose stop
```
To display container logs
```bash
$> docker-compose logs
Attaching to nginxverdaccio_nginx_1, verdaccio
verdaccio | warn --- config file - /verdaccio/conf/config.yaml
verdaccio | warn --- http address - http://0.0.0.0:4873/ - verdaccio/2.1.7
verdaccio | http <-- 304, user: undefined, req: 'GET /', bytes: 0/0
verdaccio | http <-- 304, user: undefined, req: 'GET /-/static/jquery.min.js', bytes: 0/0
verdaccio | http <-- 304, user: undefined, req: 'GET /-/static/main.css', bytes: 0/0
verdaccio | http <-- 304, user: undefined, req: 'GET /-/static/main.js', bytes: 0/0
verdaccio | http <-- 304, user: undefined, req: 'GET /-/logo', bytes: 0/0
verdaccio | http <-- 304, user: undefined, req: 'GET /-/static/fontello.woff?10872183', bytes: 0/0
verdaccio | http <-- 200, user: undefined, req: 'GET /-/static/favicon.png', bytes: 0/315
```
### Display Information
To display the containers running
```bash
&> docker-compose ps
Name Command State Ports
----------------------------------------------------------------------------------------
nginxverdaccio_nginx_1 /usr/sbin/nginx Up 0.0.0.0:80->80/tcp
verdaccio /usr/src/app/bin/verdaccio ... Up 0.0.0.0:4873->4873/tcp
```

View file

@ -0,0 +1,31 @@
# Nginx Relative Path with Verdaccio 6
This example runs two verdaccio versions:
- Running `verdaccio:6.x` http://localhost/verdaccio/
Note: we should add more sort of configurations here.
**Nginx HTTP Example**
```bash
docker-compose up --build --force-recreate
```
open the browser
```
http://localhost/verdaccio/
```
**Nginx SSL Example**
```bash
docker-compose -f docker-compose_ssl.yml up --build --force-recreate
```
open the browser
```
https://localhost/verdaccio/
```

View file

@ -0,0 +1,49 @@
storage: /verdaccio/storage
web:
enable: true
title: VerdaccioV6 Relative Path
primary_color: red
auth:
htpasswd:
file: /verdaccio/conf/htpasswd
security:
api:
jwt:
sign:
expiresIn: 60d
notBefore: 1
web:
sign:
expiresIn: 7d
## IMPORTANT
## This will configure verdaccio to rely on a relative path
url_prefix: /verdaccio
uplinks:
npmjs:
url: https://registry.npmjs.org/
packages:
'@jota/*':
access: $all
publish: $all
'@*/*':
# scoped packages
access: $all
publish: $all
proxy: npmjs
'**':
access: $all
publish: $all
proxy: npmjs
middlewares:
audit:
enabled: true
logs: { type: stdout, format: pretty, level: trace }

View file

@ -0,0 +1,2 @@
jpicado:$6vkdNgRX2npc:autocreated 2017-07-11T18:48:38.003Z
test:$6FrCaT/v0dwE:autocreated 2019-05-06T22:06:54.513Z

View file

@ -0,0 +1,45 @@
storage: /verdaccio/storage
web:
enable: true
title: VerdaccioV6 Root Path
primary_color: redF
auth:
htpasswd:
file: /verdaccio/conf/htpasswd
security:
api:
jwt:
sign:
expiresIn: 60d
notBefore: 1
web:
sign:
expiresIn: 7d
uplinks:
npmjs:
url: https://registry.npmjs.org/
packages:
'@jota/*':
access: $all
publish: $all
'@*/*':
# scoped packages
access: $all
publish: $all
proxy: npmjs
'**':
access: $all
publish: $all
proxy: npmjs
middlewares:
audit:
enabled: true
logs: { type: stdout, format: json, level: trace }

View file

@ -0,0 +1 @@
jpicado:$6vkdNgRX2npc:autocreated 2017-07-11T18:48:38.003Z

View file

@ -0,0 +1,41 @@
services:
nginx:
build:
context: ''
dockerfile: nginx/Dockerfile
ports:
- '80:80'
networks:
- node-network
container_name: 'nginx'
depends_on:
- verdaccio
- verdaccio-root
verdaccio:
image: verdaccio/verdaccio:nightly-master
container_name: 'verdaccio_relative_path_v6'
networks:
- node-network
environment:
- VERDACCIO_PORT=4873
- DEBUG=verdaccio:*
ports:
- '4873:4873'
volumes:
- './storage:/verdaccio/storage'
- './conf/v6:/verdaccio/conf'
verdaccio-root:
image: verdaccio/verdaccio:nightly-master
container_name: 'verdaccio_relative_path_v6_root'
networks:
- node-network
environment:
- VERDACCIO_PORT=8000
ports:
- '8000:8000'
volumes:
- './storage:/verdaccio/storage'
- './conf/v6_root:/verdaccio/conf'
networks:
node-network:
driver: bridge

View file

@ -0,0 +1,44 @@
services:
nginx:
build:
context: './nginx_ssl'
dockerfile: Dockerfile
ports:
- '443:443'
- '80:80'
environment:
- REMOTE_URL=http://verdaccio_relative_path_v6:4873/
networks:
- node-network
container_name: 'nginx_ssl'
depends_on:
- verdaccio
- verdaccio-root
verdaccio:
image: verdaccio/verdaccio:nightly-master
container_name: 'verdaccio_relative_path_v6'
networks:
- node-network
environment:
- VERDACCIO_PORT=4873
ports:
- '4873:4873'
volumes:
- './storage:/verdaccio/storage'
- './conf/v6:/verdaccio/conf'
verdaccio-root:
image: verdaccio/verdaccio:nightly-master
container_name: 'verdaccio_relative_path_v6_root'
networks:
- node-network
environment:
- VERDACCIO_PORT=8000
ports:
- '8000:8000'
volumes:
- './storage:/verdaccio/storage'
- './conf/v6_root:/verdaccio/conf'
networks:
node-network:
driver: bridge

View file

@ -0,0 +1,2 @@
FROM nginx:1.21-alpine
COPY nginx/default.conf /etc/nginx/conf.d/default.conf

View file

@ -0,0 +1,33 @@
upstream verdaccio_relative_v6 {
server verdaccio_relative_path_v6:4873;
keepalive 8;
}
upstream verdaccio_v6_root {
server verdaccio_relative_path_v6_root:8000;
keepalive 8;
}
server {
listen 80 default_server;
access_log /var/log/nginx/verdaccio.log;
charset utf-8;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://verdaccio_v6_root;
proxy_redirect off;
}
location ~ ^/verdaccio/(.*)$ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://verdaccio_relative_v6/$1;
proxy_redirect off;
}
}

View file

@ -0,0 +1,10 @@
FROM nginx:1
COPY cert.crt /etc/nginx/cert.crt
COPY cert.key /etc/nginx/cert.key
COPY nginx-default.conf /etc/nginx/conf.d/default.conf
COPY run.sh /run.sh
ENV REMOTE_URL="http://localhost:8080/"
CMD ["/run.sh"]

View file

@ -0,0 +1,5 @@
Example taken from:
[https://github.com/foxylion/docker-nginx-self-signed-https](https://github.com/foxylion/docker-nginx-self-signed-https)
by [@foxylion](https://github.com/foxylion)

View file

@ -0,0 +1,22 @@
-----BEGIN CERTIFICATE-----
MIIDrzCCApegAwIBAgIJAPVnhyCGRxmMMA0GCSqGSIb3DQEBCwUAMG4xCzAJBgNV
BAYTAlhYMQswCQYDVQQIDAJYWDELMAkGA1UEBwwCWFgxCzAJBgNVBAoMAlhYMQsw
CQYDVQQLDAJYWDESMBAGA1UEAwwJbG9jYWxob3N0MRcwFQYJKoZIhvcNAQkBFghY
WEBYWC5YWDAeFw0xNzExMjQxNDI0MzVaFw0xODExMjQxNDI0MzVaMG4xCzAJBgNV
BAYTAlhYMQswCQYDVQQIDAJYWDELMA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sTxtUN0NwKBgQCSRvdFjxCtJre+VYFlZA3k0c21Mkt/VhyzgItPKDiwD4lou7kT
z95UBrOYUGsDVSodjT1ctTKcJrP2mtJLgn7+cvuw9JIlLxTfUksWqpxljD/XFS1g
u2wjF70QB0uW+voMO9dvFAZ9+jNoSE2gnvUcLSMLYRV789B3qQhtBGsUDwKBgQCm
RU/fCKOUKitfZ3Ql9cHgd2DEyIHZEpHOYt8AARXHQ+pZdrogwXFkNAjawy5wGrmR
bkzNfAnAhaMN4Zpwp8Ac2lTFd+8IZb5mEfm8sCY3zeo/sW8skThN9du3xFAjcjxi
LpW1q7wkA3lLHZsWV4A8dzvFpk6dfNkURRSwEc2JdQKBgH1n8Io2gnrQd1Yhh5rH
pajY9Pdzp+mv9PW8G1Y7Z57RKxAorYfszmR5Qj2oZ3+0lqJ5+K7K4PffH3CkiCBz
i9HBnq/NczJggQ9BTifIdyznWkuAqZAjup5V+g7+CIhpa+XaeGzB4BpTsXrJFiy0
ZTYk/5J1N3d6rURRlybaoRGj
-----END PRIVATE KEY-----

View file

@ -0,0 +1,40 @@
server {
listen 80;
return 302 https://$host$request_uri;
}
server {
listen 443 ssl http2;
server_name localhost;
ssl_certificate /etc/nginx/cert.crt;
ssl_certificate_key /etc/nginx/cert.key;
ssl on;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
ssl_prefer_server_ciphers on;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass XX_REMOTE_URL_XX;
proxy_read_timeout 600;
proxy_redirect off;
}
location ~ ^/verdaccio/(.*)$ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header X-NginX-Proxy true;
proxy_pass XX_REMOTE_URL_XX$1;
proxy_redirect off;
}
}

View file

@ -0,0 +1,5 @@
#!/bin/bash
sed -i -e "s|XX_REMOTE_URL_XX|$REMOTE_URL|g" /etc/nginx/conf.d/default.conf
exec nginx -g "daemon off;"

View file

@ -0,0 +1,3 @@
FROM tutum/nginx
RUN rm /etc/nginx/sites-enabled/default
ADD sites-enabled /etc/nginx/sites-enabled

View file

@ -0,0 +1,14 @@
server {
listen 80 default_server;
access_log /var/log/nginx/verdaccio.log;
charset utf-8;
location / {
proxy_pass http://verdaccio:4873/;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_ssl_session_reuse off;
proxy_set_header Host $http_host;
proxy_redirect off;
}
}

View file

@ -0,0 +1,24 @@
services:
verdaccio:
image: verdaccio/verdaccio:nightly-master
container_name: verdaccio_root_path
ports:
- '4873:4873'
volumes:
- verdaccio:/verdaccio
nginx:
restart: always
build: conf/nginx
ports:
- '80:80'
volumes:
- /www/public
volumes_from:
- verdaccio
links:
- verdaccio:verdaccio
volumes:
verdaccio:
driver: local