[Docker系列·6]搭建基於Docker的NPM私服Sinopia
製作映象
Dockerfile
# Version: 0.0.1
FROM feuyeux/ubuntu-node
MAINTAINER Eric Han "feuyeux@gmail.com"
RUN apt-get -yq install make build-essential python python-dev
RUN npm install js-yaml sinopia@0.9.1
RUN adduser --disabled-password --gecos "" sinopia
RUN mkdir -p /opt/sinopia/storage
RUN chown -R sinopia:sinopia /opt/sinopia
USER sinopia
WORKDIR /opt/sinopia
ADD /config_gen.js /opt/sinopia/config_gen.js
ADD /start.sh /opt/sinopia/start.sh
CMD ["/opt/sinopia/start.sh"]
EXPOSE 4873
config_gen.js
#!/usr/bin/env nodejs
var config = require(`sinopia/lib/config_gen`)()
, yaml = require(`js-yaml`)
, fs = require(`fs`)
console.log(`Username: %s`, config.user)
console.log(`Password: %s`, config.pass)
fs.writeFileSync(`/tmp/config.yaml`, config.yaml)
start.sh
#!/bin/bash
nodejs /opt/sinopia/config_gen.js
cat /tmp/config.yaml
sed -e `s/#listen: localhost/listen: 0.0.0.0/` -e `s/allow_publish: admin/allow_publish: all/` /tmp/config.yaml > /opt/sinopia/config.yaml
nodejs /node_modules/sinopia/bin/sinopia --config /opt/sinopia/config.yaml
構建映象
[erichan@mars-centos7 ubuntu-sinopia]$ d build -t feuyeux/ubuntu-sinopia .
Sending build context to Docker daemon 5.12 kB
Sending build context to Docker daemon
Step 0 : FROM feuyeux/ubuntu-node
---> 7eb4cbfcf2e0
Step 1 : MAINTAINER Eric Han "feuyeux@gmail.com"
---> Using cache
---> bd62d7c3611c
Step 2 : RUN apt-get -yq install make build-essential python python-dev
---> Using cache
---> c960e53c1b40
Step 3 : RUN npm install js-yaml sinopia@0.9.1
---> Running in eed56456ae0e
npm http GET https://registry.npmjs.org/sinopia/0.9.1
npm http GET https://registry.npmjs.org/js-yaml
……
npm WARN prefer global sinopia@0.9.1 should be installed with -g
js-yaml@3.1.0 node_modules/js-yaml
├── esprima@1.0.4
└── argparse@0.1.15 (underscore@1.4.4, underscore.string@2.3.3)
sinopia@0.9.1 node_modules/sinopia
├── commander@2.3.0
├── async@0.9.0
├── semver@3.0.1
├── minimatch@1.0.0 (sigmund@1.0.0, lru-cache@2.5.0)
├── mkdirp@0.5.0 (minimist@0.0.8)
├── fs-ext@0.3.2
├── crypt3@0.1.5
├── cookies@0.5.0 (keygrip@1.0.1)
├── bunyan@1.0.0 (mv@2.0.3)
├── request@2.40.0 (json-stringify-safe@5.0.0, forever-agent@0.5.2, aws-sign2@0.5.0, oauth-sign@0.3.0, stringstream@0.0.4, tunnel-agent@0.4.0, qs@1.0.2, node-uuid@1.4.1, mime-types@1.0.2, tough-cookie@0.12.1, http-signature@0.10.0, form-data@0.1.4, hawk@1.1.1)
└── express@3.16.7 (basic-auth@1.0.0, merge-descriptors@0.0.2, cookie@0.1.2, escape-html@1.0.1, cookie-signature@1.0.4, fresh@0.2.2, range-parser@1.0.0, vary@0.1.0, media-typer@0.2.0, methods@1.1.0, parseurl@1.3.0, buffer-crc32@0.2.3, depd@0.4.4, proxy-addr@1.0.1, debug@1.0.4, commander@1.3.2, send@0.8.3, connect@2.25.7)
---> 78689f6f2b39
Removing intermediate container eed56456ae0e
Step 4 : RUN adduser --disabled-password --gecos "" sinopia
---> Running in 69e7239b6807
Adding user `sinopia` ...
Adding new group `sinopia` (1000) ...
Adding new user `sinopia` (1000) with group `sinopia` ...
Creating home directory `/home/sinopia` ...
Copying files from `/etc/skel` ...
---> 8db99c03a2ca
Removing intermediate container 69e7239b6807
Step 5 : RUN mkdir -p /opt/sinopia/storage
---> Running in c8df4c2dbb0b
---> 7dadbc492b3c
Removing intermediate container c8df4c2dbb0b
Step 6 : RUN chown -R sinopia:sinopia /opt/sinopia
---> Running in 227825ca7561
---> fec3907ca6c9
Removing intermediate container 227825ca7561
Step 7 : USER sinopia
---> Running in 1ed1ea8aff6e
---> e9edc497b77e
Removing intermediate container 1ed1ea8aff6e
Step 8 : WORKDIR /opt/sinopia
---> Running in daa0f3ac4383
---> 0b7bda3426ed
Removing intermediate container daa0f3ac4383
Step 9 : ADD /config_gen.js /opt/sinopia/config_gen.js
---> 25770258cbb3
Removing intermediate container 3a502127d038
Step 10 : ADD /start.sh /opt/sinopia/start.sh
---> 678434935c80
Removing intermediate container ddfc6aa3dceb
Step 11 : CMD ["/opt/sinopia/start.sh"]
---> Running in e3117e312f4c
---> 2acff7da72cc
Removing intermediate container e3117e312f4c
Step 12 : EXPOSE 4873
---> Running in a458160612cf
---> a1b8e9c0366f
Removing intermediate container a458160612cf
Successfully built a1b8e9c0366f
[erichan@mars-centos7 ubuntu-sinopia]$
執行sinopia
d run --name sinopia -d -p 4873:4873 -v /home/erichan/docker-room/ubuntu-sinopia/storage:/opt/sinopia/storage feuyeux/ubuntu-sinopia
測試sinopia
[erichan@mars-centos7 ubuntu-sinopia]$ d logs sinopia
[erichan@mars-centos7 ubuntu-sinopia]$ curl -i http://localhost:4873
HTTP/1.1 404 Not Found
X-Powered-By: Sinopia/0.9.1
Content-Type: text/html; charset=utf-8
Content-Length: 13
Vary: Accept-Encoding
X-Status-Cat: http://flic.kr/p/aV6juR
Date: Wed, 20 Aug 2014 14:28:21 GMT
Connection: keep-alive
Cannot GET /
Sinopia Client
[erichan@Eric-Mavericks ~]$ nano .bash_profile
alias dpm=`npm --registry="http://10.211.55.14:4873"`
[erichan@Eric-Mavericks arcas]$ npm install logsto
logsto@0.0.6 ../node_modules/logsto
[erichan@Eric-Mavericks arcas]$ dpm publish logsto
+ logsto@0.0.6
Sinopia Server flow
相關文章
- [Docker系列·2]搭建基於Docker的Nginx伺服器DockerNginx伺服器
- docker搭建Nexus搭建Maven私服DockerMaven
- 使用docker快速搭建gitlab私服DockerGitlab
- npm私服 verdaccio 搭建NPM
- 手把手教你搭建Docker Registry私服Docker
- [Prometheus+Grafana系列]基於docker-compose搭建PrometheusGrafanaDocker
- 基於Docker搭建LNMP環境DockerLNMP
- Llinux下搭建NPM私服LinuxNPM
- 利用nexus構建maven、docker、npm、gradle私服倉庫MavenDockerNPMGradle
- Linux 上部署 docker,基於 docker 搭建 lnmp 環境LinuxDockerLNMP
- 研發提效必備技能:手把手教你基於Docker搭建Maven私服倉庫DockerMaven
- 使用 docker + verdaccio 搭建npm私有倉庫DockerNPM
- 基於ECS快速搭建Docker環境Docker
- 用 Docker 十分鐘搭建出 Sentry 私服Docker
- 基於Linux的docker mysql主從搭建LinuxDockerMySql
- [nodejs/npm] 基於Docker建立Nodejs前端應用NodeJSNPMDocker前端
- Docker系列——利用gogs搭建屬於自己的git服務DockerGoGit
- [mysql/docker] 基於Docker安裝MYSQLMySqlDocker
- 基於 Docker 的 MySQL 主從複製搭建(真正弄懂)DockerMySql
- 基於docker 搭建redis環境—redis單機版DockerRedis
- Day2——基於ECS快速搭建Docker環境Docker
- 基於Docker的日誌分析平臺(二) 環境搭建Docker
- 阿里雲Ubuntu 16.04系統下用sinopia搭建npm私庫阿里UbuntuNPM
- 基於docker的蜜罐學習Docker
- 基於Docker的GoldenGate部署DockerGo
- Elasticsearch使用系列-Docker搭建Elasticsearch叢集ElasticsearchDocker
- [Docker系列·11]搭建ZooKeeper伺服器Docker伺服器
- 基於docker環境下搭建redis主從叢集DockerRedis
- 基於Docker搭建PHP+Nginx+MySQL開發環境DockerPHPNginxMySql開發環境
- 基於 DC2 和 Docker Compose 搭建 TiDBDockerTiDB
- 基於Docker搭建Jumpserver堡壘機操作實踐DockerServer
- 體驗有禮:基於ECS快速搭建Docker環境Docker
- centos7搭建基礎dockerCentOSDocker
- 基於 Docker 的 MySQL 主從複製搭建及原理(真正弄懂)DockerMySql
- 案例分享:基於Docker環境下的Jenkins搭建及使用DockerJenkins
- quay.io/coreos/etcd 基於Docker映象的叢集搭建Docker
- 雲端計算 之 Docker--Docker 應用實戰案例--基於 registry 搭建私有倉庫Docker
- Docker容器的搭建Docker