version: '3.4'

services:
  one-api:
    image: justsong/one-api:latest
    container_name: one-api
    restart: always
    command: --log-dir /app/logs
    ports:
      - "3000:3000"
    volumes:
      - ./data/oneapi:/data
      - ./logs:/app/logs
    environment:
      - SQL_DSN=oneapi:123456@tcp(db:3306)/one-api 
      - REDIS_CONN_STRING=redis://redis
      - SESSION_SECRET=1234567890  # 修改为随机字符串
      - TZ=Asia/Shanghai
    depends_on:
      - redis
      - db

  redis:
    image: redis:latest
    container_name: redis
    restart: always

  db:
    image: mysql:8.2.0
    restart: always
    container_name: mysql
    volumes:
      - ./data/mysql:/var/lib/mysql  
    ports:
      - '3306:3306'
    environment:
      TZ: Asia/Shanghai   # 设置时区
      MYSQL_ROOT_PASSWORD: 'OneAPI@justsong' # 设置 root 用户的密码
      MYSQL_USER: oneapi   # 创建专用用户
      MYSQL_PASSWORD: '123456'    # 设置专用用户密码
      MYSQL_DATABASE: one-api   # 自动创建数据库

直接使用docker-compose 启动

docker-compose up  -d

GitHub 加速计划 / compose / compose
33.28 K
5.15 K
下载
compose - Docker Compose是一个用于定义和运行多容器Docker应用程序的工具,通过Compose文件格式简化应用部署过程。
最近提交(Master分支:3 个月前 )
5e3a0953 full diff: https://github.com/docker/cli/compare/v27.4.0-rc.1...8d1bacae3e49ed1d096eede8eef4ae851d7f2eae Signed-off-by: Sebastiaan van Stijn <github@gone.nl> 6 天前
a2a3eb72 - full diff: https://github.com/docker/cli/compare/cb3048fbebb1...v27.4.0-rc.1 Signed-off-by: Sebastiaan van Stijn <github@gone.nl> 6 天前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