惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
News and Events Feed by Topic
S
Security @ Cisco Blogs
S
Secure Thoughts
Attack and Defense Labs
Attack and Defense Labs
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Hacker News - Newest:
Hacker News - Newest: "LLM"
Recent Commits to openclaw:main
Recent Commits to openclaw:main
H
Hacker News: Front Page
博客园 - 叶小钗
H
Heimdal Security Blog
Microsoft Security Blog
Microsoft Security Blog
Forbes - Security
Forbes - Security
AI
AI
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Troy Hunt's Blog
罗磊的独立博客
Application and Cybersecurity Blog
Application and Cybersecurity Blog
爱范儿
爱范儿
GbyAI
GbyAI
The Last Watchdog
The Last Watchdog
TaoSecurity Blog
TaoSecurity Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
D
DataBreaches.Net
Recent Announcements
Recent Announcements
Schneier on Security
Schneier on Security
C
Cisco Blogs
美团技术团队
D
Docker
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
WordPress大学
WordPress大学
月光博客
月光博客
雷峰网
雷峰网
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
H
Hackread – Cybersecurity News, Data Breaches, AI and More
A
Arctic Wolf
B
Blog RSS Feed
Cisco Talos Blog
Cisco Talos Blog
C
Cybersecurity and Infrastructure Security Agency CISA
V
Vulnerabilities – Threatpost
V2EX - 技术
V2EX - 技术
Y
Y Combinator Blog
N
News and Events Feed by Topic
www.infosecurity-magazine.com
www.infosecurity-magazine.com
W
WeLiveSecurity
Security Archives - TechRepublic
Security Archives - TechRepublic
G
GRAHAM CLULEY
Jina AI
Jina AI
Hugging Face - Blog
Hugging Face - Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
The Hacker News
The Hacker News

博客园 - 干炸小黄鱼

timex 处理时间戳 gorm-gen go 雪花算法 golang每日一库--协程池库ants golang每日一库--json解析库gjson python高级编程-asyncio python高级编程-condition python高级编程-event python装饰器-自动重试 EAP系统 go实现实现 SECS/GEM 协议 设备通信协议 SECS go项目使用Jenkins进行CICD go操作ES mongo db聚合查询 go如何使用mongodb Apache ShardingSphere paxos and raft (分布式一致性算法) go使用zookeeper分布式锁以及和redis差异 go使用 seata 示例 Alibaba 分布式事务 Seata go中使用saga go中使用TCC示例 分布式事务TCC 熔断器 Hystrix OR Sentinel k8s下部署consul and etcd Consul OR Etcd 【力扣hot100】双指针-盛水最多的容器 【力扣hot100】滑动窗口-最小覆盖子串 shell脚本合集 分布式id生成器 springboot通用CURD Python PB级检索系统架构设计 rancher 在三台机器搭建k8s集群 python ssh clinet 数据库排序Null值字段靠后/靠前 常规web项目 docker-compose 例子 手搓一个验证码 使用itertools 中的groupby 对字典数组进行分组后排序 使用开源库 geoip2 获取某ip的经纬度地理信息 python中 apscheduler.schedulers.blocking.BlockingScheduler 定时执行任务 python和sliver交互 golang sliver二次开发自定义命令(格式乱后面再调) pydantic做参数校验 基于rancher部署k8s 地理位置相关基础数据 flask migrate时报错 Can't locate revision identified by '3d80e4c025df'
简单的python web项目的docker-compose.yml 示例
干炸小黄鱼 · 2024-08-12 · via 博客园 - 干炸小黄鱼

一个简单的 python web项目, 包含redis, mysql, nginx, 定时业务调度等
其中web启动注册了自定义命令 flask create-db && flask init-db && uwsgi /web/uwsgi.ini

version: '3.5'

services:
  db:
    image: mysql
    container_name: yeping_mysql
    command: --default-authentication-plugin=mysql_native_password
    environment:
      MYSQL_ROOT_PASSWORD: yeping9527
      MYSQL_DATABASE: yeping9527
      LANG: C.UTF-8
    volumes:
      - ./db_data:/var/lib/mysql
      - ./mysql_files:/var/lib/mysql-files
      - /usr/share/zoneinfo/Asia/Shanghai:/etc/localtime:ro
    # ports: 
    #   - "127.0.0.1:3309:3306"
    restart: unless-stopped
    privileged: true
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
  redis:
    image: redis:alpine
    container_name: yeping_redis
    volumes:
      - /usr/share/zoneinfo/Asia/Shanghai:/etc/localtime:ro
    restart: unless-stopped
    privileged: true
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
  web:
    image: yeping_web:v106
    container_name: yeping_web
    command: bash -c "wait-for-it -t 0 db:3306; wait-for-it -t 0 redis:6379; cd /web/主目录 && export FLASK_APP=sites && flask create-db && flask init-db && uwsgi /web/uwsgi.ini"
    volumes:
      - /root/.ssh/:/root/.ssh
      - .:/web
      - /usr/share/zoneinfo/Asia/Shanghai:/etc/localtime:ro
      - ./db_data:/data/db_data
      - ./mysql_files:/data/mysql_files
    depends_on:
      - db
      - redis
    #ports:
    #  - 8112:8000
    restart: unless-stopped
    privileged: true
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
  nginx:
      image: nginx:alpine
      container_name: yeping_nginx
      environment:
        LANG: C.UTF-8
      ports:
        - "443:443"
        - "80:80"
      volumes:
        - /opt/work/yeping/config/nginx:/nginx
        - /opt/work/yeping:/opt/work/yeping
        - /opt/work/yeping/config/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
        - /var/log/yeping/nginx/:/var/log/yeping/nginx/
        - /usr/share/zoneinfo/Asia/Shanghai:/etc/localtime:ro
      restart: unless-stopped
      privileged: true
      stdin_open: true
      tty: true
      logging:
        driver: "json-file"
        options:
          max-size: "10m"
  schedulers:
    image: yeping:v106
    container_name: yeping_schedulers
    command: sh -c 'cd /web/主目录 && python -u -m sites.scripts.schedulers'
    volumes:
      - .:/web
      - /usr/share/zoneinfo/Asia/Shanghai:/etc/localtime:ro
      - /root/.ssh:/root/.ssh
      - ./db_data:/data/db_data
      - ./mysql_files:/data/mysql_files
    depends_on:
      - web
    restart: unless-stopped
    privileged: true
    logging:
      driver: "json-file"
      options:
        max-size: "10m"

自定义清库和数据库初始化命令

import click
@app.cli.command(help="Create all tables form models")
@click.option("--drop", is_flag=True, help="Create after drop.")
def create_db(drop):
    # 文件锁
    lock_file = "init_create.lock"
    if os.path.exists(lock_file):
        logging.warning("不是第一次启动,无需创建表。。。")
        return
    if drop:
        db.drop_all()
    db.create_all()
    os.mknod(lock_file)

@app.cli.command(help="Initialization app data")
def init_db():
    # 数据库初始化操作