Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Nov 30, 2024
1 parent ac0d525 commit 7ee2846
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:18
FROM node:22

# Create app directory
WORKDIR /usr/src/app
Expand Down
63 changes: 52 additions & 11 deletions docs/deploy-in-docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,23 @@ docker build -t cnpmcore .
### MySQL

```bash
CNPMCORE_MYSQL_DATABASE=cnpmcore
CNPMCORE_MYSQL_HOST=127.0.0.1
CNPMCORE_MYSQL_PORT=3306
CNPMCORE_MYSQL_USER=your-db-user-name
CNPMCORE_MYSQL_PASSWORD=your-db-user-password
CNPMCORE_DATABASE_TYPE=MySQL
CNPMCORE_DATABASE_NAME=cnpmcore
CNPMCORE_DATABASE_HOST=127.0.0.1
CNPMCORE_DATABASE_PORT=3306
CNPMCORE_DATABASE_USER=your-db-user-name
CNPMCORE_DATABASE_PASSWORD=your-db-user-password
```

### PostgreSQL

```bash
CNPMCORE_DATABASE_TYPE=PostgreSQL
CNPMCORE_DATABASE_NAME=cnpmcore
CNPMCORE_DATABASE_HOST=127.0.0.1
CNPMCORE_DATABASE_PORT=5432
CNPMCORE_DATABASE_USER=your-db-user-name
CNPMCORE_DATABASE_PASSWORD=your-db-user-password
```

### Redis
Expand Down Expand Up @@ -134,14 +146,43 @@ docker run -p 7001:7001 -it --rm \

## 运行容器

### 基于 MySQL 运行

```bash
docker run -p 7001:7001 -it --rm \
-e CNPMCORE_CONFIG_REGISTRY=https://your-registry.com \
-e CNPMCORE_DATABASE_TYPE=MySQL \
-e CNPMCORE_DATABASE_NAME=cnpmcore \
-e CNPMCORE_DATABASE_HOST=127.0.0.1 \
-e CNPMCORE_DATABASE_PORT=3306 \
-e CNPMCORE_DATABASE_USER=your-db-user-name \
-e CNPMCORE_DATABASE_PASSWORD=your-db-user-password \
-e CNPMCORE_NFS_TYPE=s3 \
-e CNPMCORE_NFS_S3_CLIENT_ENDPOINT=https://your-s3-endpoint \
-e CNPMCORE_NFS_S3_CLIENT_BUCKET=your-bucket-name \
-e CNPMCORE_NFS_S3_CLIENT_ID=s3-ak \
-e CNPMCORE_NFS_S3_CLIENT_SECRET=s3-sk \
-e CNPMCORE_NFS_S3_CLIENT_FORCE_PATH_STYLE=true \
-e CNPMCORE_NFS_S3_CLIENT_DISABLE_URL=true \
-e CNPMCORE_REDIS_HOST=127.0.0.1 \
-e CNPMCORE_REDIS_PORT=6379 \
-e CNPMCORE_REDIS_PASSWORD=your-redis-password \
-e CNPMCORE_REDIS_DB=1 \
-e TZ=Asia/Shanghai \
--name cnpmcore-prod cnpmcore
```

### 基于 PostgreSQL 运行

```bash
docker run -p 7001:7001 -it --rm \
-e CNPMCORE_CONFIG_REGISTRY=https://your-registry.com \
-e CNPMCORE_MYSQL_DATABASE=cnpmcore \
-e CNPMCORE_MYSQL_HOST=127.0.0.1 \
-e CNPMCORE_MYSQL_PORT=3306 \
-e CNPMCORE_MYSQL_USER=your-db-user-name \
-e CNPMCORE_MYSQL_PASSWORD=your-db-user-password \
-e CNPMCORE_DATABASE_TYPE=PostgreSQL \
-e CNPMCORE_DATABASE_NAME=cnpmcore \
-e CNPMCORE_DATABASE_HOST=127.0.0.1 \
-e CNPMCORE_DATABASE_PORT=5432 \
-e CNPMCORE_DATABASE_USER=your-db-user-name \
-e CNPMCORE_DATABASE_PASSWORD=your-db-user-password \
-e CNPMCORE_NFS_TYPE=s3 \
-e CNPMCORE_NFS_S3_CLIENT_ENDPOINT=https://your-s3-endpoint \
-e CNPMCORE_NFS_S3_CLIENT_BUCKET=your-bucket-name \
Expand All @@ -161,7 +202,7 @@ docker run -p 7001:7001 -it --rm \

https://registry-demo.fengmk2.com:9443

管理员账号:cnpmcore_admin/12345678
管理员账号:`cnpmcore_admin/12345678`

通过 npm login 可以登录

Expand Down
10 changes: 5 additions & 5 deletions docs/elasticsearch-setup.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# 本地搭建 ES 搜索环境

## 单机搭建

### 下载安装 ES

首先我们进入 [ES 下载的官方网站](https://www.elastic.co/cn/downloads/elasticsearch) ,选择合适的操作系统版本并下载。下载完成后再适当位置解压并运行
Expand Down Expand Up @@ -50,7 +51,6 @@ path.logs: ./logs

此时,访问 http://localhost:5601 ,即可看到 Kibana 引导页面。


我们仅仅将其作为一个可视化的操作 API 的可视化工具,可以跳过其引导,访问 `/app/dev_tools#/console` 进入 devtool 页面。

## docker compose
Expand Down Expand Up @@ -247,14 +247,13 @@ ENCRYPTION_KEY=c34d38b3a14956121ff2170e5030b471551370178f43e5626eec58b04a30fae2
执行如下命令,启动服务

```bash
$ docker compose up
docker compose up
```

### 访问 Elastic

浏览器打开 http://localhost:5601/app/dev_tools#/console,默认账号为 `elastic` 密码为 .env 文件中定义的 `abcdef`


## 创建索引

ES 可以通过 Kibana devtool 进行数据的写入和查询操作。下面创建一个索引,`cnpmcore_packages` 为索引名称。
Expand Down Expand Up @@ -982,8 +981,9 @@ $ curl -X PUT https://r.cnpmjs.org/-/v1/search/sync/${pkgName}
### 删除一条数据

注意需要添加管理员 token,管理员在本地进行登录后,可通过查询 `~/.npmrc` 查看

```bash
$ curl -X DELETE -H 'Authorization: Bearer ${token}' http://localhost:7001/-/v1/search/${pkgName}
curl -X DELETE -H 'Authorization: Bearer ${token}' http://localhost:7001/-/v1/search/${pkgName}
```

### 修改数据
Expand All @@ -993,5 +993,5 @@ $ curl -X DELETE -H 'Authorization: Bearer ${token}' http://localhost:7001/-/v1/
### 查询

```bash
$ npm search colors --registry=http://localhost:7001
npm search colors --registry=http://localhost:7001
```

0 comments on commit 7ee2846

Please sign in to comment.