常規web專案 docker-compose 例子

干炸小黄鱼發表於2024-09-20
version: '3.1'

services:
  db:
    image: postgres:13.1
    container_name: com_db
    environment:
      POSTGRES_USER: root
      POSTGRES_PASSWORD: db123
      POSTGRES_DB: db
    volumes:
      - /opt/work/DDDDD/platform/com_db/db_data:/var/lib/postgresql/data
      - /usr/share/zoneinfo/Asia/Shanghai:/etc/localtime:ro
    restart: unless-stopped
    privileged: true
    logging:
      driver: "json-file"
      options:
        max-size: "10m"

  redis:
    image: redis:alpine
    volumes:
      - /usr/share/zoneinfo/Asia/Shanghai:/etc/localtime:ro
    restart: unless-stopped
    command: --requirepass "db123"
    privileged: true
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
  web:
    image: web_py38:v106
    command: sh -c 'cd /web/DDDDD && export FLASK_APP=sites && flask create-db && flask init-db && uwsgi /web/uwsgi.ini'
    volumes:
      - .:/web
      - /root/.ssh:/root/.ssh
      - /data:/data
      - /usr/share/zoneinfo/Asia/Shanghai:/etc/localtime:ro
    depends_on:
      - redis
    restart: unless-stopped
    privileged: true
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
  schedulers:
    image: web_py38:v106
    command: sh -c 'cd /web/DDDDD && python -u -m sites.scripts.schedulers'
    volumes:
      - .:/web
      - /usr/share/zoneinfo/Asia/Shanghai:/etc/localtime:ro
      - /root/.ssh:/root/.ssh
    depends_on:
      - web
    restart: unless-stopped
    privileged: true
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
networks:
  default:
    ipam:
      driver: default
      config:
        - subnet: 10.254.{{net_id}}.0/24

相關文章