From b415ee051d2c5584a11c15d0012961f0d91e269d Mon Sep 17 00:00:00 2001 From: ibuler Date: Thu, 23 Sep 2021 10:26:39 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=8E=BB=E6=8E=89django.po?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 4 +++- apps/common/apps.py | 5 +++-- jms | 11 +++++++++++ requirements/deb_requirements.txt | 2 +- requirements/mac_requirements.txt | 2 +- requirements/rpm_requirements.txt | 2 +- 6 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index d8652be34..8adf20f14 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,12 +35,14 @@ RUN mkdir -p /root/.ssh/ \ && echo "Host *\n\tStrictHostKeyChecking no\n\tUserKnownHostsFile /dev/null" > /root/.ssh/config RUN mkdir -p /opt/jumpserver/oracle/ \ - && wget https://download.jumpserver.org/public/instantclient-basiclite-linux.x64-21.1.0.0.0.tar \ + && wget https://download.jumpserver.org/public/instantclient-basiclite-linux.x64-21.1.0.0.0.tar > /dev/null \ && tar xf instantclient-basiclite-linux.x64-21.1.0.0.0.tar -C /opt/jumpserver/oracle/ \ && echo "/opt/jumpserver/oracle/instantclient_21_1" > /etc/ld.so.conf.d/oracle-instantclient.conf \ && ldconfig \ && rm -f instantclient-basiclite-linux.x64-21.1.0.0.0.tar +RUN cd apps && python manage.py compilemessages + RUN echo > config.yml VOLUME /opt/jumpserver/data VOLUME /opt/jumpserver/logs diff --git a/apps/common/apps.py b/apps/common/apps.py index bf9348826..998881866 100644 --- a/apps/common/apps.py +++ b/apps/common/apps.py @@ -10,5 +10,6 @@ class CommonConfig(AppConfig): def ready(self): from . import signals_handlers from .signals import django_ready - if 'migrate' not in sys.argv: - django_ready.send(CommonConfig) + if 'migrate' in sys.argv or 'compilemessages' in sys.argv: + return + django_ready.send(CommonConfig) diff --git a/jms b/jms index 475ef75ca..1c05f5d62 100755 --- a/jms +++ b/jms @@ -100,9 +100,20 @@ def collect_static(): logging.info("Collect static files done") +def compile_i81n_file(): + django_mo_file = os.path.join(BASE_DIR, 'apps', 'locale', 'zh', 'LC_MESSAGES', 'django.mo') + if os.path.exists(django_mo_file): + return + os.chdir(os.path.join(BASE_DIR, 'apps')) + _cmd = 'python3 manage.py compilemessages --no-input -c &> /dev/null ' + subprocess.call(_cmd, shell=True) + logging.info("Compile i18n files done") + + def upgrade_db(): collect_static() perform_db_migrate() + collect_static() def prepare(): diff --git a/requirements/deb_requirements.txt b/requirements/deb_requirements.txt index 6edb70062..bd3dd8242 100644 --- a/requirements/deb_requirements.txt +++ b/requirements/deb_requirements.txt @@ -1 +1 @@ -g++ make iputils-ping default-libmysqlclient-dev libpq-dev libffi-dev libldap2-dev libsasl2-dev sshpass +g++ make iputils-ping default-libmysqlclient-dev libpq-dev libffi-dev libldap2-dev libsasl2-dev sshpass gettext diff --git a/requirements/mac_requirements.txt b/requirements/mac_requirements.txt index c7accda00..bc81ef5bd 100644 --- a/requirements/mac_requirements.txt +++ b/requirements/mac_requirements.txt @@ -1 +1 @@ -brew install libtiff libjpeg webp little-cms2 openssl +brew install libtiff libjpeg webp little-cms2 openssl gettext diff --git a/requirements/rpm_requirements.txt b/requirements/rpm_requirements.txt index a11e46125..e84966386 100644 --- a/requirements/rpm_requirements.txt +++ b/requirements/rpm_requirements.txt @@ -1 +1 @@ -gcc-c++ sshpass mariadb-devel openldap-devel +gcc-c++ sshpass mariadb-devel openldap-devel gettext