mirror of
				https://github.com/songquanpeng/one-api.git
				synced 2025-11-04 15:53:42 +08:00 
			
		
		
		
	feat: add Docker Compose support (#55)
* docker-compose.yml * Create one-api.service 配置systemd守护进程 * Update docker-compose.yml * Update one-api.service * Update docker-compose.yml * Update docker-compose.yml
This commit is contained in:
		
							
								
								
									
										22
									
								
								docker-compose.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								docker-compose.yml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,22 @@
 | 
				
			|||||||
 | 
					version: '3.4'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					services:
 | 
				
			||||||
 | 
					  one-api:
 | 
				
			||||||
 | 
					    image: ghcr.io/songquanpeng/one-api:latest
 | 
				
			||||||
 | 
					    container_name: one-api
 | 
				
			||||||
 | 
					    restart: always
 | 
				
			||||||
 | 
					    command: --log-dir /app/logs
 | 
				
			||||||
 | 
					    ports:
 | 
				
			||||||
 | 
					      - "3000:3000"
 | 
				
			||||||
 | 
					    volumes:
 | 
				
			||||||
 | 
					      - /home/ubuntu/data/one-api:/data
 | 
				
			||||||
 | 
					      - /home/ubuntu/data/one-api/logs:/app/logs
 | 
				
			||||||
 | 
					    # environment:
 | 
				
			||||||
 | 
					    #   REDIS_CONN_STRING: redis://default:redispw@localhost:49153
 | 
				
			||||||
 | 
					    #   SESSION_SECRET: random_string
 | 
				
			||||||
 | 
					    #   SQL_DSN: root:123456@tcp(localhost:3306)/one-api
 | 
				
			||||||
 | 
					    healthcheck:
 | 
				
			||||||
 | 
					      test: ["CMD-SHELL", "curl -s http://localhost:3000/api/status | grep -o '\"success\":\\s*true' | awk '{print $2}' | grep 'true'"]
 | 
				
			||||||
 | 
					      interval: 30s
 | 
				
			||||||
 | 
					      timeout: 10s
 | 
				
			||||||
 | 
					      retries: 3
 | 
				
			||||||
							
								
								
									
										13
									
								
								one-api.service
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								one-api.service
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,13 @@
 | 
				
			|||||||
 | 
					[Unit]
 | 
				
			||||||
 | 
					Description=One API Service
 | 
				
			||||||
 | 
					After=network.target
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[Service]
 | 
				
			||||||
 | 
					User=yourusername                  # 守护进程用户名
 | 
				
			||||||
 | 
					WorkingDirectory=/path/to/One-API  # One API运行路径
 | 
				
			||||||
 | 
					ExecStart=/path/to/One-API/one-api --port 3000 --log-dir /path/to/One-API/logs  # 端口
 | 
				
			||||||
 | 
					Restart=always
 | 
				
			||||||
 | 
					RestartSec=5
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[Install]
 | 
				
			||||||
 | 
					WantedBy=multi-user.target
 | 
				
			||||||
		Reference in New Issue
	
	Block a user