From 332ce2caa47fa1a0b38012ff1f441ecc5f20dc1e Mon Sep 17 00:00:00 2001 From: 2610361 Date: Tue, 16 Jun 2026 17:43:47 +0900 Subject: [PATCH] =?UTF-8?q?Flask=20=EB=B0=B0=ED=8F=AC=EC=9A=A9=20Dockerfil?= =?UTF-8?q?e=C2=B7.gitignore=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Dockerfile: python:3.12-slim 기반. requirements.txt를 먼저 설치해 레이어 캐시를 활용하고, 비루트(appuser)로 실행. 배포 규격대로 0.0.0.0:8080 포트 노출(EXPOSE 8080). sample/Dockerfile 구조를 파이썬 플라스크용으로 변환. - .gitignore: __pycache__·*.pyc, 가상환경(.venv 등), .env 등 파이썬/환경변수 산출물 제외. --- .gitignore | 26 ++++++++++++++++++++++++++ Dockerfile | 24 ++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 .gitignore create mode 100644 Dockerfile diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..294fd20 --- /dev/null +++ b/.gitignore @@ -0,0 +1,26 @@ +# Python +__pycache__/ +*.py[cod] +*.egg-info/ +.eggs/ +build/ +dist/ + +# 가상환경 +.venv/ +venv/ +env/ + +# 환경변수(자격증명 포함) — 절대 커밋 금지 +.env +.env.* +!.env.example + +# 테스트/캐시 +.pytest_cache/ +.mypy_cache/ +.coverage +htmlcov/ + +# OS / 에디터 +.DS_Store diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..98352d0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +# 로컬(podman)과 Kubero 자동빌드가 공유하는 단일 Dockerfile. +# - 로컬: podman build -t maze-runner . && podman run --rm -p 8080:8080 maze-runner +# - 배포: git push → Kubero가 이 Dockerfile로 빌드/배포 (http://<앱이름>.apps.bokdev.in) +FROM python:3.12-slim + +WORKDIR /app + +# 의존성 레이어 캐시 +COPY requirements.txt ./ +RUN pip install --no-cache-dir -r requirements.txt + +# 앱 소스 +COPY . . + +ENV PYTHONUNBUFFERED=1 \ + PORT=8080 +# 배포 규격: 0.0.0.0 의 8080 포트 +EXPOSE 8080 + +# 비루트 실행 +RUN useradd --create-home --uid 10001 appuser +USER appuser + +CMD ["python", "main.py"]