Skip to content

Commit

Permalink
refactor: 重构 all in one 打包逻辑 (#244)
Browse files Browse the repository at this point in the history
* perf: all in one

* perf: stash

* pref: 完成 allinone 重构

* pref: base finished

* pref: mv readme position

* docs: add docs

* docs: add url

* doc: add english readme

* doc: add readme

* perf: split volume

---------

Co-authored-by: fit2bot <[email protected]>
  • Loading branch information
ibuler and fit2bot authored Sep 10, 2024
1 parent 99a5ebe commit af028c7
Show file tree
Hide file tree
Showing 32 changed files with 499 additions and 1,800 deletions.
41 changes: 0 additions & 41 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,47 +7,6 @@ on:
- v4.*

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
component: [core, koko, lion, chen, web]
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: Get Version
run: |
echo "version=$(basename ${GITHUB_REF})" >> $GITHUB_ENV
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push Image
uses: docker/build-push-action@v5
with:
context: .
file: ${{ matrix.component }}/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ github.repository_owner }}/jms_${{ matrix.component }}:${{ env.version }}
${{ github.repository_owner }}/jms_${{ matrix.component }}:latest
ghcr.io/${{ github.repository_owner }}/jms_${{ matrix.component }}:${{ env.version }}
ghcr.io/${{ github.repository_owner }}/jms_${{ matrix.component }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max

allinone:
needs: build
runs-on: ubuntu-latest
Expand Down
229 changes: 21 additions & 208 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,227 +12,40 @@

--------------------------

## 环境要求
- MariaDB Server >= 10.6
- Redis Server >= 6.0

## 快速部署
```sh
# 测试环境可以使用,生产环境推荐外置数据
git clone --depth=1 https://github.com/jumpserver/Dockerfile.git
cd Dockerfile
cp config_example.conf .env
docker compose -f docker-compose-network.yml -f docker-compose-redis.yml -f docker-compose-mariadb.yml -f docker-compose-init-db.yml up
docker compose -f docker-compose-network.yml -f docker-compose-redis.yml -f docker-compose-mariadb.yml -f docker-compose.yml up -d

docker rm jms_init_db
```

## 标准部署

> 请先自行创建 数据库 和 Redis, 版本要求参考上面环境要求说明
```sh
# 自行部署 MySQL 可以参考 (https://docs.jumpserver.org/zh/master/install/setup_by_lb/#mysql)
# mysql 创建用户并赋予权限, 请自行替换 nu4x599Wq7u0Bn8EABh3J91G 为自己的密码
mysql -u root -p
```

```mysql
create database jumpserver default charset 'utf8';
create user 'jumpserver'@'%' identified by 'nu4x599Wq7u0Bn8EABh3J91G';
grant all on jumpserver.* to 'jumpserver'@'%';
flush privileges;
```
## all-in-one 快速部署
测试环境可以使用,生产环境推荐使用 标准部署

```sh
# 自行部署 Redis 可以参考 (https://docs.jumpserver.org/zh/master/install/setup_by_lb/#redis)
docker volume create jsdata &> /dev/null
docker volume create pgdata &> /dev/null
docker run --name jms_all \
-e SECRET_KEY=PleaseChangeMe \
-e BOOTSTRAP_TOKEN=PleaseChangeMe \
-v jsdata:/opt/data \
-v pgdata:/var/lib/postgresql \
-p 2222:2222 \
-p 80:80 jumpserver/jms_all
```

```sh
git clone --depth=1 https://github.com/jumpserver/Dockerfile.git
cd Dockerfile
cp config_example.conf .env
vi .env
**初始账号**
```bash
默认账号: admin
默认密码: ChangeMe
```
```vim
# 版本号可以自己根据项目的版本修改
VERSION=v4.1.0
# 构建参数, 支持 amd64, arm64, ppc64le, s390x
TARGETARCH=amd64

# Compose, Swarm 模式下修改 NETWORK_DRIVER=overlay
COMPOSE_PROJECT_NAME=jms
# COMPOSE_HTTP_TIMEOUT=3600
# DOCKER_CLIENT_TIMEOUT=3600
DOCKER_SUBNET=192.168.250.0/24
NETWORK_DRIVER=overlay
更多详见 allinone [README](allinone)

# 持久化存储
VOLUME_DIR=/opt/jumpserver

# 时区
TZ=Asia/Shanghai
# MySQL
DB_HOST=mysql
DB_PORT=3306
DB_USER=root
DB_PASSWORD=nu4x599Wq7u0Bn8EABh3J91G
DB_NAME=jumpserver
# Redis
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_PASSWORD=8URXPL2x3HZMi7xoGTdk3Upj
# Core
SECRET_KEY=B3f2w8P2PfxIAS7s4URrD9YmSbtqX4vXdPUL217kL9XPUOWrmy
BOOTSTRAP_TOKEN=7Q11Vz6R2J6BLAdO
LOG_LEVEL=ERROR
DOMAINS=
# 组件通信
CORE_HOST=http://core:8080
## 标准部署

# Lion
GUACD_LOG_LEVEL=error
GUA_HOST=guacd
GUA_PORT=4822
请使用 jumpserver installer 部署

# Web
HTTP_PORT=80
SSH_PORT=2222
https://docs.jumpserver.org/zh/v3/quick_start/

##
# SECRET_KEY 保护签名数据的密匙, 首次安装请一定要修改并牢记, 后续升级和迁移不可更改, 否则将导致加密的数据不可解密。
# BOOTSTRAP_TOKEN 为组件认证使用的密钥, 仅组件注册时使用。组件指 koko, lion, magnus, kael, chen ...
```
```sh
docker compose -f docker-compose-network.yml -f docker-compose-init-db.yml up
docker compose -f docker-compose-network.yml -f docker-compose.yml up -d

docker rm jms_init_db
```

## 集群部署

- Docker Swarm 集群环境
- 自行创建 MySQL 和 Redis, 参考上面环境要求说明
- 自行创建持久化共享存储目录 ( 例如 NFS, GlusterFS, Ceph 等 )

```sh
# 在所有 Docker Swarm Worker 节点挂载 NFS 或者其他共享存储, 例如 /data/jumpserver
# 注意: 需要手动创建所有需要挂载的持久化目录, Docker Swarm 模式不会自动创建所需的目录
mkdir -p /data/jumpserver/core/data
mkdir -p /data/jumpserver/chen/data
mkdir -p /data/jumpserver/lion/data
mkdir -p /data/jumpserver/koko/data
mkdir -p /data/jumpserver/lion/data
mkdir -p /data/jumpserver/web/data/logs
mkdir -p /data/jumpserver/web/download
```
```sh
git clone --depth=1 https://github.com/jumpserver/Dockerfile.git
cd Dockerfile
cp config_example.conf .env
vi .env
```
```vim
# 版本号可以自己根据项目的版本修改
VERSION=v4.1.0
# 构建参数, 支持 amd64, arm64, ppc64le, s390x
TARGETARCH=amd64
# Compose, Swarm 模式下修改 NETWORK_DRIVER=overlay
COMPOSE_PROJECT_NAME=jms
# COMPOSE_HTTP_TIMEOUT=3600
# DOCKER_CLIENT_TIMEOUT=3600
DOCKER_SUBNET=192.168.250.0/24
NETWORK_DRIVER=overlay
# 持久化存储
VOLUME_DIR=/opt/jumpserver
# 时区
TZ=Asia/Shanghai
# MySQL
DB_HOST=mysql
DB_PORT=3306
DB_USER=root
DB_PASSWORD=nu4x599Wq7u0Bn8EABh3J91G
DB_NAME=jumpserver
# Redis
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_PASSWORD=8URXPL2x3HZMi7xoGTdk3Upj
# Core
SECRET_KEY=B3f2w8P2PfxIAS7s4URrD9YmSbtqX4vXdPUL217kL9XPUOWrmy
BOOTSTRAP_TOKEN=7Q11Vz6R2J6BLAdO
LOG_LEVEL=ERROR
DOMAINS=
# 组件通信
CORE_HOST=http://core:8080
# Lion
GUACD_LOG_LEVEL=error
GUA_HOST=guacd
GUA_PORT=4822
# Web
HTTP_PORT=80
SSH_PORT=2222
##
# SECRET_KEY 保护签名数据的密匙, 首次安装请一定要修改并牢记, 后续升级和迁移不可更改, 否则将导致加密的数据不可解密。
# BOOTSTRAP_TOKEN 为组件认证使用的密钥, 仅组件注册时使用。组件指 koko, lion, magnus, kael, chen ...
```
```sh
# 生成 docker stack 部署所需文件
docker compose -f docker-compose-network.yml -f docker-compose-init-db.yml config | sed '/published:/ s/"//g' | sed "/name:/d" > docker-stack-init-db.yml
docker compose -f docker-compose-network.yml -f docker-compose.yml config | sed '/published:/ s/"//g' | sed "/name:/d" > docker-stack.yml
```
```sh
# 初始化数据库
docker stack deploy -c docker-stack-init-db.yml jumpserver
docker service ls
docker service ps jumpserver_init_db

# 根据查到的 Worker 节点, 到对应节点查看初始化日志
```
```sh
# 启动 JumpServer 应用
docker stack deploy -c docker-stack.yml jumpserver
docker service ls
```
```sh
# 扩容缩容
docker service update --replicas=2 jumpserver_koko # 扩容 koko 到 2 个副本
docker service update --replicas=4 jumpserver_lion # 扩容 lion 到 2 个副本
# ...
```

## Build
```sh
# 如果希望手动构建镜像, 可以使用下面的命令
cd Dockerfile
cp config_example.conf .env
vi .env
```
```vim
# 构建参数, 支持 amd64/arm64
TARGETARCH=amd64
```
```bash
docker compose -f docker-compose-build.yml up
```
JumpServer 支持 swarm 方式部署,但目前不太推荐用于生产环境,除非你对此熟悉 .

## 初始账号
- 默认账号: `admin`
- 默认密码: `ChangeMe`
详见 swarm [README](swarm)
Loading

0 comments on commit af028c7

Please sign in to comment.