diff --git a/Dockerfile b/Dockerfile index bb83ae686..f88dbe4b5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,6 @@ -FROM registry.fit2cloud.com/public/python:v3 as stage-build -MAINTAINER Jumpserver Team +# 编译代码 +FROM python:3.8.6-slim as stage-build +MAINTAINER JumpServer Team ARG VERSION ENV VERSION=$VERSION @@ -8,29 +9,30 @@ ADD . . RUN cd utils && bash -ixeu build.sh -FROM registry.fit2cloud.com/public/python:v3 +# 构建运行时环境 +FROM python:3.8.6-slim ARG PIP_MIRROR=https://pypi.douban.com/simple ENV PIP_MIRROR=$PIP_MIRROR ARG PIP_JMS_MIRROR=https://pypi.douban.com/simple ENV PIP_JMS_MIRROR=$PIP_JMS_MIRROR -ARG MYSQL_MIRROR=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql57-community-el6/ -ENV MYSQL_MIRROR=$MYSQL_MIRROR WORKDIR /opt/jumpserver -COPY ./requirements ./requirements -RUN useradd jumpserver -RUN wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo -RUN yum -y install epel-release && \ - echo -e "[mysql]\nname=mysql\nbaseurl=${MYSQL_MIRROR}\ngpgcheck=0\nenabled=1" > /etc/yum.repos.d/mysql.repo -RUN yum -y install $(cat requirements/rpm_requirements.txt) -RUN pip install --upgrade pip==20.2.4 setuptools==49.6.0 wheel==0.34.2 -i ${PIP_MIRROR} && \ - pip config set global.index-url ${PIP_MIRROR} -RUN pip install --no-cache-dir $(grep 'jms' requirements/requirements.txt) -i ${PIP_JMS_MIRROR} -RUN pip install --no-cache-dir -r requirements/requirements.txt +COPY ./requirements/deb_buster_requirements.txt ./requirements/deb_buster_requirements.txt +RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list \ + && sed -i 's/security.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list \ + && apt update +RUN grep -v '^#' ./requirements/deb_buster_requirements.txt | xargs apt -y install + +COPY ./requirements/requirements.txt ./requirements/requirements.txt +RUN pip install --upgrade pip==20.2.4 setuptools==49.6.0 wheel==0.34.2 -i ${PIP_MIRROR} \ + && pip config set global.index-url ${PIP_MIRROR} \ + && pip install --no-cache-dir $(grep 'jms' requirements/requirements.txt) -i ${PIP_JMS_MIRROR} \ + && pip install --no-cache-dir -r requirements/requirements.txt COPY --from=stage-build /opt/jumpserver/release/jumpserver /opt/jumpserver -RUN mkdir -p /root/.ssh/ && echo -e "Host *\n\tStrictHostKeyChecking no\n\tUserKnownHostsFile /dev/null" > /root/.ssh/config +RUN mkdir -p /root/.ssh/ \ + && echo -e "Host *\n\tStrictHostKeyChecking no\n\tUserKnownHostsFile /dev/null" > /root/.ssh/config RUN echo > config.yml VOLUME /opt/jumpserver/data diff --git a/apps/common/utils/common.py b/apps/common/utils/common.py index 382cd2412..25b2e771b 100644 --- a/apps/common/utils/common.py +++ b/apps/common/utils/common.py @@ -41,7 +41,7 @@ def timesince(dt, since='', default="just now"): 3 days, 5 hours. """ - if since is '': + if not since: since = datetime.datetime.utcnow() if since is None: diff --git a/requirements/deb_buster_requirements.txt b/requirements/deb_buster_requirements.txt new file mode 100644 index 000000000..5d873b060 --- /dev/null +++ b/requirements/deb_buster_requirements.txt @@ -0,0 +1,33 @@ +# common +gcc +cmake + +# mysql-client +default-libmysqlclient-dev + +# Pillow +# libffi-dev +# libfreetype6-dev +# libfribidi-dev +# libharfbuzz-dev +# libjpeg-turbo-progs +# libjpeg62-turbo-dev +# liblcms2-dev +# libopenjp2-7-dev +# libtiff5-dev +# libwebp-dev +# python3-tk +# zlib1g-dev + + +# ldap +openssl +libssl-dev +libldap2-dev +libsasl2-dev +libkrb5-dev +sqlite + +# ansible +sshpass + diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 29872d16a..391481090 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -58,7 +58,7 @@ pycryptodomex==3.9.9 pyotp==2.2.6 PyNaCl==1.2.1 python-dateutil==2.6.1 -python-gssapi==0.6.4 +#python-gssapi==0.6.4 pytz==2018.3 PyYAML==5.1 redis==3.5.3 diff --git a/requirements/rpm_requirements.txt b/requirements/rpm_requirements.txt index b6a192d1a..0501d2860 100644 --- a/requirements/rpm_requirements.txt +++ b/requirements/rpm_requirements.txt @@ -1 +1 @@ -gcc krb5-devel libtiff-devel libjpeg-devel libzip-devel freetype-devel lcms2-devel libwebp-devel tcl-devel tk-devel sshpass openldap-devel mariadb-devel mysql-community-devel mysql libffi-devel openssh-clients telnet openldap-clients +gcc make krb5-devel libtiff-devel libjpeg-devel libzip-devel freetype-devel lcms2-devel libwebp-devel tcl-devel tk-devel sshpass openldap-devel mariadb-devel mysql-community-devel mysql libffi-devel openssh-clients telnet openldap-clients