-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
修改docker compose 增加自动编译docker镜像 优化readme
- Loading branch information
Showing
10 changed files
with
1,258 additions
and
884 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
PORT=1080 | ||
WSPATH=/vless | ||
UUID=13170fcc-1966-507d-bce9-532cc588fcf3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow | ||
name: Build Docker Image | ||
|
||
# 当 push 到 master 分支,或者创建以 v 开头的 tag 时触发,可根据需求修改 | ||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- v* | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE: BanKnight/nvless | ||
|
||
jobs: | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
|
||
# 这里用于定义 GITHUB_TOKEN 的权限 | ||
permissions: | ||
packages: write | ||
contents: read | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
# 登录到 GitHub Packages 容器仓库 | ||
# 注意 secrets.GITHUB_TOKEN 不需要手动添加,直接就可以用 | ||
- name: Log in to the Container registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# 根据输入自动生成 tag 和 label 等数据,说明见下 | ||
- name: Extract metadata for Docker | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE }} | ||
|
||
# 构建并上传 | ||
- name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# 基于Node.js 20版本的Slim镜像构建 | ||
FROM node:20-slim AS build-env | ||
|
||
# 安装 jemalloc | ||
RUN apt-get update && \ | ||
apt-get install -y --no-install-recommends \ | ||
libjemalloc2 && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
|
||
COPY . /app | ||
# 设置工作目录 | ||
WORKDIR /app | ||
|
||
# 安装项目依赖 | ||
RUN npm ci --omit=dev | ||
|
||
FROM gcr.io/distroless/nodejs20-debian12 | ||
|
||
COPY --from=build-env /usr/lib/x86_64-linux-gnu/libjemalloc.so.2 /usr/lib/x86_64-linux-gnu/ | ||
|
||
# 设置环境变量使 jemalloc 全局起效 | ||
ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2 | ||
|
||
COPY --from=build-env /app /app | ||
|
||
WORKDIR /app | ||
|
||
# 暴露应用程序使用的端口(根据你的应用程序进行修改) | ||
EXPOSE 3000 | ||
|
||
# 运行应用程序,这里不加载env文件了,交给用户自己搞定 | ||
CMD ["--import", "tsx", "src/index.ts"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,63 @@ | ||
# nvless | ||
nodejs vless | ||
## nvless | ||
|
||
一个用typescript实现的只使用ws链接的vless协议服务端。 | ||
|
||
### 为什么重复造轮子 | ||
|
||
+ 研究nodejs在这方面的极限 | ||
+ 研究nodejs中的内存和cpu的控制 | ||
+ 在已有vps的基础上,如何简化配置 | ||
|
||
### 特性 | ||
|
||
+ 支持 tcp 协议 | ||
+ 支持 udp 协议(需要完整测试) | ||
+ 支持 mux tcp 协议 | ||
+ 支持 mux udp 协议(需要完整测试) | ||
+ 内存:占用小 | ||
+ cpu:占用低 | ||
+ 支持 docker | ||
+ 支持:配置文件/环境变量 | ||
|
||
## 如何开始 | ||
|
||
## docker compose 部署 | ||
|
||
+ 下载文件 [docker-compose.yml](./docker-compose.yml) | ||
+ 修改配置文件: | ||
+ 端口:默认3000 | ||
+ uuid:默认 13170fcc-1966-507d-bce9-532cc588fcf3 | ||
+ 路径:默认 /nvless | ||
+ 启动:`docker-compose up -d` | ||
+ 注意:开启防火墙端口 | ||
+ 注意:要支持https,请部署在nginx之后,推荐使用 [1Panel](https://github.com/1Panel-dev/1Panel) 部署 | ||
+ nginx 配置参考: | ||
|
||
```nginx | ||
location = /nvless { | ||
proxy_pass http://127.0.0.1:3000; | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header REMOTE-HOST $remote_addr; | ||
proxy_set_header Upgrade $http_upgrade; | ||
proxy_set_header Connection "upgrade"; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
proxy_http_version 1.1; | ||
add_header Cache-Control no-cache; | ||
} | ||
``` | ||
|
||
### 本地调试 | ||
|
||
+ 拷贝 [.env.example](./.env.example) 一份为本地配置 `.env.local` | ||
+ 修改配置文件 | ||
+ 启动 | ||
|
||
```bash | ||
# 安装依赖 | ||
npm install | ||
|
||
# 启动服务 | ||
npm run test | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
version: '3' | ||
services: | ||
nvless: | ||
image: ghcr.io/banknight/nvless:main | ||
container_name: nvless | ||
restart: always | ||
ports: | ||
- 3000:3000 | ||
environment: | ||
- UUID=13170fcc-1966-507d-bce9-532cc588fcf3 | ||
- WSPATH=/nvless |
Oops, something went wrong.