Skip to content

Commit dd2e422

Browse files
[Update]更新
1 parent 1d6b58b commit dd2e422

17 files changed

+192
-190
lines changed

.dockerignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.DS_Store
2+
.git

.env

+16-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
# 版本号可以自己根据项目的版本修改
22
Version=1.5.6
33

4-
# MYSQL_ROOT_PASSWORD 不支持纯数字, 字符串位数推荐大于等于 8
5-
MYSQL_ROOT_PASSWORD=oM0aevSQaH8Bd2Bgg5cX8lOd
4+
# MySQL
5+
DB_HOST=mysql
6+
DB_PORT=3306
7+
DB_USER=jumpserver
8+
DB_PASSWORD=nu4x599Wq7u0Bn8EABh3J91G
9+
DB_NAME=jumpserver
610

7-
# SECRET_KEY 不支持纯数字, 推荐字符串位数大于等于 50, 仅首次安装定义, 升级或者迁移请勿修改此项
8-
SECRET_KEY=B3f2w8P2PfxIAS7s4URrD9YmSbtqX4vXdPUL217kL9XPUOWrmy
11+
# Redis
12+
REDIS_HOST=redis
13+
REDIS_PORT=6379
14+
REDIS_PASSWORD=8URXPL2x3HZMi7xoGTdk3Upj
915

10-
# BOOTSTRAP_TOKEN 不支持纯数字, 推荐字符串位数大于等于 16, 仅首次安装定义, 升级或者迁移请勿修改
16+
# Core
17+
SECRET_KEY=B3f2w8P2PfxIAS7s4URrD9YmSbtqX4vXdPUL217kL9XPUOWrmy
1118
BOOTSTRAP_TOKEN=7Q11Vz6R2J6BLAdO
19+
20+
##
21+
# SECRET_KEY 保护签名数据的密匙, 首次安装请一定要修改并牢记, 后续升级和迁移不可更改, 否则将导致加密的数据不可解密。
22+
# BOOTSTRAP_TOKEN 为组件认证使用的密钥, 仅组件注册时使用。组件指 koko、guacamole

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.DS_Store
2+
.git/

core/Dockerfile

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
FROM centos:7
22
WORKDIR /opt
33
ARG Version=1.5.6
4-
ENV LC_ALL=en_US.UTF-8
4+
ENV Version=${Version} \
5+
LC_ALL=en_US.UTF-8
6+
57

