Skip to content

Containerize Application via Dockerfile#1

Open
hepheir wants to merge 93 commits intodevelopfrom
feature/dockerize
Open

Containerize Application via Dockerfile#1
hepheir wants to merge 93 commits intodevelopfrom
feature/dockerize

Conversation

@hepheir
Copy link
Member

@hepheir hepheir commented Nov 26, 2025

향후 애플리케이션 배포 및 개발환경 재현을 위한 컨테이너화를 수행합니다.

컨테이너 이미지 빌드를 위한 Dockerfile 을 작성했으며,
컨테이너 상태 검사를 위한 /health 엔드포인트 구현 및 Dockerfile 의 HEALTHCHECK 옵션을 사용하도록 구성하였습니다.

개발환경 재현을 위한 Docker Compose 설정도 구성해두었으며, 기본 DB로 PostgreSQL을 사용합니다.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR containerizes a Django REST Framework application by adding a Dockerfile, health check endpoint, and container startup scripts. The implementation enables deployment via Docker containers and provides container health monitoring capabilities.

Key Changes

  • Added Dockerfile with Python 3.9 base image, environment configuration, and health check support
  • Implemented /health/ endpoint for container health monitoring with Swagger documentation
  • Created entrypoint and healthcheck scripts for container lifecycle management

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
Dockerfile Defines container image build with Python environment, dependencies installation, and health check configuration
healthcheck.sh Shell script that curls the health endpoint to verify container status
entrypoint.sh Container startup script that runs migrations and starts Django development server
app/views.py Adds health check view function with HTTP 200 response and Swagger documentation
app/urls.py Registers /health/ URL route for container health checks

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 4 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Dockerfile Outdated
Comment on lines 28 to 29
RUN /app/manage.py migrate --no-input
ENTRYPOINT ["gunicorn", "app.wsgi:application", "--bind", "0.0.0.0:8000"]
Copy link

Copilot AI Nov 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running migrations during the image build (at RUN time) is incorrect. Migrations should be run when the container starts (at runtime), not during the build process, because:

  1. The database may not be available during build time
  2. The same image should be deployable to different environments with different database states
  3. This will cause the build to fail if no database is accessible

Move this to a startup script or use CMD instead. For example:

CMD python manage.py migrate --no-input && gunicorn app.wsgi:application --bind 0.0.0.0:8000

Or create a separate entrypoint script that runs migrations before starting gunicorn.

Suggested change
RUN /app/manage.py migrate --no-input
ENTRYPOINT ["gunicorn", "app.wsgi:application", "--bind", "0.0.0.0:8000"]
CMD python manage.py migrate --no-input && gunicorn app.wsgi:application --bind 0.0.0.0:8000

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

로컬 SQLite DB를 사용하는 동안에만 필요한 커맨드이므로 지금은 유지하고, 추후 DB 컨테이너 분리시에 migrate 명령을 제거하도록 조치하겠습니다.

Copy link
Member Author

@hepheir hepheir Nov 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

85acb0d 커밋에서 마이그레이션 로직을 조건부로 수행하도록 조치하였습니다.

Copy link

Copilot AI commented Nov 27, 2025

@hepheir I've opened a new pull request, #2, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 12 changed files in this pull request and generated 12 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
DEBUG = env.get_bool('DEBUG', default=False)

Copy link

Copilot AI Nov 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default ALLOWED_HOSTS configuration only includes localhost and 127.0.0.1, but in containerized environments, requests may come from different hostnames (e.g., the service name tle-auth-service, or external load balancers). Consider documenting this limitation in the README or adding a note that ALLOWED_HOSTS should be configured via the ALLOWED_HOSTS environment variable for production deployments.

Suggested change
# WARNING: The default ALLOWED_HOSTS is only suitable for local development.
# In production or containerized environments, you MUST set the ALLOWED_HOSTS environment variable
# to include all hostnames and domains that will access this service (e.g., service names, load balancers, external domains).

Copilot uses AI. Check for mistakes.
Comment on lines +40 to +41
if value is not None:
retval = value.strip()
Copy link

Copilot AI Nov 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The environment variable stripping in the get() function could remove intentional whitespace. While stripping is generally desirable for most configuration values, there might be edge cases where leading/trailing whitespace is intentional (e.g., formatted strings). Consider documenting this behavior in the function's docstring to make it explicit that values are stripped.

Copilot uses AI. Check for mistakes.
@hepheir hepheir force-pushed the develop branch 3 times, most recently from f40bf03 to 1b8433a Compare December 4, 2025 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants