Skip to content

Commit

Permalink
Merge pull request jhao104#256 from nnnewb/feature/docker-enhancement
Browse files Browse the repository at this point in the history
[refine] 允许 docker-compose up 直接运行服务而无需修改配置
  • Loading branch information
jhao104 authored Mar 11, 2019
2 parents 0c48d9d + b568bd2 commit 5554832
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 54 deletions.
24 changes: 20 additions & 4 deletions Config/setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,29 @@
"""

# database config
from os import getenv


class ConfigError(BaseException):
pass


DB_TYPE = getenv('db_type', 'SSDB')

if DB_TYPE == 'SSDB':
DB_HOST = getenv('ssdb_host', '127.0.0.1')
DB_PORT = getenv('ssdb_port', '6379')
elif DB_TYPE == 'MONGODB':
DB_HOST = getenv('mongodb_host', '127.0.0.1')
DB_PORT = getenv('mongodb_host', '27017')
else:
raise ConfigError('Unknown database type, your environment variable `db_type` should be one of SSDB/MONGODB.')

DATABASES = {
"default": {
"TYPE": "SSDB", # TYPE SSDB/MONGODB if use redis, only modify the host port, the type should be SSDB
"HOST": "127.0.0.1",
"PORT": 8888,
"TYPE": DB_TYPE, # TYPE SSDB/MONGODB if use redis, only modify the host port, the type should be SSDB
"HOST": DB_HOST,
"PORT": DB_PORT,
"NAME": "proxy",
"PASSWORD": ""

Expand Down Expand Up @@ -45,7 +62,6 @@
# "freeProxyWallThird"
]


# # API config http://127.0.0.1:5010

SERVER_API = {
Expand Down
27 changes: 0 additions & 27 deletions Docker/Dockerfile.develop

This file was deleted.

14 changes: 0 additions & 14 deletions Docker/docker-compose.yml

This file was deleted.

9 changes: 3 additions & 6 deletions Docker/Dockerfile → Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
FROM python:3.6
WORKDIR /usr/src/app
COPY . .

ENV DEBIAN_FRONTEND noninteractive
ENV TZ Asia/Shanghai

WORKDIR /usr/src/app
COPY ./requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY . .
EXPOSE 5010

WORKDIR /usr/src/app/
CMD [ "python", "Run/main.py" ]
14 changes: 14 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: '2'
services:
proxy_pool:
build: .
ports:
- "5010:5010"
links:
- proxy_redis
environment:
db_type: SSDB
ssdb_host: proxy_redis
ssdb_port: 6379
proxy_redis:
image: "redis"
3 changes: 0 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,5 @@ werkzeug==0.11.15
Flask==0.12
requests==2.20.0
lxml==3.7.2

pymongo
redis


0 comments on commit 5554832

Please sign in to comment.