{"id":27243458,"url":"https://github.com/dalee/comrade-pavlik2","last_synced_at":"2025-06-15T00:04:24.760Z","repository":{"id":57600686,"uuid":"91539039","full_name":"Dalee/comrade-pavlik2","owner":"Dalee","description":"Private package registry: NPM, Yarn or Composer","archived":false,"fork":false,"pushed_at":"2019-01-25T11:21:19.000Z","size":141,"stargazers_count":16,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-10T20:50:45.842Z","etag":null,"topics":["composer","npm","private-repository","yarn"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Dalee.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-17T05:59:02.000Z","updated_at":"2020-02-23T20:19:36.000Z","dependencies_parsed_at":"2022-09-16T18:51:43.836Z","dependency_job_id":null,"html_url":"https://github.com/Dalee/comrade-pavlik2","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/Dalee/comrade-pavlik2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dalee%2Fcomrade-pavlik2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dalee%2Fcomrade-pavlik2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dalee%2Fcomrade-pavlik2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dalee%2Fcomrade-pavlik2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Dalee","download_url":"https://codeload.github.com/Dalee/comrade-pavlik2/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dalee%2Fcomrade-pavlik2/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259901382,"owners_count":22929224,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["composer","npm","private-repository","yarn"],"created_at":"2025-04-10T20:36:56.389Z","updated_at":"2025-06-15T00:04:24.740Z","avatar_url":"https://github.com/Dalee.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/Dalee/comrade-pavlik2.svg?branch=master)](https://travis-ci.org/Dalee/comrade-pavlik2)\n[![Go Report Card](https://goreportcard.com/badge/github.com/Dalee/comrade-pavlik2)](https://goreportcard.com/report/github.com/Dalee/comrade-pavlik2)\n[![codebeat badge](https://codebeat.co/badges/546e6f28-3500-4d4e-8ead-a4405ec029a4)](https://codebeat.co/projects/github-com-dalee-comrade-pavlik2-master)\n\n\n# Private package registry: NPM, Yarn or Composer\n\n![logo from wikipedia](pavlik.png)\n\u003e Photo is taken from Wikipedia.\n\nMeet [Comrade Pavlik](https://en.wikipedia.org/wiki/Pavlik_Morozov).\nPrivate `composer`, `npm` or `yarn` package registry with \nGitLab instance as package backend.\n\n## Project goals\n\n * Private registry with GitLab instance as backend\n * Prevent leaving keys/tokens in Docker image\n * Access management via GitLab user tokens\n * Test npm/composer packages before publishing\n\n## Supported software\n\n * [GitLab](https://about.gitlab.com/) `\u003e= 8.5` (API `v3` and `v4` are supported)\n * [npm](https://github.com/npm/npm) `\u003e= 2.5`\n * [yarn](https://yarnpkg.com) `\u003e= 0.23.x`\n * [composer](https://getcomposer.org/) - any version should work without problems\n\n## Setup\n\nLet's assume:\n\n * You running GitLab instance as `gitlab.example.com`\n * You selected packages domain as `packages.example.com`\n * You created GitLab repository `gitlab.example.com/devops/packages.git`\n\n### Source repository\n \nSo, what you should put to `gitlab.example.com/devops/packages.git`?\nAll you have to do, just put `repoList.json` with simple structure:\n```\n[\n  {\n    \"acme\": \"git@gitlab.example.com/composer/my-package.git\",\n    \"uuid\": \"\u003crandom generated uuid-v4 #1\u003e\",\n    \"tags\": [\"composer\"]\n  },\n  {\n    \"acme\": \"https://gitlab.example.com/nodejs/my-package.git\",\n    \"uuid\": \"\u003crandom generated uuid-v4 #2\u003e\",\n    \"tags\": [\"npm\"]\n  }\n  ...\n]\n```\n\nWhere:\n * `acme` - scope name\n * `uuid` - UUID, will be used to format package download URL ([online generator](https://www.uuidgenerator.net/))\n * `tags` - define package type: currently supported: \"composer\" or \"npm\"\n\n\u003e Each private package should be described in `repoList.json`.\n\nFor `npm` or `yarn`, package name should be defined like this:\n```\n\"name\": \"@acme/my-package\",\n```\n\nFor `composer`, package name should be defined like this:\n```\n\"name\": \"acme/my-package\",\n```\n\n\u003e Actually, it's possible to shadow official Composer registry packages. \n\n### Running service\n\nYou have at least two options to configure Pavlik:\n * Put configuration options to `.env` file in project root\n * Put configuration options to environment variables\n\nConfiguration options:\n * `GITLAB_URL` - base GitLab endpoint - `http://gitlab.example.com`\n * `GITLAB_REPO_NAME` - namespace/project for repoList.json file - `devops/packages`\n * `GITLAB_FILE_NAMESPACE` - source namespace - `acme`\n * `GITLAB_REPO_FILE` - list of packages - `repoList.json`\n * `GITLAB_REPO_FILE_EXTRA_LIST` - optional, additional list of packages, comma-separated.\n\n\u003e To simplify deployment, you can use prebuild [docker image](https://hub.docker.com/r/dalee/comrade-pavlik2/) `dalee/comrade-pavlik2`.\n\nExample systemd unit:\n```\n[Unit]\nDescription=Comrade Pavlik service\nAfter=docker.service\nRequires=docker.service\n\n[Service]\nTimeoutStartSec=0\nRestart=always\nExecStartPre=-/usr/bin/docker stop %n\nExecStartPre=-/usr/bin/docker rm %n\nExecStart=/usr/bin/docker run --rm --name %n \\\n        -e \"GITLAB_URL=http://gitlab.example.com\" \\\n        -e \"GITLAB_REPO_NAME=devops/packages\" \\\n        -e \"GITLAB_REPO_FILE=repoList.json\" \\\n        -e \"GITLAB_FILE_NAMESPACE=acme\" \\\n        -e \"GITLAB_REPO_FILE_EXTRA_LIST=composerList.json,npmList.json\" \\\n        -p 8080:4000 \\\n        dalee/comrade-pavlik2:1.0.5\n\n[Install]\nWantedBy=multi-user.target\n```\n\u003e Please check image version, stable version is \u003e= 1.0.5\n\n### Project setup\n\nGrab user private token from `gitlab.example.com/profile/account` page.\n\n#### Composer \n\nIn project root or in `~/.composer` directory create `auth.json` with contents: \n```json\n{\n  \"http-basic\": {\n    \"packages.example.com\": {\n      \"username\": \"gitlab username\",\n      \"password\": \"gitlab user private token\"\n    }\n  }\n}\n```\n\nAdd repository definition to composer.json\n```\n\"repositories\": [{\n   \"type\": \"composer\",\n   \"url\": \"http://packages.example.com\"\n}]\n```\n\nIn order to allow composer use http protocol, add this parameter to composer.json:\n```\n\"config\": {\n    \"secure-http\": false\n}\n```\n\nAdd dependency:\n```\n\"require\": { \n    \"acme/my-package\": \"^1.0.0\" \n}\n```\n\n#### NPM/Yarn\n\nIn project root or in `~/` directory create `.npmrc` with contents:\n```\n@acme:registry=http://packages.example.com/\n//packages.example.com/:_authToken=\u003cgitlab user private token\u003e\nalways-auth=true\n```\n\nAdd dependency:\n```json\n\"dependencies\": {\n  \"@acme/my-package\": \"^1.0.0\"\n}\n```\n\n### CI/CD pipeline setup instructions\n\nDo not put `auth.json` and `.npmrc` under version control!\n * composer - set `COMPOSER_AUTH` environment variable with contents of `auth.json` file\n * npm - set `NPM_TOKEN` environment variable and create `.npmrc` with following contents:\n```\n@acme:registry=http://packages.example.com/\n//packages.example.com/:_authToken=${NPM_TOKEN}\n```\n * for `yarn`, `always-auth=true` option is required in `.npmrc`.\n\n#### CI/CD example\n\nSetup NPM_TOKEN environment variable for Build Task. \n(You can use parameters for `TeamCity` or EnvInjector plugin for `Jenkins`).\n\n`Dockerfile` steps (assuming project root is `/app` directory):\n```\n...\nWORKDIR /app\nCOPY package.json npm-shrinkwrap.json /app/\n\nRUN echo \"@acme:registry=http://packages.example.com/\\n\\\n//packages.example.com/:_authToken=\\${NPM_TOKEN}\" \u003e /app/.npmrc\n\nARG NPM_TOKEN\nRUN npm install --silent\n...\n```\n\nAnd pass `NPM_TOKEN` environment variable for image build command:\n```\ndocker build --build-arg NPM_TOKEN=${NPM_TOKEN} .\n```\n\n\u003e Do not hardcode token into `--build-arg NPM_TOKEN=\u003ctoken\u003e`, use CI/CD environment \nvariables, otherwise you may leak your token.\n\n## Web UI\n\nDepending on access level, private token may have access to a lot of repositories. \nNot all of them are useful, so Pavlik caches repository list for a relatively small \namount of time (exactly 30 min, right now).\n\nTo clear or warm up cache, you can always use Web UI. Authorization credentials are \nthe same as for composer `username:token`.\n\n![warmed up cache](screenshot-cached.png)\n\n## Development\n\nPavlik uses wonderful `go-bindata` package for packing all assets\ninside of executable. So, before development you need to:\n\n * install all dependencies \n * create development version of templates\n\nThis can be done by using bundled `Makefile`\n```\n$ make install\n$ make template-debug\n```\n\n## Licensing\n\nComrade Pavlik is licensed under the Apache License, Version 2.0. \nSee LICENSE for the full license text.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdalee%2Fcomrade-pavlik2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdalee%2Fcomrade-pavlik2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdalee%2Fcomrade-pavlik2/lists"}