68
RUN set -ex \
79
&& yum install -y epel-release wget \
8-
&& wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo \
9-
&& wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo \
10-
&& sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo \
11-
&& yum makecache \
1210
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
1311
&& yum -y install gcc nc \
1412
&& yum -y install python36 python36-devel unzip \
@@ -18,11 +16,11 @@ RUN set -ex \
1816
&& chown -R root:root jumpserver \
1917
&& yum -y install $(cat /opt/jumpserver/requirements/rpm_requirements.txt) \
2018
&& python3.6 -m venv /opt/py3 \
21-
&& echo -e "[easy_install]\nindex_url = https://mirrors.aliyun.com/pypi/simple/">> ~/.pydistutils.cfg \
2219
&& source /opt/py3/bin/activate \
2320
&& pip install wheel \
24-
&& pip install --upgrade pip setuptools -i https://mirrors.aliyun.com/pypi/simple/ \
25-
&& pip install -r /opt/jumpserver/requirements/requirements.txt -i https://mirrors.aliyun.com/pypi/simple/ \
21+
&& pip install --upgrade pip setuptools \
22+
&& pip install -r /opt/jumpserver/requirements/requirements.txt \
23+
&& yum remove -y wget gcc unzip \
2624
&& yum clean all \
2725
&& rm -rf /var/cache/yum/* \
2826
&& rm -rf /opt/${Version}.zip \

core/entrypoint.sh

+7-2
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,25 @@
22
#
33

44
sleep 5s
5-
while ! nc -z mysql 3306;
5+
while ! nc -z $DB_HOST $DB_PORT;
66
do
77
echo "wait for jms_mysql ready"
88
sleep 2s
99
done
1010

11+
while ! nc -z $REDIS_HOST $REDIS_PORT;
12+
do
13+
echo "wait for jms_redis ready"
14+
sleep 2s
15+
done
16+
1117
if [ ! -f "/opt/jumpserver/config.yml" ]; then
1218
cp /opt/jumpserver/config_example.yml /opt/jumpserver/config.yml
1319
sed -i "s/SECRET_KEY:/SECRET_KEY: $SECRET_KEY/g" /opt/jumpserver/config.yml
1420
sed -i "s/BOOTSTRAP_TOKEN:/BOOTSTRAP_TOKEN: $BOOTSTRAP_TOKEN/g" /opt/jumpserver/config.yml
1521
sed -i "s/# DEBUG: true/DEBUG: false/g" /opt/jumpserver/config.yml
1622
sed -i "s/# LOG_LEVEL: DEBUG/LOG_LEVEL: ERROR/g" /opt/jumpserver/config.yml
1723
sed -i "s/# SESSION_EXPIRE_AT_BROWSER_CLOSE: false/SESSION_EXPIRE_AT_BROWSER_CLOSE: true/g" /opt/jumpserver/config.yml
18-
sed -i "s/DB_ENGINE: mysql/DB_HOST: $DB_ENGINE/g" /opt/jumpserver/config.yml
1924
sed -i "s/DB_HOST: 127.0.0.1/DB_HOST: $DB_HOST/g" /opt/jumpserver/config.yml
2025
sed -i "s/DB_PORT: 3306/DB_PORT: $DB_PORT/g" /opt/jumpserver/config.yml
2126
sed -i "s/DB_USER: jumpserver/DB_USER: $DB_USER/g" /opt/jumpserver/config.yml

docker-compose-build.yml

+30-16
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,40 @@
11
version: '3'
22
services:
33
mysql:
4-
image: mysql:5.7
4+
build:
5+
context: .
6+
dockerfile: mysql/Dockerfile
7+
args:
8+
Version: ${Version}
9+
image: jms_mysql:${Version}
510
container_name: jms_mysql
611
restart: always
712
tty: true
813
environment:
9-
MYSQL_ROOT_PASSWORD: $MYSQL_ROOT_PASSWORD
10-
MYSQL_DATABASE: jumpserver
11-
command: --character-set-server=utf8
14+
DB_PORT: $DB_PORT
15+
DB_USER: $DB_USER
16+
DB_PASSWORD: $DB_PASSWORD
17+
DB_NAME: $DB_NAME
1218
volumes:
1319
- mysql-data:/var/lib/mysql
1420
networks:
1521
- jumpserver
1622

1723
redis:
18-
image: redis:alpine
24+
build:
25+
context: .
26+
dockerfile: redis/Dockerfile
27+
args:
28+
Version: ${Version}
29+
image: jms_redis:${Version}
1930
container_name: jms_redis
2031
restart: always
2132
tty: true
33+
environment:
34+
REDIS_PORT: $REDIS_PORT
35+
REDIS_PASSWORD: $REDIS_PASSWORD
2236
volumes:
23-
- redis-data:/data
37+
- redis-data:/var/lib/redis/
2438
networks:
2539
- jumpserver
2640

@@ -37,13 +51,14 @@ services:
3751
environment:
3852
SECRET_KEY: $SECRET_KEY
3953
BOOTSTRAP_TOKEN: $BOOTSTRAP_TOKEN
40-
DB_ENGINE: mysql
41-
DB_HOST: mysql
42-
DB_PORT: 3306
43-
DB_USER: root
44-
DB_PASSWORD: $MYSQL_ROOT_PASSWORD
45-
DB_NAME: jumpserver
46-
REDIS_HOST: redis
54+
DB_HOST: $DB_HOST
55+
DB_PORT: $DB_PORT
56+
DB_USER: $DB_USER
57+
DB_PASSWORD: $DB_PASSWORD
58+
DB_NAME: $DB_NAME
59+
REDIS_HOST: $REDIS_HOST
60+
REDIS_PORT: $REDIS_PORT
61+
REDIS_PASSWORD: $REDIS_PASSWORD
4762
depends_on:
4863
- mysql
4964
- redis
@@ -59,7 +74,6 @@ services:
5974
dockerfile: koko/Dockerfile
6075
args:
6176
Version: ${Version}
62-
GOPROXY: https://goproxy.io
6377
image: jms_koko:${Version}
6478
container_name: jms_koko
6579
restart: always
@@ -72,7 +86,7 @@ services:
7286
- mysql
7387
- redis
7488
volumes:
75-
- koko-kyes:/opt/koko/data/keys
89+
- koko-keys:/opt/koko/data/keys
7690
ports:
7791
- 2222:2222
7892
networks:
@@ -133,7 +147,7 @@ volumes:
133147
media:
134148
mysql-data:
135149
redis-data:
136-
koko-kyes:
150+
koko-keys:
137151
guacamole-keys:
138152

139153
networks:

docker-compose.yml

+20-15
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
11
version: '3'
22
services:
33
mysql:
4-
image: mysql:5.7
4+
image: wojiushixiaobai/jms_mysql:${Version}
55
container_name: jms_mysql
66
restart: always
77
tty: true
88
environment:
9-
MYSQL_ROOT_PASSWORD: $MYSQL_ROOT_PASSWORD
10-
MYSQL_DATABASE: jumpserver
11-
command: --character-set-server=utf8
9+
DB_PORT: $DB_PORT
10+
DB_USER: $DB_USER
11+
DB_PASSWORD: $DB_PASSWORD
12+
DB_NAME: $DB_NAME
1213
volumes:
1314
- mysql-data:/var/lib/mysql
1415
networks:
1516
- jumpserver
1617

1718
redis:
18-
image: redis:alpine
19+
image: wojiushixiaobai/jms_redis:${Version}
1920
container_name: jms_redis
2021
restart: always
2122
tty: true
23+
environment:
24+
REDIS_PORT: $REDIS_PORT
25+
REDIS_PASSWORD: $REDIS_PASSWORD
2226
volumes:
23-
- redis-data:/data
27+
- redis-data:/var/lib/redis/
2428
networks:
2529
- jumpserver
2630

@@ -32,13 +36,14 @@ services:
3236
environment:
3337
SECRET_KEY: $SECRET_KEY
3438
BOOTSTRAP_TOKEN: $BOOTSTRAP_TOKEN
35-
DB_ENGINE: mysql
36-
DB_HOST: mysql
37-
DB_PORT: 3306
38-
DB_USER: root
39-
DB_PASSWORD: $MYSQL_ROOT_PASSWORD
40-
DB_NAME: jumpserver
41-
REDIS_HOST: redis
39+
DB_HOST: $DB_HOST
40+
DB_PORT: $DB_PORT
41+
DB_USER: $DB_USER
42+
DB_PASSWORD: $DB_PASSWORD
43+
DB_NAME: $DB_NAME
44+
REDIS_HOST: $REDIS_HOST
45+
REDIS_PORT: $REDIS_PORT
46+
REDIS_PASSWORD: $REDIS_PASSWORD
4247
depends_on:
4348
- mysql
4449
- redis
@@ -85,7 +90,7 @@ services:
8590
- mysql
8691
- redis
8792
volumes:
88-
- guacamole-key:/config/guacamole/keys
93+
- guacamole-keys:/config/guacamole/keys
8994
networks:
9095
- jumpserver
9196

@@ -112,7 +117,7 @@ volumes:
112117
media:
113118
mysql-data:
114119
redis-data:
115-
koko-kyes:
120+
koko-keys:
116121
guacamole-keys:
117122

118123
networks:

guacamole/Dockerfile

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
FROM centos:7
2-
WORKDIR /config
2+
WORKDIR /opt
33
ARG Version=1.5.6
4-
ENV LC_ALL=en_US.UTF-8 \
4+
ENV Version=${Version} \
5+
LC_ALL=en_US.UTF-8 \
56
GUAC_VER=1.0.0 \
67
TOMCAT_VER=9.0.30
78

89
RUN set -ex \
910
&& yum install -y epel-release wget \
10-
&& wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo \
11-
&& wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo \
12-
&& sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo \
13-
&& yum makecache \
1411
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
1512
&& mkdir /usr/local/lib/freerdp/ \
1613
&& ln -s /usr/local/lib/freerdp /usr/lib64/freerdp \
@@ -19,6 +16,7 @@ RUN set -ex \
1916
&& yum install -y cairo-devel libjpeg-turbo-devel libpng-devel uuid-devel \
2017
&& yum install -y ffmpeg-devel freerdp1.2-devel libvncserver-devel pulseaudio-libs-devel openssl-devel libvorbis-devel libwebp-devel \
2118
&& mkdir -p /config/guacamole /config/guacamole/lib /config/guacamole/extensions /config/guacamole/data/log/ \
19+
&& cd /config \
2220
&& wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-9/v${TOMCAT_VER}/bin/apache-tomcat-${TOMCAT_VER}.tar.gz \
2321
&& tar xf apache-tomcat-${TOMCAT_VER}.tar.gz \
2422
&& mv apache-tomcat-${TOMCAT_VER} tomcat9 \
@@ -52,6 +50,7 @@ RUN set -ex \
5250
&& wget https://github.com/ibuler/ssh-forward/releases/download/v0.0.5/linux-amd64.tar.gz \
5351
&& tar xf linux-amd64.tar.gz -C /bin/ \
5452
&& chmod +x /bin/ssh-forward \
53+
&& yum remove -y wget gcc make unzip \
5554
&& rm -rf /config/linux-amd64.tar.gz \
5655
&& rm -rf /config/docker-guacamole \
5756
&& yum clean all \

guacamole/entrypoint.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ done
3030
guacd &
3131
cd /config/tomcat9/bin && ./startup.sh
3232

33-
echo "Guacamole version 1.5.6, more see https://www.jumpserver.org"
33+
echo "Guacamole version $Version, more see https://www.jumpserver.org"
3434
echo "Quit the server with CONTROL-C."
3535

3636
if [ ! -f "/config/guacamole/data/log/info.log" ]; then

koko/Dockerfile

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
FROM alpine:3.11
1+
FROM centos:7
22
WORKDIR /opt
33
ARG Version=1.5.6
4+
ENV Version=${Version} \
5+
LC_ALL=en_US.UTF-8
46

57
RUN set -ex \
6-
&& sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/' /etc/apk/repositories \
7-
&& apk update \
8-
&& apk add -U tzdata \
9-
&& apk add curl mariadb-client \
10-
&& cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
11-
&& echo "Asia/Shanghai" > /etc/timezone \
8+
&& yum install -y wget \
9+
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
10+
&& yum -y localinstall --nogpgcheck https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-community-client-8.0.18-1.el7.x86_64.rpm https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-community-libs-8.0.18-1.el7.x86_64.rpm https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-community-common-8.0.18-1.el7.x86_64.rpm \
1211
&& wget https://github.com/jumpserver/koko/releases/download/${Version}/koko-master-linux-amd64.tar.gz \
1312
&& tar -xf koko-master-linux-amd64.tar.gz \
1413
&& mv kokodir koko \
1514
&& chown -R root:root koko \
1615
&& rm -rf koko-master-linux-amd64.tar.gz \
17-
&& apk del tzdata \
18-
&& rm -rf /var/cache/apk/*
16+
&& yum remove -y wget \
17+
&& yum clean all \
18+
&& rm -rf /var/cache/yum*
1919

2020
COPY koko/entrypoint.sh .
2121
RUN chmod 755 ./entrypoint.sh

koko/entrypoint.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22
#
33

44
sleep 5s

mysql/Dockerfile

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM centos:7
2+
WORKDIR /opt
3+
ARG Version=1.5.6
4+
ENV Version=${Version} \
5+
LC_ALL=en_US.UTF-8
6+
7+
RUN set -ex \
8+
&& yum install -y epel-release wget \
9+
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
10+
&& yum -y install mariadb-server \
11+
&& yum remove -y wget \
12+
&& yum clean all \
13+
&& rm -rf /var/cache/yum/*
14+
15+
COPY mysql/entrypoint.sh .
16+
RUN chmod 755 ./entrypoint.sh
17+
18+
CMD ["./entrypoint.sh"]

mysql/entrypoint.sh

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
#
3+
4+
function config_mysql {
5+
if [ $DB_PORT != 3306 ]; then
6+
if [ ! "$(cat /etc/my.cnf | grep port=)" ]; then
7+
sed -i "10i port=$DB_PORT" /etc/my.cnf
8+
else
9+
sed -i "s/port=.*/port=$DB_PORT/g" /etc/my.cnf
10+
fi
11+
fi
12+
}
13+
14+
if [ ! -d "/var/lib/mysql/$DB_NAME" ]; then
15+
config_mysql
16+
mysql_install_db --user=mysql --datadir=/var/lib/mysql --force
17+
mysqld_safe &
18+
sleep 5s
19+
mysql -uroot -e "create database $DB_NAME default charset 'utf8';grant all on $DB_NAME.* to '$DB_USER'@'%' identified by '$DB_PASSWORD';flush privileges;";
20+
mysql --version
21+
tail -f /var/log/mariadb/mariadb.log
22+
else
23+
config_mysql
24+
mysql --version
25+
mysqld_safe
26+
fi

0 commit comments

Comments
 (0)