Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.git
.gitignore
.dockerignore
Dockerfile
File renamed without changes.
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 파이썬 베이스 이미지 사용
FROM python:3.10.14-slim

# 작업 디렉토리 설정
WORKDIR /app

# 필요한 파이썬 패키지 설치
# requirements.txt 파일에 Flask와 기타 의존성이 명시되어 있다고 가정
COPY requirements.txt .
RUN pip install -r requirements.txt

# 현재 디렉토리의 모든 파일을 컨테이너의 작업 디렉토리로 복사
COPY . /app

# Flask 서버 실행
# "--host=0.0.0.0" 옵션은 Docker 컨테이너 외부에서 Flask 앱에 접근할 수 있도록 함
CMD ["flask", "run", "--host=0.0.0.0"]
15 changes: 12 additions & 3 deletions code_red_crawling/app.py → app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from selenium.webdriver.chrome.service import Service as ChromeService
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.by import By
import time
from time import sleep
import jellyfish
import os
import psycopg2
Expand All @@ -22,14 +22,23 @@
scheduler.init_app(app)

def create_connection():
conn = psycopg2.connect(
retry_count = 5
for i in range(retry_count):
try:
conn = psycopg2.connect(
host=os.getenv('DB_HOST'),
dbname=os.getenv('DB_NAME'),
user=os.getenv('DB_USERNAME'),
password=os.getenv('DB_PASSWORD'),
port=os.getenv('DB_PORT')
)
return conn
print("Database connection successful")
return conn
except psycopg2.OperationalError as e:
print(f"Connection failed: {e}")
print("Trying again in 5 seconds...")
sleep(5)
raise Exception("Failed to connect to database after several attempts")
conn = create_connection()


Expand Down
Binary file removed code_red_crawling/requirements.txt
Binary file not shown.
File renamed without changes.
18 changes: 15 additions & 3 deletions code_red_crawling/docker-compose.yml → docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ services:
codered_postgresql:
image: postgis/postgis
restart: always
container_name: postgres
container_name: codered_postgresql
ports:
- "5432:5432"

# 환경 변수 설정

environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
Expand All @@ -18,3 +16,17 @@ services:
- ./data/postgres/:/var/lib/postgresql/data
networks:
- compose-networks
codered_crawling:
image: codered_crawling
restart: always
container_name: codered_crawling
ports:
- "5000:5000"
depends_on:
- codered_postgresql
networks:
- compose-networks

networks:
compose-networks:
driver: bridge
File renamed without changes.
File renamed without changes.
Binary file added requirements.txt
Binary file not shown.
File renamed without changes.