From 82b132f5197a033459b92708cb2b223af054334f Mon Sep 17 00:00:00 2001 From: icurfer Date: Fri, 4 Oct 2024 00:28:36 +0900 Subject: [PATCH] docker test setting --- Dockerfile | 15 +++++++++++++++ README.md | 5 ++--- main.py | 1 + package/GetConfig.py | 8 +++++++- requirements.txt | Bin 934 -> 441 bytes sample.env.dev | 4 ++-- version | 1 + 7 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 Dockerfile create mode 100644 version diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0d88576 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM python:3.10-slim-buster + +WORKDIR /usr/src/app + +ENV PYTHONDONTWRITEBYTECODE 1 +ENV PYTHONUNBUFFERED 1 + +COPY . /usr/src/app + +# install python dependencies +RUN pip install --upgrade pip +RUN pip install --no-cache-dir -r requirements.txt + +# 6. Python main.py 파일을 실행합니다. +CMD ["python", "main.py"] \ No newline at end of file diff --git a/README.md b/README.md index 818106e..b826c27 100644 --- a/README.md +++ b/README.md @@ -25,9 +25,8 @@ make.com을 이용해서 만든 AutoMation Flow를 Python을 이용하여 변환 * 워드프레스 등록 플로우 코드 작성(기능 테스트 완료 - 연결 필요). ### 코드 리팩토링. -* 환경변수 호출 모듈분리(완료) -* 데이터베이스 조회 모듈분리(완료) -* OpenAI 모듈 +* 전체 리팩토링. +* 모듈화, 패키지화. ## 코드 이슈 ### 네이버 블로그 크롤링 diff --git a/main.py b/main.py index d66346b..e1c3063 100644 --- a/main.py +++ b/main.py @@ -3,6 +3,7 @@ from package import GetConfig, MariaDB, ChangeTextToPost, WordPress import markdown # 2024-10-03 환경 변수 호출 +print('### Get values from .env') config = GetConfig() dict_data = config.get_config_as_dict() diff --git a/package/GetConfig.py b/package/GetConfig.py index d931a20..0f0100c 100644 --- a/package/GetConfig.py +++ b/package/GetConfig.py @@ -1,7 +1,13 @@ import os from dotenv import load_dotenv -load_dotenv(r'./.env.dev') +# 우선순위: .env.prd > .env.dev > .env +if os.path.exists('.env.prd'): + load_dotenv('.env.prd') +elif os.path.exists('.env.dev'): + load_dotenv('.env.dev') +else: + load_dotenv('.env') # 기본 .env 파일 class GetConfig: def __init__(self): diff --git a/requirements.txt b/requirements.txt index c2239f0b3b282c51bb5c3b3db5fc6ab6d8e57e6f..0d8529e500ca6c7b0c5a4aa9effd5dea7d86c168 100644 GIT binary patch literal 441 zcmX|;OLD^?5JdOfMHC>}P8J*?XK-OOwn!w9VdPjjeR|@mESXPt&m-hqI53SJ?<+O$ zjXr6kLf%vHe$YoeE)+IS*KKZPTL-CHr+XEtqME#S#tr&S_eRAj)JELpQkO8NAFAH> zy4Oy{GM5^bAO=uXV`^OCVD&p3=ox9{RPwFDLaGisleIE#2TV-NYb=$dXRt5tr*z#3 zlWELQ?zJ`QGqJcDeZba7s9$6G&eA)nWpDSnizR1@Txz%OJQehi0JCMK9B_@*2Uw_e zA4BF8aULSN|M&To0{MD9pehpGSeWwTmCdS3_l+6@CNK%9mechrJS|vQB^X literal 934 zcmZ9LSyIA45Qh8NDvuJ1giRkjf@h#u0z@%^Bq(@z_4~USO0CpXmif2t>3n}JtmbO0 zw*{-TwPoBdcHp_QC$6ClY{nYez1@MT*{xt`Z_M}UZEp!@VJG;NZMg4IXt*E1C3J2D z_>pU^z_(X)<%j~8!c`v}6`m{Gq1&QXg3df|Yj1qpJEKvOUiCD%ZXKz5q$RX!3AY{Z`OPEu8bW6WzlWndEqaNo zzD_-9LY!~>!aE+y6*=o`epQ%X^SzKtC)VCr6L!P%8GLK6FdO@Tow_q~zc)^>vm@Qf zJe4M(884r?Y#%$Ozp0TcI+Kc~WBYjc=qQYfpmG(nL_toRS2A1BUg@3XulN6IY6 GNc;my{)&wN diff --git a/sample.env.dev b/sample.env.dev index 93d846c..877632b 100644 --- a/sample.env.dev +++ b/sample.env.dev @@ -4,6 +4,6 @@ DB_PASSWORD=demo DB_NAME=demo OPENAI_API_KEY=demo WP_URL='https://www.example.com' -WP_USERNAME='demo' +WP_USER='demo' WP_API_KEY='demo' -reference_style="문장" \ No newline at end of file +WP_POST_STYLE="문장" \ No newline at end of file diff --git a/version b/version new file mode 100644 index 0000000..6c6aa7c --- /dev/null +++ b/version @@ -0,0 +1 @@ +0.1.0 \ No newline at end of file