diff --git a/README.md b/README.md index 19a25ba..ac4a56f 100644 --- a/README.md +++ b/README.md @@ -21,14 +21,10 @@ cd futarin-api 3. Create `.env` file ``` touch .env -# default 0(prod) -echo "DEV_MODE=1" - echo "VOICEVOX_API_KEY=[voicevox api key]" >> .env -echo "VOICEVOX_URL=[endpoint url]" >> .env echo "OPENAI_API_KEY=[openAI api key]" >> .env -# Only production mode (NOT DEV_MODE=1) +# Only production mode(開発環境用) echo "STORAGE_ACCOUNT_NAME=[azure storage-account-name]" >> .env echo "SAS_TOKEN=[azure storage-account SAS token]" >> .env ``` @@ -41,8 +37,12 @@ sudo docker compose build 5. Build and Start image ``` +# Production(本番環境) sudo docker compose up -sudo docker compose up -d # detach +# Development(開発環境) +sudo docker compose -f docker-compose.yml -f docker-compose.dev.yml up +# Detachモード +sudo docker compose up -d ``` 6. access to localhost to check docs http://localhost/docs @@ -76,10 +76,12 @@ http://localhost/docs │   │   ├── voicevox.py │   │   ├── voicevox_api.py │   │   └── whisper.py +│   ├── uploads │   └── utils │   ├── __init__.py │   ├── config.py │   └── log.py +├── docker-compose.dev.yml └── docker-compose.yml ``` diff --git a/api/utils/config.py b/api/utils/config.py index 55a9ca2..e62848c 100644 --- a/api/utils/config.py +++ b/api/utils/config.py @@ -17,8 +17,8 @@ def check_env_variables(): raise EnvironmentError(f"Missing environment variables: {', '.join(missing_vars)}") def get_is_dev_mode() -> bool: - IS_DEV = os.getenv("DEV_MODE") - return True if IS_DEV==1 else False + is_dev_mode = os.getenv("IS_DEV_MODE") + return int(is_dev_mode)==1 def get_voicevox_url(): return os.getenv("VOICEVOX_URL") diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml new file mode 100644 index 0000000..6ccb038 --- /dev/null +++ b/docker-compose.dev.yml @@ -0,0 +1,4 @@ +services: + api: + environment: + - IS_DEV_MODE=1 diff --git a/docker-compose.yml b/docker-compose.yml index 2ac3a22..3a7e722 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,6 +14,8 @@ services: api: container_name: api image: futarin-api + environment: + - IS_DEV_MODE=0 env_file: - .env build: