docker-compose-prod.yml 2.1 KB
Newer Older
智布道's avatar
智布道 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13
# 使用构建好的镜像运行
# 官方稳定版
version: '3.3'
services:

  # Redis
  blog-redis:
    image: redis
    restart: always
    container_name: blog-redis
    hostname: blog-redis
    command: redis-server --appendonly yes --requirepass ${ONEBLOG_REDIS_PASSWORD} --bind blog-redis
    ports:
智布道's avatar
智布道 已提交
14
      - ${ONEBLOG_EXPORT_PORT_REDIS}:6379
智布道's avatar
智布道 已提交
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
    volumes:
      - ${ONEBLOG_APP_DIR}/redis/:/data/
    healthcheck:
      test: [ "CMD", "redis-cli" ]
      timeout: 20s
      retries: 10
    networks:
      - oneblog

  # MySQL
  blog-mysql:
    image: justauth/blog-mysql
    environment:
      MYSQL_ROOT_PASSWORD: ${ONEBLOG_DATASOURCE_PASSWORD}
      TZ: Asia/Shanghai
    restart: always
    container_name: blog-mysql
    hostname: blog-mysql
    volumes:
      - ${ONEBLOG_APP_DIR}/mysql:/var/lib/mysql
    ports:
智布道's avatar
智布道 已提交
36
      - ${ONEBLOG_EXPORT_PORT_MYSQL}:3306
智布道's avatar
智布道 已提交
37 38 39 40 41 42 43 44 45 46 47 48 49 50
    command: --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci
    healthcheck:
      test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
      timeout: 20s
      retries: 10
    networks:
      - oneblog

  # admin 服务
  blog-admin:
    image: justauth/blog-admin
    restart: always
    container_name: blog-admin
    hostname: blog-admin
智布道's avatar
智布道 已提交
51 52
    env_file:
      - .env
智布道's avatar
智布道 已提交
53 54 55 56 57 58 59 60 61 62 63
    volumes:
      - ${ONEBLOG_APP_DIR}:/var/tmp/oneblog
    depends_on:
      blog-redis:
        condition: service_healthy
      blog-mysql:
        condition: service_healthy
    links:
      - blog-redis
      - blog-mysql
    ports:
智布道's avatar
智布道 已提交
64
      - ${ONEBLOG_EXPORT_PORT_ADMIN}:8085
智布道's avatar
智布道 已提交
65 66 67 68 69 70 71 72 73
    networks:
      - oneblog

  # admin 服务
  blog-web:
    image: justauth/blog-web
    restart: always
    container_name: blog-web
    hostname: blog-web
智布道's avatar
智布道 已提交
74 75
    env_file:
      - .env
智布道's avatar
智布道 已提交
76 77 78 79 80 81 82 83 84 85 86
    volumes:
      - ${ONEBLOG_APP_DIR}:/var/tmp/oneblog
    depends_on:
      blog-redis:
        condition: service_healthy
      blog-mysql:
        condition: service_healthy
    links:
      - blog-redis
      - blog-mysql
    ports:
智布道's avatar
智布道 已提交
87
      - ${ONEBLOG_EXPORT_PORT_WEB}:8443
智布道's avatar
智布道 已提交
88 89 90 91 92 93
    networks:
      - oneblog

networks:
  oneblog:
    driver: bridge