sinopia

NPM 사설 저장소 만들기

code.ryan.lee@gmail.com

Introduction

SVN -> git

모듈화

회사 코드를 외부 시스템에?

Introduction

  1. [NPM] Make Private NPM Registry with sinopia - NPM 사설 저장소 만들기

  2. [Gitlab] CI / CD with Gitlab Runner

  3. [NPM / Gitlab] Build, Test and Deploy Private Node Package with Gitlab

Package manager

언어별 패키지

  • npm - npm is the package manager for JavaScript and the world’s largest software registry.

  • pip - The PyPA recommended tool for installing Python packages.

  • composer - Dependency Manager for PHP.

  • gem - Find, install, and publish RubyGems.

  • bower - A package manager for the web.

sinopia

Install

$ npm i -g sinopia

$ sudo npm i -g sinopia

sinopia 서버를 사용하기 위해 전역으로 sinopia 모듈을 설치한다.

Usage

Run sinopia Server

$ sinopia

Usage

Run with custom config

1. 폴더 생성

$ mkdir ~/npm-registry && cd ~/npm-registry

앞으로 사설 NPM 저장소는

`npm-registry/`에서 관리된다.

Usage

Run with custom config

2. 설정 파일 복사

$ cp ~/.config/sinopia/config.yaml ./config.yaml

기본 설정 파일

`config.yaml`을 현재 위치로 복사한다.

Usage

Run with custom config

3. config.yml로 서버 구동

$ sinopia ./config.yaml
 warn  --- config file  - /home/lsh/npm-registry/config.yaml
 warn  --- http address - http://localhost:4873/

output:

conifg.yaml

Host

listen: 0.0.0.0:4873
  • 0.0.0.0:4873 - listen on all addresses
  • https://example.org:4873 - https 이용
  • [::1]:4873  - ipv6 이용

conifg.yaml

User

`$ npm publish` 시 인증을 위한 사용자를 추가한다.

http://10.222.222.227:4873에 접근 후 로그인할 사용자이기도 하다.

users:
  admin:
    password: 5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8
$ node

> crypto.createHash('sha1').update('password').digest('hex')
'5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8'

Run with config.yaml

$ sinopia ./config.yaml

Run with config.yaml

http://10.222.222.227:4873

Run with config.yaml

$ nohup sinopia ./config.yaml &

Private NPM Registry

adduser

$ npm adduser --registry http://10.222.222.227:4873

Private NPM Registry

Create module

$ mkdir ~/my-module 
$ cd ~/my-module

$ wget https://gist.githubusercontent.com/SangHakLee/9513672e133c1027bc06a80c993d7025/raw/e5c0b7508702f974ebcb1dbfeacf205b8ba3814c/package.json

$ echo "console.log('my-module')" > index.js

Private NPM Registry

Publish

Private NPM Registry

Pubish

Private NPM Registry

Install module 

Conclusion

Make Graceful Node.js Module

Made with Slides.com