diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 6d80df8..08fbfc1 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -48,34 +48,34 @@ jobs: # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed steps: - - name: Checkout repository - uses: actions/checkout@v2 + - name: Checkout repository + uses: actions/checkout@v2 - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v1 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - # queries: ./path/to/local/query, your-org/your-repo/queries@main + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v1 + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v1 - # ℹ️ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl + # ℹ️ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl - # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language + # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language - #- run: | - # make bootstrap - # make release + #- run: | + # make bootstrap + # make release - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 5b5b589..77b87ae 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -12,23 +12,18 @@ jobs: docker: runs-on: ubuntu-latest steps: - - - name: Checkout + - name: Checkout uses: actions/checkout@v2 - - - name: Set up QEMU + - name: Set up QEMU uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - - - name: Login to DockerHub + - name: Login to DockerHub uses: docker/login-action@v1 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and push + - name: Build and push uses: docker/build-push-action@v2 with: context: . diff --git a/DjangoBlog/settings.py b/DjangoBlog/settings.py index 078425e..1344243 100644 --- a/DjangoBlog/settings.py +++ b/DjangoBlog/settings.py @@ -182,11 +182,6 @@ CACHE_CONTROL_MAX_AGE = 2592000 # cache setting CACHES = { 'default': { - 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', - 'LOCATION': os.environ.get('DJANGO_MEMCACHED_LOCATION') or '127.0.0.1:11211', - 'KEY_PREFIX': 'django_test' if TESTING else 'djangoblog', - 'TIMEOUT': 60 * 60 * 10 - } if env_to_bool('DJANGO_MEMCACHED_ENABLE', False) else { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', 'TIMEOUT': 10800, 'LOCATION': 'unique-snowflake', diff --git a/Dockerfile b/Dockerfile index 7a43ef9..7bc47ec 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,6 +5,8 @@ RUN apt-get install default-libmysqlclient-dev -y && \ ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime ADD requirements.txt requirements.txt RUN pip install -Ur requirements.txt && \ - pip install gunicorn[gevent] + pip install gunicorn[gevent] && \ + pip cache purge + ADD . . ENTRYPOINT ["/code/DjangoBlog/bin/docker_start.sh"] diff --git a/bin/docker_start.sh b/bin/docker_start.sh index 2d7f1a8..ddada3a 100644 --- a/bin/docker_start.sh +++ b/bin/docker_start.sh @@ -31,4 +31,4 @@ exec gunicorn ${DJANGO_WSGI_MODULE}:application \ --log-level=debug \ --log-file=- \ --worker-class gevent \ ---threads 4 +--threads 4 \ No newline at end of file diff --git a/bin/es-support/Dockerfile b/bin/es-support/Dockerfile deleted file mode 100644 index 2e66242..0000000 --- a/bin/es-support/Dockerfile +++ /dev/null @@ -1,2 +0,0 @@ -FROM elasticsearch:7.12.1 -RUN /usr/share/elasticsearch/bin/elasticsearch-plugin install -b https://ghproxy.com/https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.12.1/elasticsearch-analysis-ik-7.12.1.zip diff --git a/docker-compose.es.yml b/docker-compose.es.yml index 2440a65..dcffaa3 100644 --- a/docker-compose.es.yml +++ b/docker-compose.es.yml @@ -2,11 +2,25 @@ version: '3' services: es: - build: ./bin/es-support + image: liangliangyy/elasticsearch-analysis-ik:7.13.2 container_name: es + restart: always + environment: + - discovery.type=single-node + - "ES_JAVA_OPTS=-Xms512m -Xmx512m" ports: - - 9200:9200 + - 9200:9200 + volumes: + - ./bin/datas/es/:/usr/share/elasticsearch/data/ + kibana: + image: kibana:7.13.2 + restart: always + container_name: kibana + ports: + - 5601:5601 + environment: + - ELASTICSEARCH_HOSTS=http://es:9200 djangoblog: build: . diff --git a/docs/docker.md b/docs/docker.md index 3de2cf3..761e448 100644 --- a/docs/docker.md +++ b/docs/docker.md @@ -19,7 +19,13 @@ docker-compose up -d ``` 本方式生成的mysql数据文件在 `bin/datas/mysql` 文件夹。 等启动完成后,访问 [http://127.0.0.1](http://127.0.0.1) 即可。 - +### 使用es +如果你期望使用es来作为后端的搜索引擎,那么可以使用如下命令来启动: +```shell +docker-compose -f docker-compose.yml -f docker-compose.es.yml build +docker-compose -f docker-compose.yml -f docker-compose.es.yml up -d +``` +本方式生成的es数据文件在 `bin/datas/es` 文件夹。 ## 配置说明: 本项目较多配置都基于环境变量,所有的环境变量如下所示: diff --git a/requirements.txt b/requirements.txt index 5187311..75809ab 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,14 +5,14 @@ django-haystack==3.0 django-ipware==3.0.2 django-mdeditor==0.1.18 django-uuslug==1.2.0 -elasticsearch==7.13.1 +elasticsearch==7.13.2 elasticsearch-dsl==7.3.0 gevent==21.1.2 jieba==0.42.1 jsonpickle==2.0.0 mistune==0.8.4 mysqlclient==2.0.3 -Pillow==8.3.0 +Pillow==8.3.1 Pygments==2.9.0 python-logstash==0.4.6 python-memcached==1.59