Merge pull request #479 from liangliangyy/docker

增加docker es 支持
sh_branch
且听风吟 5 years ago committed by GitHub
commit 8dd264f2f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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

@ -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: .

@ -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',

@ -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"]

@ -31,4 +31,4 @@ exec gunicorn ${DJANGO_WSGI_MODULE}:application \
--log-level=debug \
--log-file=- \
--worker-class gevent \
--threads 4
--threads 4

@ -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

@ -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: .

@ -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` 文件夹。
## 配置说明:
本项目较多配置都基于环境变量,所有的环境变量如下所示:

@ -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

Loading…
Cancel
Save