chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
data
|
||||
.idea
|
||||
*.iml
|
||||
.DS_Store
|
||||
*.zip
|
||||
*.log
|
||||
*.pyc
|
||||
doc
|
||||
/bin
|
||||
pkg
|
||||
*.tmp
|
||||
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -0,0 +1,60 @@
|
||||
## 镜像仓库选择
|
||||
|
||||
https://github.com/DaoCloud/public-image-mirror
|
||||
|
||||
```bash
|
||||
|
||||
# python使用镜像
|
||||
docker.m.daocloud.io/library/python:3.11-slim-bullseye
|
||||
|
||||
# mysql使用:
|
||||
docker.m.daocloud.io/library/mysql:8
|
||||
|
||||
```
|
||||
|
||||
|
||||
## 本地部署方法
|
||||
|
||||
|
||||
```
|
||||
git clone git@gitee.com:pythonstock/docker-compose.git
|
||||
|
||||
cd docker-compose
|
||||
|
||||
docker-compose up -d
|
||||
|
||||
```
|
||||
|
||||
## 访问地址
|
||||
|
||||
http://localhost:9090/
|
||||
|
||||
|
||||
|
||||
## 查看日至,进入项目代码
|
||||
|
||||
```
|
||||
# 查看启动日志:
|
||||
docker logs -f stock
|
||||
|
||||
# 进入stock容器
|
||||
docker exec -it stock bash
|
||||
```
|
||||
|
||||
## 开发模式,映射stock 代码方法
|
||||
|
||||
直接使用 dev yml 即可,会映射stock到/data/stock 然后在外部修改代码容器中运行即可。
|
||||
|
||||
```bash
|
||||
docker-compose -f dev-docker-compose.yml up -d
|
||||
```
|
||||
|
||||
```bash
|
||||
docker-compose -f docker-compose-v2.0.yml up -d
|
||||
```
|
||||
|
||||
## 老镜像还保存一个版本
|
||||
|
||||
```
|
||||
pythonstock/pythonstock:v2021
|
||||
```
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
|
||||
cd ../stock
|
||||
|
||||
NOW_MONTH=$(date "+%Y-%m")
|
||||
|
||||
DOCKER_TAG=pythonstock/pythonstock:latest
|
||||
DOCKER_TAG_MONTH=pythonstock/pythonstock:stock-${NOW_MONTH}
|
||||
|
||||
echo " docker build -f Dockerfile -t ${DOCKER_TAG} ."
|
||||
docker build -f Dockerfile -t ${DOCKER_TAG} .
|
||||
echo " docker build tag xxx ${DOCKER_TAG_MONTH} "
|
||||
echo "#################################################################"
|
||||
echo " docker push ${DOCKER_TAG} "
|
||||
|
||||
|
||||
Executable
+13
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
git pull
|
||||
|
||||
sleep 1
|
||||
docker-compose -f dev-docker-compose.yml down
|
||||
|
||||
sleep 1
|
||||
docker-compose -f dev-docker-compose.yml up -d
|
||||
|
||||
echo "restart dev-docker-compose"
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
networks:
|
||||
stock-dev-network:
|
||||
driver: bridge
|
||||
|
||||
version: "3"
|
||||
services:
|
||||
frontend:
|
||||
image: pythonstock/frontend-dev:latest
|
||||
build:
|
||||
context: .
|
||||
dockerfile: docker/DevFrontendDockerfile
|
||||
container_name: frontend
|
||||
ports:
|
||||
- "8080:8080"
|
||||
volumes:
|
||||
# 设置开发目录,方便开发调试
|
||||
- "../frontend:/usr/src/app"
|
||||
environment:
|
||||
LANG: zh_CN.UTF-8
|
||||
LC_CTYPE: zh_CN.UTF-8
|
||||
restart: always
|
||||
networks:
|
||||
stock-dev-network: {}
|
||||
# 入口写死,手动启动应用。
|
||||
entrypoint: /usr/src/app/docker-entrypoint.sh
|
||||
depends_on:
|
||||
- backend
|
||||
backend:
|
||||
image: pythonstock/backend-dev:latest
|
||||
build:
|
||||
context: .
|
||||
dockerfile: docker/DevBackendDockerfile
|
||||
container_name: backend
|
||||
ports:
|
||||
- "8888:8888"
|
||||
- "9090:9090"
|
||||
volumes:
|
||||
# 设置开发目录,方便开发调试
|
||||
- "../backend/jobs/crontab:/var/spool/cron/crontabs/root"
|
||||
- "../backend/jobs/cron.minutely:/etc/cron.minutely"
|
||||
- "../backend/jobs/cron.hourly:/etc/cron.hourly"
|
||||
- "../backend/jobs/cron.daily:/etc/cron.daily"
|
||||
- "../backend/jobs/cron.monthly:/etc/cron.monthly"
|
||||
- "../backend:/data/stock"
|
||||
- "../backend/supervisor:/data/supervisor"
|
||||
- "./data/notebooks:/data/notebooks"
|
||||
- "./data/logs:/data/logs"
|
||||
environment:
|
||||
MYSQL_HOST: mysql-stock
|
||||
MYSQL_USER: root
|
||||
MYSQL_PWD: mysql-stock
|
||||
MYSQL_DB: stock_data
|
||||
MYSQL_PORT: 3306
|
||||
LANG: zh_CN.UTF-8
|
||||
LC_CTYPE: zh_CN.UTF-8
|
||||
PYTHONIOENCODING: utf-8
|
||||
restart: always
|
||||
networks:
|
||||
stock-dev-network: {}
|
||||
# 入口写死,手动启动应用。
|
||||
#entrypoint: sleep 999999d
|
||||
depends_on:
|
||||
- mysql-stock
|
||||
mysql-stock:
|
||||
# image: hub.atomgit.com/library/mysql:5.7
|
||||
# https://hub.atomgit.com/repos/amd64/mysql
|
||||
image: docker.m.daocloud.io/library/mysql:8
|
||||
container_name: mysql-stock
|
||||
# 执行命令:https://juejin.cn/s/mysql%20healthcheck%20docker-compose
|
||||
healthcheck:
|
||||
test: ["CMD", "mysqladmin" ,"ping", "-uroot", "-pmysql-stock"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
ports:
|
||||
- "3306:3306"
|
||||
networks:
|
||||
stock-dev-network: {}
|
||||
volumes:
|
||||
- "./mysql/my.cnf:/etc/mysql/my.cnf"
|
||||
- "./data/mysql-stock/data:/var/lib/mysql"
|
||||
- ./mysql/init.sql:/docker-entrypoint-initdb.d/init.sql
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: mysql-stock
|
||||
MYSQL_DATABASE: stock_data
|
||||
TZ: Asia/Shanghai
|
||||
command: [
|
||||
'--character-set-server=utf8mb4',
|
||||
'--collation-server=utf8mb4_general_ci',
|
||||
'--max_connections=3000'
|
||||
]
|
||||
restart: always
|
||||
@@ -0,0 +1,107 @@
|
||||
networks:
|
||||
stock-dev-network:
|
||||
driver: bridge
|
||||
|
||||
version: "3"
|
||||
services:
|
||||
|
||||
#### 使用node 镜像进行编译,构建成 js 文件给nginx 使用。
|
||||
frontend-build:
|
||||
image: pythonstock/frontend-dev:latest
|
||||
build:
|
||||
context: .
|
||||
dockerfile: docker/DevFrontendDockerfile
|
||||
container_name: frontend-build
|
||||
volumes:
|
||||
# 设置开发目录,方便开发调试,生产环境拷贝到 /data/html
|
||||
- "../frontend:/usr/src/app"
|
||||
- "./data/html:/data/html"
|
||||
environment:
|
||||
LANG: zh_CN.UTF-8
|
||||
LC_CTYPE: zh_CN.UTF-8
|
||||
networks:
|
||||
stock-dev-network: {}
|
||||
# 入口写死,手动启动应用。每次构建时候使用,构建完成结束
|
||||
entrypoint: /usr/src/app/docker-build.sh
|
||||
nginx:
|
||||
image: docker.m.daocloud.io/library/nginx:stable-alpine
|
||||
container_name: nginx
|
||||
ports:
|
||||
- "8080:8080"
|
||||
volumes:
|
||||
# 设置开发目录,方便开发调试
|
||||
- "./data/html:/usr/share/nginx/html"
|
||||
- "./nginx/nginx.conf:/etc/nginx/conf.d/default.conf"
|
||||
environment:
|
||||
LANG: zh_CN.UTF-8
|
||||
LC_CTYPE: zh_CN.UTF-8
|
||||
restart: always
|
||||
networks:
|
||||
stock-dev-network: {}
|
||||
depends_on:
|
||||
- backend
|
||||
backend:
|
||||
image: pythonstock/backend-dev:latest
|
||||
build:
|
||||
context: .
|
||||
dockerfile: docker/DevBackendDockerfile
|
||||
container_name: backend
|
||||
ports:
|
||||
- "8888:8888"
|
||||
- "9090:9090"
|
||||
volumes:
|
||||
# 设置开发目录,方便开发调试
|
||||
- "../backend/jobs/crontab:/var/spool/cron/crontabs/root"
|
||||
- "../backend/jobs/cron.minutely:/etc/cron.minutely"
|
||||
- "../backend/jobs/cron.hourly:/etc/cron.hourly"
|
||||
- "../backend/jobs/cron.daily:/etc/cron.daily"
|
||||
- "../backend/jobs/cron.monthly:/etc/cron.monthly"
|
||||
- "../backend:/data/stock"
|
||||
- "../backend/supervisor:/data/supervisor"
|
||||
- "./data/notebooks:/data/notebooks"
|
||||
- "./data/logs:/data/logs"
|
||||
environment:
|
||||
MYSQL_HOST: mysql-stock
|
||||
MYSQL_USER: root
|
||||
MYSQL_PWD: mysql-stock
|
||||
MYSQL_DB: stock_data
|
||||
MYSQL_PORT: 3306
|
||||
LANG: zh_CN.UTF-8
|
||||
LC_CTYPE: zh_CN.UTF-8
|
||||
PYTHONIOENCODING: utf-8
|
||||
restart: always
|
||||
networks:
|
||||
stock-dev-network: {}
|
||||
# 入口写死,手动启动应用。
|
||||
#entrypoint: sleep 999999d
|
||||
depends_on:
|
||||
- mysql-stock
|
||||
mysql-stock:
|
||||
# image: hub.atomgit.com/library/mysql:5.7
|
||||
# https://hub.atomgit.com/repos/amd64/mysql
|
||||
image: docker.m.daocloud.io/library/mysql:8
|
||||
container_name: mysql-stock
|
||||
# 执行命令:https://juejin.cn/s/mysql%20healthcheck%20docker-compose
|
||||
healthcheck:
|
||||
test: ["CMD", "mysqladmin" ,"ping", "-uroot", "-pmysql-stock"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
ports:
|
||||
- "3306:3306"
|
||||
networks:
|
||||
stock-dev-network: {}
|
||||
volumes:
|
||||
- "./mysql/my.cnf:/etc/mysql/my.cnf"
|
||||
- "./data/mysql-stock/data:/var/lib/mysql"
|
||||
- ./mysql/init.sql:/docker-entrypoint-initdb.d/init.sql
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: mysql-stock
|
||||
MYSQL_DATABASE: stock_data
|
||||
TZ: Asia/Shanghai
|
||||
command: [
|
||||
'--character-set-server=utf8mb4',
|
||||
'--collation-server=utf8mb4_general_ci',
|
||||
'--max_connections=3000'
|
||||
]
|
||||
restart: always
|
||||
@@ -0,0 +1,97 @@
|
||||
|
||||
|
||||
# https://hub.docker.com/_/python?tab=tags&page=1&name=3.11-slim-bullseye
|
||||
# 用这个做为基础镜像,防止每次都进行构建。
|
||||
|
||||
#FROM docker.io/python:3.11-slim-bullseye
|
||||
FROM docker.m.daocloud.io/library/python:3.11-slim-bullseye
|
||||
|
||||
# https://opsx.alibaba.com/mirror
|
||||
# 使用阿里云镜像地址。修改debian apt 更新地址,pip 地址,设置时区。
|
||||
# 设置debian的镜像源
|
||||
RUN echo "deb http://mirrors.aliyun.com/debian/ bullseye main non-free contrib" > /etc/apt/sources.list && \
|
||||
echo "deb-src http://mirrors.aliyun.com/debian/ bullseye main non-free contrib" >> /etc/apt/sources.list && \
|
||||
echo "deb http://mirrors.aliyun.com/debian-security/ bullseye-security main" >> /etc/apt/sources.list && \
|
||||
echo "deb-src http://mirrors.aliyun.com/debian-security/ bullseye-security main" >> /etc/apt/sources.list && \
|
||||
echo "deb http://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib" >> /etc/apt/sources.list && \
|
||||
echo "deb-src http://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib" >> /etc/apt/sources.list && \
|
||||
echo "deb http://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib" >> /etc/apt/sources.list && \
|
||||
echo "deb-src http://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib" >> /etc/apt/sources.list && \
|
||||
echo "[global]\n\
|
||||
trusted-host=mirrors.aliyun.com\n\
|
||||
index-url=http://mirrors.aliyun.com/pypi/simple" > /etc/pip.conf && \
|
||||
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
|
||||
echo "Asia/Shanghai" > /etc/timezone
|
||||
|
||||
#增加语言utf-8
|
||||
ENV LANG=zh_CN.UTF-8
|
||||
ENV LC_CTYPE=zh_CN.UTF-8
|
||||
ENV LC_ALL=C
|
||||
ENV PYTHONPATH=/data/stock
|
||||
|
||||
# 增加 TensorFlow 的支持,使用最新的2.0 编写代码。目前还是使用 1.x 吧,还没有学明白。
|
||||
# RUN pip3 install tensorflow==2.0.0-rc1 keras
|
||||
# RUN pip3 install tensorflow keras sklearn
|
||||
|
||||
# 设置 vim 的语言配置
|
||||
RUN mkdir -p /etc/vim/ && \
|
||||
echo "set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936" >> /etc/vim/vimrc && \
|
||||
echo "set termencoding=utf-8" >> /etc/vim/vimrc && \
|
||||
echo "set encoding=utf-8" >> /etc/vim/vimrc
|
||||
|
||||
# 安装 mysqlclient akshare (pandas ,numpy) tornado bokeh
|
||||
# 安装 nodejs 库
|
||||
# apt-get autoremove -y 删除没有用的依赖lib。减少镜像大小。1MB 也要节省。
|
||||
# apt-get --purge remove 软件包名称 , 删除已安装包(不保留配置文件)。
|
||||
RUN apt-get update && apt-get install -y git pkg-config net-tools procps gcc make python3-dev default-libmysqlclient-dev libxml2-dev cron && \
|
||||
pip3 install mysqlclient sqlalchemy && \
|
||||
pip3 install supervisor && \
|
||||
pip3 install numpy pandas && \
|
||||
pip3 install akshare --upgrade && \
|
||||
apt-get install -y nodejs && \
|
||||
pip3 install tornado torndb && \
|
||||
pip3 install bokeh stockstats scikit-learn && \
|
||||
apt-get --purge remove -y gcc make python3-dev default-libmysqlclient-dev libxml2-dev && \
|
||||
rm -rf /root/.cache/* && apt-get clean && apt-get autoremove -y && \
|
||||
cd /usr/local/lib/python3.11/site-packages && find ./ -name *.pyc | xargs rm -f
|
||||
|
||||
# /usr/local/lib/python3.11/site-packages/pandas/
|
||||
# 1.解决 pandas 数据插入问题。直接修改数据库驱动 sqlalchemy
|
||||
# 修改:statement.replace("INSERT INTO","INSERT IGNORE INTO")
|
||||
# /usr/local/lib/python3.11/site-packages/sqlalchemy/dialects/mysql/mysqldb.py
|
||||
# 增加了一个 IGNORE 参数。
|
||||
# 2.解决torndb在python3下面的问题:
|
||||
# http://blog.csdn.net/littlethunder/article/details/8917378
|
||||
# 3. 解决 type 问题,使用sed 进行替换。
|
||||
# File "/usr/local/lib/python3.11/site-packages/torndb.py", line 260, in <module>
|
||||
# CONVERSIONS[field_type] = [(FLAG.BINARY, str)] + CONVERSIONS[field_type]
|
||||
# TypeError: can only concatenate list (not "type") to list
|
||||
|
||||
RUN echo `date +%Y-%m-%d:%H:%M:%S` >> /etc/docker.build && \
|
||||
sed -i -e 's/executemany(statement/executemany(statement.replace\("INSERT INTO","INSERT IGNORE INTO")/g' \
|
||||
/usr/local/lib/python3.11/site-packages/sqlalchemy/dialects/mysql/mysqldb.py && \
|
||||
rm -f /etc/cron.daily/apt-compat /etc/cron.daily/dpkg /etc/cron.daily/passwd && \
|
||||
sed -i -e 's/itertools\.izip/zip/g' \
|
||||
/usr/local/lib/python3.11/site-packages/torndb.py && \
|
||||
sed -i -e 's/\+ CONVERSIONS\[field_type\]/\+ \[CONVERSIONS\[field_type\],bytes\]/g' \
|
||||
/usr/local/lib/python3.11/site-packages/torndb.py
|
||||
|
||||
|
||||
#add cron sesrvice.
|
||||
#每分钟,每小时1分钟,每天1点1分,每月1号执行
|
||||
RUN mkdir -p /etc/cron.minutely && mkdir -p /etc/cron.hourly && mkdir -p /etc/cron.monthly && mkdir -p /var/spool/cron/crontabs && \
|
||||
echo "SHELL=/bin/sh \n\
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin \n\
|
||||
# min hour day month weekday command \n\
|
||||
*/1 * * * * /bin/run-parts /etc/cron.minutely \n\
|
||||
10 * * * * /bin/run-parts /etc/cron.hourly \n\
|
||||
30 16 * * * /bin/run-parts /etc/cron.daily \n\
|
||||
30 17 1,10,20 * * /bin/run-parts /etc/cron.monthly \n" > /var/spool/cron/crontabs/root && \
|
||||
chmod 600 /var/spool/cron/crontabs/root
|
||||
|
||||
|
||||
#增加服务端口
|
||||
EXPOSE 8888 9090
|
||||
|
||||
ENTRYPOINT ["supervisord","-n","-c","/data/supervisor/supervisord.conf"]
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
#使用 node:bullseye-slim 做基础镜像减少大小。
|
||||
|
||||
# FROM docker.m.daocloud.io/library/node:bullseye-slim
|
||||
# fixbug 最新node 版本编译不过去,
|
||||
# ERROR Error: Cannot find module './passes/web-incoming'
|
||||
|
||||
FROM docker.m.daocloud.io/library/node:23.5.0-bullseye-slim
|
||||
|
||||
# https://opsx.alibaba.com/mirror
|
||||
# 使用阿里云镜像地址。修改debian apt 更新地址,pip 地址,设置时区。
|
||||
# 设置debian的镜像源
|
||||
RUN echo "deb http://mirrors.aliyun.com/debian/ bullseye main non-free contrib" > /etc/apt/sources.list && \
|
||||
echo "deb-src http://mirrors.aliyun.com/debian/ bullseye main non-free contrib" >> /etc/apt/sources.list && \
|
||||
echo "deb http://mirrors.aliyun.com/debian-security/ bullseye-security main" >> /etc/apt/sources.list && \
|
||||
echo "deb-src http://mirrors.aliyun.com/debian-security/ bullseye-security main" >> /etc/apt/sources.list && \
|
||||
echo "deb http://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib" >> /etc/apt/sources.list && \
|
||||
echo "deb-src http://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib" >> /etc/apt/sources.list && \
|
||||
echo "deb http://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib" >> /etc/apt/sources.list && \
|
||||
echo "deb-src http://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib" >> /etc/apt/sources.list && \
|
||||
echo "[global]\n\
|
||||
trusted-host=mirrors.aliyun.com\n\
|
||||
index-url=http://mirrors.aliyun.com/pypi/simple" > /etc/pip.conf && \
|
||||
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
|
||||
echo "Asia/Shanghai" > /etc/timezone
|
||||
|
||||
#增加语言utf-8
|
||||
ENV LANG=zh_CN.UTF-8
|
||||
ENV LC_CTYPE=zh_CN.UTF-8
|
||||
ENV LC_ALL=C
|
||||
|
||||
# 增加 TensorFlow 的支持,使用最新的2.0 编写代码。目前还是使用 1.x 吧,还没有学明白。
|
||||
# RUN pip3 install tensorflow==2.0.0-rc1 keras
|
||||
# RUN pip3 install tensorflow keras sklearn
|
||||
|
||||
# 设置 vim 的语言配置
|
||||
RUN mkdir -p /etc/vim/ && \
|
||||
echo "set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936" >> /etc/vim/vimrc && \
|
||||
echo "set termencoding=utf-8" >> /etc/vim/vimrc && \
|
||||
echo "set encoding=utf-8" >> /etc/vim/vimrc
|
||||
|
||||
# 安装 mysqlclient akshare (pandas ,numpy) tornado bokeh
|
||||
# 安装 nodejs 库
|
||||
# apt-get autoremove -y 删除没有用的依赖lib。减少镜像大小。1MB 也要节省。
|
||||
# apt-get --purge remove 软件包名称 , 删除已安装包(不保留配置文件)。
|
||||
RUN apt-get update && apt-get install -y python3 make g++ && apt-get clean
|
||||
@@ -0,0 +1,103 @@
|
||||
#使用 python:3.8-slim 做基础镜像减少大小。其中tensorflow再用另外的镜像跑数据。
|
||||
|
||||
# 之前使用的是python:3.6-slim
|
||||
# 可以更新 3.8-slim-bullseye slim-bullseye
|
||||
|
||||
# https://hub.docker.com/_/python?tab=tags&page=1&name=3.8-slim-bullseye
|
||||
# 用这个做为基础镜像,防止每次都进行构建。
|
||||
|
||||
#FROM docker.io/python:3.8-slim-bullseye
|
||||
#FROM hub.atomgit.com/amd64/python:3.8-slim-bullseye
|
||||
# https://hub.atomgit.com/repos/amd64/python
|
||||
#FROM hub.atomgit.com/amd64/python:3.11-slim-bullseye
|
||||
FROM docker.m.daocloud.io/library/python:3.11-slim-bullseye
|
||||
|
||||
# https://opsx.alibaba.com/mirror
|
||||
# 使用阿里云镜像地址。修改debian apt 更新地址,pip 地址,设置时区。
|
||||
# 设置debian的镜像源
|
||||
RUN echo "deb http://mirrors.aliyun.com/debian/ bullseye main non-free contrib" > /etc/apt/sources.list && \
|
||||
echo "deb-src http://mirrors.aliyun.com/debian/ bullseye main non-free contrib" >> /etc/apt/sources.list && \
|
||||
echo "deb http://mirrors.aliyun.com/debian-security/ bullseye-security main" >> /etc/apt/sources.list && \
|
||||
echo "deb-src http://mirrors.aliyun.com/debian-security/ bullseye-security main" >> /etc/apt/sources.list && \
|
||||
echo "deb http://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib" >> /etc/apt/sources.list && \
|
||||
echo "deb-src http://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib" >> /etc/apt/sources.list && \
|
||||
echo "deb http://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib" >> /etc/apt/sources.list && \
|
||||
echo "deb-src http://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib" >> /etc/apt/sources.list && \
|
||||
echo "[global]\n\
|
||||
trusted-host=mirrors.aliyun.com\n\
|
||||
index-url=http://mirrors.aliyun.com/pypi/simple" > /etc/pip.conf && \
|
||||
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
|
||||
echo "Asia/Shanghai" > /etc/timezone
|
||||
|
||||
#增加语言utf-8
|
||||
ENV LANG=zh_CN.UTF-8
|
||||
ENV LC_CTYPE=zh_CN.UTF-8
|
||||
ENV LC_ALL=C
|
||||
ENV PYTHONPATH=/data/stock
|
||||
|
||||
# 增加 TensorFlow 的支持,使用最新的2.0 编写代码。目前还是使用 1.x 吧,还没有学明白。
|
||||
# RUN pip3 install tensorflow==2.0.0-rc1 keras
|
||||
# RUN pip3 install tensorflow keras sklearn
|
||||
|
||||
# 设置 vim 的语言配置
|
||||
RUN mkdir -p /etc/vim/ && \
|
||||
echo "set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936" >> /etc/vim/vimrc && \
|
||||
echo "set termencoding=utf-8" >> /etc/vim/vimrc && \
|
||||
echo "set encoding=utf-8" >> /etc/vim/vimrc
|
||||
|
||||
# 安装 mysqlclient akshare (pandas ,numpy) tornado bokeh
|
||||
# 安装 nodejs 库
|
||||
# apt-get autoremove -y 删除没有用的依赖lib。减少镜像大小。1MB 也要节省。
|
||||
# apt-get --purge remove 软件包名称 , 删除已安装包(不保留配置文件)。
|
||||
RUN apt-get update && apt-get install -y git pkg-config net-tools procps gcc make python3-dev default-libmysqlclient-dev libxml2-dev cron && \
|
||||
pip3 install mysqlclient sqlalchemy && \
|
||||
pip3 install supervisor && \
|
||||
pip3 install numpy pandas && \
|
||||
pip3 install akshare --upgrade && \
|
||||
apt-get install -y nodejs && \
|
||||
pip3 install tornado torndb && \
|
||||
pip3 install bokeh stockstats scikit-learn && \
|
||||
apt-get --purge remove -y gcc make python3-dev default-libmysqlclient-dev libxml2-dev && \
|
||||
rm -rf /root/.cache/* && apt-get clean && apt-get autoremove -y && \
|
||||
cd /usr/local/lib/python3.11/site-packages && find ./ -name *.pyc | xargs rm -f
|
||||
|
||||
# /usr/local/lib/python3.11/site-packages/pandas/
|
||||
# 1.解决 pandas 数据插入问题。直接修改数据库驱动 sqlalchemy
|
||||
# 修改:statement.replace("INSERT INTO","INSERT IGNORE INTO")
|
||||
# /usr/local/lib/python3.11/site-packages/sqlalchemy/dialects/mysql/mysqldb.py
|
||||
# 增加了一个 IGNORE 参数。
|
||||
# 2.解决torndb在python3下面的问题:
|
||||
# http://blog.csdn.net/littlethunder/article/details/8917378
|
||||
# 3. 解决 type 问题,使用sed 进行替换。
|
||||
# File "/usr/local/lib/python3.11/site-packages/torndb.py", line 260, in <module>
|
||||
# CONVERSIONS[field_type] = [(FLAG.BINARY, str)] + CONVERSIONS[field_type]
|
||||
# TypeError: can only concatenate list (not "type") to list
|
||||
|
||||
RUN echo `date +%Y-%m-%d:%H:%M:%S` >> /etc/docker.build && \
|
||||
sed -i -e 's/executemany(statement/executemany(statement.replace\("INSERT INTO","INSERT IGNORE INTO")/g' \
|
||||
/usr/local/lib/python3.11/site-packages/sqlalchemy/dialects/mysql/mysqldb.py && \
|
||||
rm -f /etc/cron.daily/apt-compat /etc/cron.daily/dpkg /etc/cron.daily/passwd && \
|
||||
sed -i -e 's/itertools\.izip/zip/g' \
|
||||
/usr/local/lib/python3.11/site-packages/torndb.py && \
|
||||
sed -i -e 's/\+ CONVERSIONS\[field_type\]/\+ \[CONVERSIONS\[field_type\],bytes\]/g' \
|
||||
/usr/local/lib/python3.11/site-packages/torndb.py
|
||||
|
||||
|
||||
#add cron sesrvice.
|
||||
#每分钟,每小时1分钟,每天1点1分,每月1号执行
|
||||
RUN mkdir -p /etc/cron.minutely && mkdir -p /etc/cron.hourly && mkdir -p /etc/cron.monthly && mkdir -p /var/spool/cron/crontabs && \
|
||||
echo "SHELL=/bin/sh \n\
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin \n\
|
||||
# min hour day month weekday command \n\
|
||||
*/1 * * * * /bin/run-parts /etc/cron.minutely \n\
|
||||
10 * * * * /bin/run-parts /etc/cron.hourly \n\
|
||||
30 16 * * * /bin/run-parts /etc/cron.daily \n\
|
||||
30 17 1,10,20 * * /bin/run-parts /etc/cron.monthly \n" > /var/spool/cron/crontabs/root && \
|
||||
chmod 600 /var/spool/cron/crontabs/root
|
||||
|
||||
|
||||
#增加服务端口就两个 6006 8500 9001
|
||||
EXPOSE 8888 9999
|
||||
|
||||
ENTRYPOINT ["supervisord","-n","-c","/data/supervisor/supervisord.conf"]
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
#使用 python:3.8-slim 做基础镜像减少大小。其中tensorflow再用另外的镜像跑数据。
|
||||
|
||||
# 之前使用的是python:3.6-slim
|
||||
# 可以更新 3.8-slim-bullseye slim-bullseye
|
||||
|
||||
# https://hub.docker.com/_/python?tab=tags&page=1&name=3.8-slim-bullseye
|
||||
# 用这个做为基础镜像,防止每次都进行构建。
|
||||
|
||||
#FROM docker.io/python:3.8-slim-bullseye
|
||||
#FROM hub.atomgit.com/amd64/python:3.8-slim-bullseye
|
||||
# https://hub.atomgit.com/repos/amd64/python
|
||||
#FROM hub.atomgit.com/amd64/python:3.11-slim-bullseye
|
||||
FROM docker.m.daocloud.io/library/python:3.11-slim-bullseye
|
||||
|
||||
# https://opsx.alibaba.com/mirror
|
||||
# 使用阿里云镜像地址。修改debian apt 更新地址,pip 地址,设置时区。
|
||||
# 设置debian的镜像源
|
||||
RUN echo "deb http://mirrors.aliyun.com/debian/ bullseye main non-free contrib" > /etc/apt/sources.list && \
|
||||
echo "deb-src http://mirrors.aliyun.com/debian/ bullseye main non-free contrib" >> /etc/apt/sources.list && \
|
||||
echo "deb http://mirrors.aliyun.com/debian-security/ bullseye-security main" >> /etc/apt/sources.list && \
|
||||
echo "deb-src http://mirrors.aliyun.com/debian-security/ bullseye-security main" >> /etc/apt/sources.list && \
|
||||
echo "deb http://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib" >> /etc/apt/sources.list && \
|
||||
echo "deb-src http://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib" >> /etc/apt/sources.list && \
|
||||
echo "deb http://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib" >> /etc/apt/sources.list && \
|
||||
echo "deb-src http://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib" >> /etc/apt/sources.list && \
|
||||
echo "[global]\n\
|
||||
trusted-host=mirrors.aliyun.com\n\
|
||||
index-url=http://mirrors.aliyun.com/pypi/simple" > /etc/pip.conf && \
|
||||
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
|
||||
echo "Asia/Shanghai" > /etc/timezone
|
||||
|
||||
#增加语言utf-8
|
||||
ENV LANG=zh_CN.UTF-8
|
||||
ENV LC_CTYPE=zh_CN.UTF-8
|
||||
ENV LC_ALL=C
|
||||
ENV PYTHONPATH=/data/stock
|
||||
|
||||
# 增加 TensorFlow 的支持,使用最新的2.0 编写代码。目前还是使用 1.x 吧,还没有学明白。
|
||||
# RUN pip3 install tensorflow==2.0.0-rc1 keras
|
||||
# RUN pip3 install tensorflow keras sklearn
|
||||
|
||||
# 设置 vim 的语言配置
|
||||
RUN mkdir -p /etc/vim/ && \
|
||||
echo "set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936" >> /etc/vim/vimrc && \
|
||||
echo "set termencoding=utf-8" >> /etc/vim/vimrc && \
|
||||
echo "set encoding=utf-8" >> /etc/vim/vimrc
|
||||
|
||||
# 安装 mysqlclient akshare (pandas ,numpy) tornado bokeh
|
||||
# 安装 nodejs 库
|
||||
# apt-get autoremove -y 删除没有用的依赖lib。减少镜像大小。1MB 也要节省。
|
||||
# apt-get --purge remove 软件包名称 , 删除已安装包(不保留配置文件)。
|
||||
RUN apt-get update && apt-get install -y git pkg-config net-tools procps gcc make python3-dev default-libmysqlclient-dev libxml2-dev cron && \
|
||||
pip3 install mysqlclient sqlalchemy && \
|
||||
pip3 install supervisor && \
|
||||
pip3 install numpy pandas && \
|
||||
pip3 install akshare --upgrade && \
|
||||
apt-get install -y nodejs && \
|
||||
pip3 install tornado torndb && \
|
||||
pip3 install bokeh stockstats scikit-learn && \
|
||||
apt-get --purge remove -y gcc make python3-dev default-libmysqlclient-dev libxml2-dev && \
|
||||
rm -rf /root/.cache/* && apt-get clean && apt-get autoremove -y && \
|
||||
cd /usr/local/lib/python3.11/site-packages && find ./ -name *.pyc | xargs rm -f
|
||||
|
||||
# /usr/local/lib/python3.11/site-packages/pandas/
|
||||
# 1.解决 pandas 数据插入问题。直接修改数据库驱动 sqlalchemy
|
||||
# 修改:statement.replace("INSERT INTO","INSERT IGNORE INTO")
|
||||
# /usr/local/lib/python3.11/site-packages/sqlalchemy/dialects/mysql/mysqldb.py
|
||||
# 增加了一个 IGNORE 参数。
|
||||
# 2.解决torndb在python3下面的问题:
|
||||
# http://blog.csdn.net/littlethunder/article/details/8917378
|
||||
# 3. 解决 type 问题,使用sed 进行替换。
|
||||
# File "/usr/local/lib/python3.11/site-packages/torndb.py", line 260, in <module>
|
||||
# CONVERSIONS[field_type] = [(FLAG.BINARY, str)] + CONVERSIONS[field_type]
|
||||
# TypeError: can only concatenate list (not "type") to list
|
||||
|
||||
RUN echo `date +%Y-%m-%d:%H:%M:%S` >> /etc/docker.build && \
|
||||
sed -i -e 's/executemany(statement/executemany(statement.replace\("INSERT INTO","INSERT IGNORE INTO")/g' \
|
||||
/usr/local/lib/python3.11/site-packages/sqlalchemy/dialects/mysql/mysqldb.py && \
|
||||
rm -f /etc/cron.daily/apt-compat /etc/cron.daily/dpkg /etc/cron.daily/passwd && \
|
||||
sed -i -e 's/itertools\.izip/zip/g' \
|
||||
/usr/local/lib/python3.11/site-packages/torndb.py && \
|
||||
sed -i -e 's/\+ CONVERSIONS\[field_type\]/\+ \[CONVERSIONS\[field_type\],bytes\]/g' \
|
||||
/usr/local/lib/python3.11/site-packages/torndb.py
|
||||
|
||||
|
||||
#add cron sesrvice.
|
||||
#每分钟,每小时1分钟,每天1点1分,每月1号执行
|
||||
RUN mkdir -p /etc/cron.minutely && mkdir -p /etc/cron.hourly && mkdir -p /etc/cron.monthly && mkdir -p /var/spool/cron/crontabs && \
|
||||
echo "SHELL=/bin/sh \n\
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin \n\
|
||||
# min hour day month weekday command \n\
|
||||
*/1 * * * * /bin/run-parts /etc/cron.minutely \n\
|
||||
10 * * * * /bin/run-parts /etc/cron.hourly \n\
|
||||
30 16 * * * /bin/run-parts /etc/cron.daily \n\
|
||||
30 17 1,10,20 * * /bin/run-parts /etc/cron.monthly \n" > /var/spool/cron/crontabs/root && \
|
||||
chmod 600 /var/spool/cron/crontabs/root
|
||||
|
||||
|
||||
#增加服务端口就两个 6006 8500 9001
|
||||
EXPOSE 8888 9999
|
||||
|
||||
ENTRYPOINT ["supervisord","-n","-c","/data/supervisor/supervisord.conf"]
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
#使用 node:bullseye-slim 做基础镜像减少大小。
|
||||
|
||||
FROM docker.m.daocloud.io/library/node:bullseye-slim
|
||||
|
||||
# https://opsx.alibaba.com/mirror
|
||||
# 使用阿里云镜像地址。修改debian apt 更新地址,pip 地址,设置时区。
|
||||
# 设置debian的镜像源
|
||||
RUN echo "deb http://mirrors.aliyun.com/debian/ bullseye main non-free contrib" > /etc/apt/sources.list && \
|
||||
echo "deb-src http://mirrors.aliyun.com/debian/ bullseye main non-free contrib" >> /etc/apt/sources.list && \
|
||||
echo "deb http://mirrors.aliyun.com/debian-security/ bullseye-security main" >> /etc/apt/sources.list && \
|
||||
echo "deb-src http://mirrors.aliyun.com/debian-security/ bullseye-security main" >> /etc/apt/sources.list && \
|
||||
echo "deb http://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib" >> /etc/apt/sources.list && \
|
||||
echo "deb-src http://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib" >> /etc/apt/sources.list && \
|
||||
echo "deb http://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib" >> /etc/apt/sources.list && \
|
||||
echo "deb-src http://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib" >> /etc/apt/sources.list && \
|
||||
echo "[global]\n\
|
||||
trusted-host=mirrors.aliyun.com\n\
|
||||
index-url=http://mirrors.aliyun.com/pypi/simple" > /etc/pip.conf && \
|
||||
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
|
||||
echo "Asia/Shanghai" > /etc/timezone
|
||||
|
||||
#增加语言utf-8
|
||||
ENV LANG=zh_CN.UTF-8
|
||||
ENV LC_CTYPE=zh_CN.UTF-8
|
||||
ENV LC_ALL=C
|
||||
|
||||
# 增加 TensorFlow 的支持,使用最新的2.0 编写代码。目前还是使用 1.x 吧,还没有学明白。
|
||||
# RUN pip3 install tensorflow==2.0.0-rc1 keras
|
||||
# RUN pip3 install tensorflow keras sklearn
|
||||
|
||||
# 设置 vim 的语言配置
|
||||
RUN mkdir -p /etc/vim/ && \
|
||||
echo "set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936" >> /etc/vim/vimrc && \
|
||||
echo "set termencoding=utf-8" >> /etc/vim/vimrc && \
|
||||
echo "set encoding=utf-8" >> /etc/vim/vimrc
|
||||
|
||||
# 安装 mysqlclient akshare (pandas ,numpy) tornado bokeh
|
||||
# 安装 nodejs 库
|
||||
# apt-get autoremove -y 删除没有用的依赖lib。减少镜像大小。1MB 也要节省。
|
||||
# apt-get --purge remove 软件包名称 , 删除已安装包(不保留配置文件)。
|
||||
RUN apt-get update && apt-get install -y python3 make g++ && apt-get clean
|
||||
@@ -0,0 +1,35 @@
|
||||
|
||||
# python 基础镜像
|
||||
|
||||
基础镜像升级到 2020年7月的版本
|
||||
|
||||
保证运行的最少基础环境,基础环境使用python3.6的版本。安装了超级多的lib库。非常的好用。
|
||||
|
||||
mysqlclient
|
||||
sqlalchemy
|
||||
requests
|
||||
numpy
|
||||
tushare
|
||||
tornado torndb
|
||||
bokeh
|
||||
stockstats
|
||||
ta-lib
|
||||
jupyter
|
||||
sklearn
|
||||
|
||||
# 2021年6月版本,使用 akshare 替换掉 tushare 库
|
||||
|
||||
akshare 地址:
|
||||
|
||||
https://www.akshare.xyz/zh_CN/latest/introduction.html
|
||||
|
||||
AKShare 是基于 Python 的财经数据接口库, 目的是实现对股票、期货、期权、基金、外汇、债券、指数、
|
||||
加密货币等金融产品的基本面数据、实时和历史行情数据、衍生数据从数据采集、数据清洗到数据落地的一套工具,
|
||||
主要用于学术研究目的。
|
||||
|
||||
|
||||
# 2021年 9 月版本,镜像裁剪,supervisor 使用python3
|
||||
|
||||
supervisor 使用 python3 后好像减少了不少大小。
|
||||
同时删除掉一直没有用的 ta-lib 和 jupyter 。升级python基础镜像。
|
||||
|
||||
Executable
+13
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
NOW_MONTH=$(date "+%Y-%m")
|
||||
|
||||
DOCKER_TAG=pythonstock/pythonstock:base-${NOW_MONTH}
|
||||
|
||||
echo " docker build -f Dockerfile -t ${DOCKER_TAG} ."
|
||||
docker build -f Dockerfile -t ${DOCKER_TAG} .
|
||||
echo "#################################################################"
|
||||
echo " docker push ${DOCKER_TAG} "
|
||||
|
||||
|
||||
@@ -0,0 +1,201 @@
|
||||
SET character_set_client = utf8;
|
||||
-- 切库:
|
||||
use stock_data;
|
||||
-- 建表
|
||||
-- 表里面都是使用 code 和 date 两个字段做联合主键的。
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `stock_zh_a_spot_em` (
|
||||
`date` varchar(255) NOT NULL,
|
||||
`code` varchar(255) NOT NULL,
|
||||
`name` varchar(255) DEFAULT NULL,
|
||||
`last_price` double(20,2) DEFAULT NULL,
|
||||
`change_percent` double(20,2) DEFAULT NULL,
|
||||
`change_amount` double(20,2) DEFAULT NULL,
|
||||
`volume` double(20,2) DEFAULT NULL,
|
||||
`turnover` double(20,2) DEFAULT NULL,
|
||||
`amplitude` double(20,2) DEFAULT NULL,
|
||||
`high` double(20,2) DEFAULT NULL,
|
||||
`low` double(20,2) DEFAULT NULL,
|
||||
`open` double(20,2) DEFAULT NULL,
|
||||
`closed` double(20,2) DEFAULT NULL,
|
||||
`volume_ratio` double(20,2) DEFAULT NULL,
|
||||
`turnover_rate` double(20,2) DEFAULT NULL,
|
||||
`pe_ratio` double(20,2) DEFAULT NULL,
|
||||
`pb_ratio` double(20,2) DEFAULT NULL,
|
||||
`market_cap` double(20,2) DEFAULT NULL,
|
||||
`circulating_market_cap` double(20,2) DEFAULT NULL,
|
||||
`rise_speed` double(20,2) DEFAULT NULL,
|
||||
`change_5min` double(20,2) DEFAULT NULL,
|
||||
`change_ercent_60day` double(20,2) DEFAULT NULL,
|
||||
`ytd_change_percent` double(20,2) DEFAULT NULL,
|
||||
PRIMARY KEY (`code`,`date`),
|
||||
KEY `idx_code` (`code`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `stock_lhb_ggtj_sina` (
|
||||
`date` varchar(255) NOT NULL,
|
||||
`code` varchar(255) NOT NULL,
|
||||
`name` varchar(255) DEFAULT NULL,
|
||||
`ranking_times` double(20,2) DEFAULT NULL,
|
||||
`sum_buy` double(20,2) DEFAULT NULL,
|
||||
`sum_sell` double(20,2) DEFAULT NULL,
|
||||
`net_amount` double(20,2) DEFAULT NULL,
|
||||
`buy_seat` double(20,2) DEFAULT NULL,
|
||||
`sell_seat` double(20,2) DEFAULT NULL,
|
||||
PRIMARY KEY (`code`,`date`),
|
||||
KEY `idx_code` (`code`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
CREATE TABLE `stock_dzjy_mrtj` (
|
||||
`date` varchar(255) NOT NULL,
|
||||
`code` varchar(255) NOT NULL,
|
||||
`name` varchar(255) DEFAULT NULL,
|
||||
`quote_change` double(20,2) DEFAULT NULL,
|
||||
`close_price` double(20,2) DEFAULT NULL,
|
||||
`average_price` double(20,2) DEFAULT NULL,
|
||||
`overflow_rate` double(20,2) DEFAULT NULL,
|
||||
`trade_number` double(20,2) DEFAULT NULL,
|
||||
`sum_volume` double(20,2) DEFAULT NULL,
|
||||
`sum_turnover` double(20,2) DEFAULT NULL,
|
||||
`turnover_market_rate` double(20,2) DEFAULT NULL,
|
||||
PRIMARY KEY (`code`,`date`),
|
||||
KEY `idx_code` (`code`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
CREATE TABLE `guess_indicators_daily` (
|
||||
`date` varchar(255) NOT NULL,
|
||||
`code` varchar(255) NOT NULL,
|
||||
`name` varchar(255) DEFAULT NULL,
|
||||
`last_price` double(20,2) DEFAULT NULL,
|
||||
`change_percent` double(20,2) DEFAULT NULL,
|
||||
`change_amount` double(20,2) DEFAULT NULL,
|
||||
`volume` double(20,2) DEFAULT NULL,
|
||||
`turnover` double(20,2) DEFAULT NULL,
|
||||
`amplitude` double(20,2) DEFAULT NULL,
|
||||
`high` double(20,2) DEFAULT NULL,
|
||||
`low` double(20,2) DEFAULT NULL,
|
||||
`open` double(20,2) DEFAULT NULL,
|
||||
`closed` double(20,2) DEFAULT NULL,
|
||||
`volume_ratio` double(20,2) DEFAULT NULL,
|
||||
`turnover_rate` double(20,2) DEFAULT NULL,
|
||||
`pe_ratio` double(20,2) DEFAULT NULL,
|
||||
`pb_ratio` double(20,2) DEFAULT NULL,
|
||||
`market_cap` double(20,2) DEFAULT NULL,
|
||||
`circulating_market_cap` double(20,2) DEFAULT NULL,
|
||||
`rise_speed` double(20,2) DEFAULT NULL,
|
||||
`change_5min` double(20,2) DEFAULT NULL,
|
||||
`change_ercent_60day` double(20,2) DEFAULT NULL,
|
||||
`ytd_change_percent` double(20,2) DEFAULT NULL,
|
||||
`boll` double(20,2) DEFAULT NULL,
|
||||
`boll_lb` double(20,2) DEFAULT NULL,
|
||||
`boll_ub` double(20,2) DEFAULT NULL,
|
||||
`kdjd` double(20,2) DEFAULT NULL,
|
||||
`kdjj` double(20,2) DEFAULT NULL,
|
||||
`kdjk` double(20,2) DEFAULT NULL,
|
||||
`macd` double(20,2) DEFAULT NULL,
|
||||
`macdh` double(20,2) DEFAULT NULL,
|
||||
`macds` double(20,2) DEFAULT NULL,
|
||||
`pdi` double(20,2) DEFAULT NULL,
|
||||
`trix` double(20,2) DEFAULT NULL,
|
||||
`trix_9_sma` double(20,2) DEFAULT NULL,
|
||||
`vr` double(20,2) DEFAULT NULL,
|
||||
`vr_6_sma` double(20,2) DEFAULT NULL,
|
||||
`wr_10` double(20,2) DEFAULT NULL,
|
||||
`wr_6` double(20,2) DEFAULT NULL,
|
||||
PRIMARY KEY (`code`,`date`),
|
||||
KEY `idx_code` (`code`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
CREATE TABLE `guess_indicators_lite_buy_daily` (
|
||||
`date` varchar(255) NOT NULL,
|
||||
`code` varchar(255) NOT NULL,
|
||||
`name` varchar(255) DEFAULT NULL,
|
||||
`last_price` double(20,2) DEFAULT NULL,
|
||||
`change_percent` double(20,2) DEFAULT NULL,
|
||||
`change_amount` double(20,2) DEFAULT NULL,
|
||||
`volume` double(20,2) DEFAULT NULL,
|
||||
`turnover` double(20,2) DEFAULT NULL,
|
||||
`amplitude` double(20,2) DEFAULT NULL,
|
||||
`high` double(20,2) DEFAULT NULL,
|
||||
`low` double(20,2) DEFAULT NULL,
|
||||
`open` double(20,2) DEFAULT NULL,
|
||||
`closed` double(20,2) DEFAULT NULL,
|
||||
`volume_ratio` double(20,2) DEFAULT NULL,
|
||||
`turnover_rate` double(20,2) DEFAULT NULL,
|
||||
`pe_ratio` double(20,2) DEFAULT NULL,
|
||||
`pb_ratio` double(20,2) DEFAULT NULL,
|
||||
`market_cap` double(20,2) DEFAULT NULL,
|
||||
`circulating_market_cap` double(20,2) DEFAULT NULL,
|
||||
`rise_speed` double(20,2) DEFAULT NULL,
|
||||
`change_5min` double(20,2) DEFAULT NULL,
|
||||
`change_ercent_60day` double(20,2) DEFAULT NULL,
|
||||
`ytd_change_percent` double(20,2) DEFAULT NULL,
|
||||
`boll` double(20,2) DEFAULT NULL,
|
||||
`boll_lb` double(20,2) DEFAULT NULL,
|
||||
`boll_ub` double(20,2) DEFAULT NULL,
|
||||
`kdjd` double(20,2) DEFAULT NULL,
|
||||
`kdjj` double(20,2) DEFAULT NULL,
|
||||
`kdjk` double(20,2) DEFAULT NULL,
|
||||
`macd` double(20,2) DEFAULT NULL,
|
||||
`macdh` double(20,2) DEFAULT NULL,
|
||||
`macds` double(20,2) DEFAULT NULL,
|
||||
`pdi` double(20,2) DEFAULT NULL,
|
||||
`trix` double(20,2) DEFAULT NULL,
|
||||
`trix_9_sma` double(20,2) DEFAULT NULL,
|
||||
`vr` double(20,2) DEFAULT NULL,
|
||||
`vr_6_sma` double(20,2) DEFAULT NULL,
|
||||
`wr_10` double(20,2) DEFAULT NULL,
|
||||
`wr_6` double(20,2) DEFAULT NULL,
|
||||
PRIMARY KEY (`code`,`date`),
|
||||
KEY `idx_code` (`code`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
|
||||
CREATE TABLE `guess_indicators_lite_sell_daily` (
|
||||
`date` varchar(255) NOT NULL,
|
||||
`code` varchar(255) NOT NULL,
|
||||
`name` varchar(255) DEFAULT NULL,
|
||||
`last_price` double(20,2) DEFAULT NULL,
|
||||
`change_percent` double(20,2) DEFAULT NULL,
|
||||
`change_amount` double(20,2) DEFAULT NULL,
|
||||
`volume` double(20,2) DEFAULT NULL,
|
||||
`turnover` double(20,2) DEFAULT NULL,
|
||||
`amplitude` double(20,2) DEFAULT NULL,
|
||||
`high` double(20,2) DEFAULT NULL,
|
||||
`low` double(20,2) DEFAULT NULL,
|
||||
`open` double(20,2) DEFAULT NULL,
|
||||
`closed` double(20,2) DEFAULT NULL,
|
||||
`volume_ratio` double(20,2) DEFAULT NULL,
|
||||
`turnover_rate` double(20,2) DEFAULT NULL,
|
||||
`pe_ratio` double(20,2) DEFAULT NULL,
|
||||
`pb_ratio` double(20,2) DEFAULT NULL,
|
||||
`market_cap` double(20,2) DEFAULT NULL,
|
||||
`circulating_market_cap` double(20,2) DEFAULT NULL,
|
||||
`rise_speed` double(20,2) DEFAULT NULL,
|
||||
`change_5min` double(20,2) DEFAULT NULL,
|
||||
`change_ercent_60day` double(20,2) DEFAULT NULL,
|
||||
`ytd_change_percent` double(20,2) DEFAULT NULL,
|
||||
`boll` double(20,2) DEFAULT NULL,
|
||||
`boll_lb` double(20,2) DEFAULT NULL,
|
||||
`boll_ub` double(20,2) DEFAULT NULL,
|
||||
`kdjd` double(20,2) DEFAULT NULL,
|
||||
`kdjj` double(20,2) DEFAULT NULL,
|
||||
`kdjk` double(20,2) DEFAULT NULL,
|
||||
`macd` double(20,2) DEFAULT NULL,
|
||||
`macdh` double(20,2) DEFAULT NULL,
|
||||
`macds` double(20,2) DEFAULT NULL,
|
||||
`pdi` double(20,2) DEFAULT NULL,
|
||||
`trix` double(20,2) DEFAULT NULL,
|
||||
`trix_9_sma` double(20,2) DEFAULT NULL,
|
||||
`vr` double(20,2) DEFAULT NULL,
|
||||
`vr_6_sma` double(20,2) DEFAULT NULL,
|
||||
`wr_10` double(20,2) DEFAULT NULL,
|
||||
`wr_6` double(20,2) DEFAULT NULL,
|
||||
PRIMARY KEY (`code`,`date`),
|
||||
KEY `idx_code` (`code`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
# https://blog.csdn.net/aichogn/article/details/117788275
|
||||
# mysql 推荐配置
|
||||
[client]
|
||||
socket=/var/lib/mysql/mysql.sock
|
||||
port=3306
|
||||
[mysqld]
|
||||
|
||||
basedir=/var/lib/mysql/
|
||||
datadir=/var/lib/mysql/data
|
||||
socket=/var/lib/mysql/mysql.sock
|
||||
default-storage-engine=INNODB
|
||||
character_set_server=utf8mb4
|
||||
collation_server=utf8mb4_general_ci
|
||||
|
||||
port=3306
|
||||
# Disabling symbolic-links is recommended to prevent assorted security risks
|
||||
symbolic-links=0
|
||||
|
||||
server_id=1
|
||||
|
||||
## 最大连接数,MySQL服务器允许的最大连接数16384,连接数越多消耗内存越多
|
||||
max_connections = 1000
|
||||
## 日志过期时间,包括二进制日志(过期自动删除)
|
||||
# expire_logs_days = 15
|
||||
## Enable Per Table Data for InnoDB to shrink ibdata1(innoDB表优化)
|
||||
innodb_file_per_table = 1
|
||||
#默认128M,用于存储页面缓存数据外,另外正常情况下还有大约8%的开销,主要用在每个缓存页帧的描述、adaptive hash等数据结构,适当的增加这个参数的大小,可以有效的减少 InnoDB 类型的表的磁盘 I/O
|
||||
innodb_buffer_pool_size = 2048M
|
||||
innodb_log_file_size = 512M
|
||||
#默认是8MB,InnoDB在写事务日志的时候,为了提高性能,也是先将信息写入Innofb Log Buffer中,当满足innodb_flush_log_trx_commit参数所设置的相应条件(或者日志缓冲区写满)之后,才会将日志写到文件 (或者同步到磁盘)中
|
||||
innodb_log_buffer_size = 8M
|
||||
innodb_flush_log_at_trx_commit = 2
|
||||
#表大小写不敏感
|
||||
lower_case_table_names=1
|
||||
#跳过密码 安装完后屏蔽该选项
|
||||
#skip-grant-tables
|
||||
#关闭 binlog
|
||||
skip-log-bin
|
||||
@@ -0,0 +1,47 @@
|
||||
# 设置nginx启动
|
||||
# systemctl enable nginx
|
||||
server {
|
||||
listen 8080;
|
||||
server_name www.pythonstock.com;
|
||||
root /usr/share/nginx/html;
|
||||
|
||||
error_page 404 /404.html;
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
|
||||
# 开启gzip
|
||||
gzip on;
|
||||
# 启用gzip压缩的最小文件;小于设置值的文件将不会被压缩
|
||||
gzip_min_length 1k;
|
||||
# gzip 压缩级别 1-10
|
||||
gzip_comp_level 2;
|
||||
# 进行压缩的文件类型。
|
||||
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
|
||||
# 是否在http header中添加Vary: Accept-Encoding,建议开启
|
||||
gzip_vary on;
|
||||
|
||||
access_log /var/log/nginx/stock.access.log main;
|
||||
error_log /var/log/nginx/stock.error.log warn;
|
||||
|
||||
# https://medium.com/aviabird/413-414-request-url-entity-too-large-error-nginx-b6dcece6f5dd
|
||||
# 解决GET 参数过长问题。
|
||||
client_max_body_size 10M;
|
||||
large_client_header_buffers 4 20k;
|
||||
|
||||
|
||||
location ^~ /static/ {
|
||||
access_log off;
|
||||
# 需要把源代码,再下载一遍。
|
||||
root /data/pythonstock/stock/web;
|
||||
expires 30d; # 设置30天超时
|
||||
# 参考 https://www.cnblogs.com/kevingrace/p/10459429.html
|
||||
# add_header Cache-Control max-age=360000;
|
||||
}
|
||||
|
||||
location / {
|
||||
proxy_next_upstream http_500 http_502 http_503 http_504 error timeout invalid_header;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_pass http://127.0.0.1:9090;
|
||||
expires 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
server {
|
||||
listen 8080;
|
||||
server_name localhost;
|
||||
#access_log /var/log/nginx/host.access.log main;
|
||||
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html index.htm;
|
||||
}
|
||||
|
||||
location /api/v1 {
|
||||
proxy_pass http://backend:9090;
|
||||
}
|
||||
|
||||
|
||||
error_page 404 /404.html;
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user