├── Dockerfile ├── LICENSE ├── README.md └── assets ├── init └── setup ├── couchdb.ini ├── install └── kappa.json /Dockerfile: -------------------------------------------------------------------------------- 1 | # DOCKER-VERSION 1.2.0 2 | # DESCRIPTION npm registry 3 | # TO_BUILD docker build -t 'npm-registry' . 4 | # TO_RUN docker run -p 5984:5984 -p 80:80 npm-registry 5 | 6 | FROM ubuntu:14.04 7 | 8 | MAINTAINER Konstantin Burykin 9 | 10 | ADD assets/setup /app/setup 11 | RUN chmod 755 /app/setup/install 12 | RUN /app/setup/install 13 | 14 | ADD assets/init /app/init 15 | RUN chmod 755 /app/init 16 | 17 | EXPOSE 5984 80 18 | 19 | VOLUME ["/var/lib/couchdb"] 20 | 21 | ENTRYPOINT ["/app/init"] 22 | CMD ["app:start"] 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Konstantin Burykin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Notice 2 | 3 | Please read deprecation notice in official repository https://github.com/npm/npm-registry-couchapp 4 | 5 | And if you know actively developing fork give me to know. 6 | 7 | # Contents 8 | - [Introduction](#introduction) 9 | - [Version](#version) 10 | - [Installation](#installation) 11 | - [Quick Start](#quick-start) 12 | - [Configuration](#configuration) 13 | - [Data Store](#data-store) 14 | - [Upgrading](#upgrading) 15 | - [Thanks](#thanks) 16 | 17 | # Introduction 18 | Dockerfile to build image with npm registry proxied with kappa. 19 | 20 | ## Version 21 | Current Version: 2.6.12 22 | 23 | # Installation 24 | 25 | Pull the latest or specific version of the image from the docker index. 26 | This is the recommended method of installation as it is easier to update image 27 | in the future. 28 | These builds are performed by the **Docker Trusted Build** service. 29 | 30 | ```bash 31 | docker pull burkostya/npm-registry:2.6.12 32 | ``` 33 | 34 | Alternately you can build the image yourself. 35 | 36 | ```bash 37 | git clone https://github.com/burkostya/npm-registry.git 38 | cd npm-registry 39 | docker build -t '/npm-registry' . 40 | ``` 41 | 42 | # Quick Start 43 | Run container 44 | 45 | ```bash 46 | docker run --name='npm-registry' -i -t --rm \ 47 | -p 5984:5984 -p 80:80 \ 48 | burkostya/npm-registry:2.6.12 49 | ``` 50 | 51 | Couchdb with installed couchapp now available on http://localhost:5984. 52 | 53 | Credentials: 54 | 55 | * username: admin 56 | * password: password 57 | 58 | You can set your login and password for couchdb admin: 59 | 60 | ```bash 61 | docker run --name='npm-registry' -i -t --rm \ 62 | -e 'COUCHDB_ADMIN_LOGIN=' \ 63 | -e 'COUCHDB_ADMIN_PASSWORD=' \ 64 | -p 5984:5984 -p 80:80 \ 65 | burkostya/npm-registry:2.6.12 66 | ``` 67 | 68 | Kappa is exposed on port 80. You can use it by setting option in .npmrc: 69 | 70 | ```bash 71 | npm config set registry http://localhost 72 | ``` 73 | 74 | or adding option to every command: 75 | 76 | ``` 77 | npm --registry http://localhost 78 | ``` 79 | 80 | # Configuration 81 | 82 | ## Data Store 83 | For data persistency you should mount a volume 84 | 85 | ```bash 86 | /var/lib/couchdb 87 | ``` 88 | 89 | Volumes can be mounted in docker by specifying the **'-v'** 90 | option in the docker run command. 91 | 92 | ```bash 93 | mkdir /opt/data/npm-registry 94 | docker run --name='npm-registry' -d \ 95 | -p 5984:5984 -p 80:80 \ 96 | -v /opt/data/npm-registry:/var/lib/couchdb \ 97 | burkostya/npm-registry:2.6.12 98 | 99 | ``` 100 | 101 | # Upgrading 102 | 103 | To upgrade to newer couchapp, follow this steps: 104 | 105 | - Update the docker image. 106 | 107 | ```bash 108 | docker pull burkostya/npm-registry:2.6.12 109 | ``` 110 | 111 | - Stop the currently running image 112 | 113 | ```bash 114 | docker stop npm-registry 115 | docker rm npm-registry 116 | ``` 117 | 118 | - Backup the application data just by coping content of mounted volume 119 | 120 | ```bash 121 | cp -r /opt/data/npm-registry /some/npm/backup/dir/ 122 | ``` 123 | 124 | - Start the image 125 | 126 | ```bash 127 | docker run --name npm-registry -d \ 128 | -e 'COUCHDB_ADMIN_LOGIN=' \ 129 | -e 'COUCHDB_ADMIN_PASSWORD=' \ 130 | -p 5984:5984 -p 80:80 \ 131 | -v /opt/data/npm-registry:/var/lib/couchdb \ 132 | burkostya/npm-registry:2.6.12 133 | ``` 134 | 135 | # Thanks 136 | 137 | * @sameersbn for awesome template of container configuration 138 | -------------------------------------------------------------------------------- /assets/init: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | COUCHAPP_LOCAL_PATH=/opt/couchapp 6 | KAPPA_LOCAL_PATH=/opt/kappa 7 | 8 | LOGIN=${COUCHDB_ADMIN_LOGIN:-admin} 9 | PASSWORD=${COUCHDB_ADMIN_PASSWORD:-password} 10 | CREDENTIALS="${LOGIN}:$(echo ${PASSWORD} | sed -e "s,/,%2F,g" )" 11 | HOSTNAME=localhost 12 | PORT=5984 13 | HOST="${HOSTNAME}:${PORT}" 14 | REGISTRY_URL="http://${CREDENTIALS}@${HOST}/registry" 15 | REGISTRY_SETTING="--npm-registry-couchapp:couch=${REGISTRY_URL}" 16 | 17 | # do not prompt coping ddoc from scratch to app 18 | export NO_PROMPT=true 19 | 20 | appStart () { 21 | 22 | /usr/bin/supervisord -c /etc/supervisor/supervisord.conf 23 | 24 | echo "Starting couchdb server..." 25 | supervisorctl start couchdb >/dev/null 26 | 27 | echo "Waiting for couchdb..." 28 | local timeout=20 29 | while ! curl -X GET http://localhost:5984/ >/dev/null 30 | do 31 | timeout=$(expr $timeout - 1) 32 | if [ $timeout -eq 0 ]; then 33 | echo "Failed to start couchdb" 34 | exit 1 35 | fi 36 | sleep 1 37 | done 38 | 39 | # create database 40 | local db_response="$(curl -X PUT -s -S http://${HOST}/registry)" 41 | if [ "${db_response}" = '{"ok":true}' ]; then 42 | echo "Database 'registry' created" 43 | else 44 | echo "Database 'registry' already exists" 45 | fi 46 | 47 | # create admin user 48 | curl -X PUT -s -S http://${HOST}/_config/admins/${LOGIN} -d '"'"${PASSWORD}"'"' 49 | 50 | # install couchapp 51 | cd "${COUCHAPP_LOCAL_PATH}" 52 | 53 | npm start "${REGISTRY_SETTING}" >/dev/null 54 | npm run load "${REGISTRY_SETTING}" >/dev/null 55 | npm run copy "${REGISTRY_SETTING}" >/dev/null 56 | 57 | echo "Couchapp installed" 58 | 59 | kappa -c /app/setup/kappa.json 60 | } 61 | 62 | appHelp () { 63 | echo "Available options:" 64 | echo " app:start - Starts the npm registry (default)" 65 | echo " app:help - Displays the help" 66 | echo " [command] - Execute the specified linux command eg. bash" 67 | } 68 | 69 | case "$1" in 70 | app:start) 71 | appStart 72 | ;; 73 | app:help) 74 | appHelp 75 | ;; 76 | *) 77 | if [ -x $1 ]; then 78 | $1 79 | else 80 | prog=$(which $1) 81 | if [ -n "${prog}" ] ; then 82 | shift 1 83 | $prog $@ 84 | else 85 | appHelp 86 | fi 87 | fi 88 | ;; 89 | esac 90 | 91 | exit 0 92 | -------------------------------------------------------------------------------- /assets/setup/couchdb.ini: -------------------------------------------------------------------------------- 1 | ; CouchDB Configuration Settings 2 | 3 | ; Custom settings should be made in this file. They will override settings 4 | ; in default.ini, but unlike changes made to default.ini, this file won't be 5 | ; overwritten on server upgrade. 6 | 7 | [couchdb] 8 | ;max_document_size = 4294967296 ; bytes 9 | delayed_commits = false 10 | 11 | [httpd] 12 | ;port = 5984 13 | bind_address = 0.0.0.0 14 | ; Options for the MochiWeb HTTP server. 15 | ;server_options = [{backlog, 128}, {acceptor_pool_size, 16}] 16 | ; For more socket options, consult Erlang's module 'inet' man page. 17 | ;socket_options = [{recbuf, 262144}, {sndbuf, 262144}, {nodelay, true}] 18 | secure_rewrites = false 19 | 20 | 21 | ; Uncomment next line to trigger basic-auth popup on unauthorized requests. 22 | ;WWW-Authenticate = Basic realm="administrator" 23 | 24 | ; Uncomment next line to set the configuration modification whitelist. Only 25 | ; whitelisted values may be changed via the /_config URLs. To allow the admin 26 | ; to change this value over HTTP, remember to include {httpd,config_whitelist} 27 | ; itself. Excluding it from the list would require editing this file to update 28 | ; the whitelist. 29 | ;config_whitelist = [{httpd,config_whitelist}, {log,level}, {etc,etc}] 30 | 31 | [query_servers] 32 | ;nodejs = /usr/local/bin/couchjs-node /path/to/couchdb/share/server/main.js 33 | 34 | 35 | [httpd_global_handlers] 36 | ;_google = {couch_httpd_proxy, handle_proxy_req, <<"http://www.google.com">>} 37 | 38 | [couch_httpd_auth] 39 | ; If you set this to true, you should also uncomment the WWW-Authenticate line 40 | ; above. If you don't configure a WWW-Authenticate header, CouchDB will send 41 | ; Basic realm="server" in order to prevent you getting logged out. 42 | ; require_valid_user = false 43 | public_fields = appdotnet, avatar, avatarMedium, avatarLarge, date, email, fields, freenode, fullname, github, homepage, name, roles, twitter, type, _id, _rev 44 | users_db_public = true 45 | 46 | [log] 47 | ;level = debug 48 | 49 | [log_level_by_module] 50 | ; In this section you can specify any of the four log levels 'none', 'info', 51 | ; 'error' or 'debug' on a per-module basis. See src/*/*.erl for various 52 | ; modules. 53 | ;couch_httpd = error 54 | 55 | 56 | [os_daemons] 57 | ; For any commands listed here, CouchDB will attempt to ensure that 58 | ; the process remains alive. Daemons should monitor their environment 59 | ; to know when to exit. This can most easily be accomplished by exiting 60 | ; when stdin is closed. 61 | ;foo = /path/to/command -with args 62 | 63 | [daemons] 64 | ; enable SSL support by uncommenting the following line and supply the PEM's below. 65 | ; the default ssl port CouchDB listens on is 6984 66 | ; httpsd = {couch_httpd, start_link, [https]} 67 | 68 | [ssl] 69 | ;cert_file = /full/path/to/server_cert.pem 70 | ;key_file = /full/path/to/server_key.pem 71 | ;password = somepassword 72 | ; set to true to validate peer certificates 73 | verify_ssl_certificates = false 74 | ; Path to file containing PEM encoded CA certificates (trusted 75 | ; certificates used for verifying a peer certificate). May be omitted if 76 | ; you do not want to verify the peer. 77 | ;cacert_file = /full/path/to/cacertf 78 | ; The verification fun (optional) if not specified, the default 79 | ; verification fun will be used. 80 | ;verify_fun = {Module, VerifyFun} 81 | ; maximum peer certificate depth 82 | ssl_certificate_max_depth = 1 83 | 84 | ; To enable Virtual Hosts in CouchDB, add a vhost = path directive. All requests to 85 | ; the Virual Host will be redirected to the path. In the example below all requests 86 | ; to http://example.com/ are redirected to /database. 87 | ; If you run CouchDB on a specific port, include the port number in the vhost: 88 | ; example.com:5984 = /database 89 | [vhosts] 90 | ;example.com = /database/ 91 | 92 | [update_notification] 93 | ;unique notifier name=/full/path/to/exe -with "cmd line arg" 94 | 95 | ; To create an admin account uncomment the '[admins]' section below and add a 96 | ; line in the format 'username = password'. When you next start CouchDB, it 97 | ; will change the password to a hash (so that your passwords don't linger 98 | ; around in plain-text files). You can add more admin accounts with more 99 | ; 'username = password' lines. Don't forget to restart CouchDB after 100 | ; changing this. 101 | [admins] 102 | ;admin = mysecretpassword 103 | -------------------------------------------------------------------------------- /assets/setup/install: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | COUCHAPP_VERSION=v2.6.12 6 | COUCHAPP_GIT=https://github.com/npm/npm-registry-couchapp.git 7 | COUCHAPP_LOCAL_PATH=/opt/couchapp 8 | 9 | KAPPA_VERSION=v0.14.3 10 | KAPPA_GIT=https://github.com/krakenjs/kappa.git 11 | KAPPA_LOCAL_PATH=/opt/kappa 12 | 13 | # adding signing key 14 | apt-get update 15 | apt-get -y install curl apt-transport-https 16 | curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - 17 | 18 | # adding source 19 | echo 'deb https://deb.nodesource.com/node trusty main' \ 20 | > /etc/apt/sources.list.d/nodejs.list 21 | 22 | # installing rest software 23 | apt-get update 24 | apt-get install -y dnsutils git nodejs couchdb supervisor 25 | 26 | #install couchapp 27 | git clone "${COUCHAPP_GIT}" "${COUCHAPP_LOCAL_PATH}" 28 | cd "${COUCHAPP_LOCAL_PATH}" 29 | git checkout "${COUCHAPP_VERSION}" 30 | npm install 31 | 32 | #install kappa 33 | git clone "${KAPPA_GIT}" "${KAPPA_LOCAL_PATH}" 34 | cd "${KAPPA_LOCAL_PATH}" 35 | git checkout "${KAPPA_VERSION}" 36 | npm install -g . 37 | 38 | cp /app/setup/couchdb.ini /etc/couchdb/local.ini 39 | 40 | cat > /etc/supervisor/conf.d/couchdb.conf <