-
Notifications
You must be signed in to change notification settings - Fork 303
Add Dockerfile and INSTRUCTION.md #282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| ARG PYTHON_VERSION=3.10 | ||
| FROM python:${PYTHON_VERSION} AS base | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| COPY requirements.txt . | ||
|
|
||
| RUN pip install --user --no-cache-dir -r requirements.txt | ||
|
|
||
| FROM python:${PYTHON_VERSION}-slim AS runner | ||
|
|
||
| ENV PYTHONUNBUFFERED=1 | ||
|
|
||
| WORKDIR /app | ||
|
|
||
|
Comment on lines
+14
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The INSTRUCTION.md provides a local build command but does not tag the image as
Comment on lines
+11
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. INSTRUCTION.md is missing instructions to run the container and how to access the application via a browser. Add a |
||
| COPY --from=base /root/.local /root/.local | ||
|
|
||
| COPY . . | ||
|
|
||
| ENV PATH=/root/.local/bin:$PATH | ||
|
|
||
| RUN python manage.py migrate | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Dockerfile includes |
||
|
|
||
| EXPOSE 8080 | ||
|
|
||
| CMD ["python", "manage.py", "runserver", "0.0.0.0:8080"] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| ToDo Application - Docker Instructions | ||
| This project is a Django-based ToDo application containerized using a multi-stage Dockerfile. | ||
|
|
||
| 1. Docker Hub Repository | ||
| The official image for this application is published at: | ||
| Link: https://hub.docker.com/r/Clem97121/todoapp | ||
| Full Image Path: clem97121/todoapp:1.0.0 | ||
|
|
||
| 2. How to Build and Tag the Image | ||
| To build the image and apply the required tag for your personal repository, run the following command from the project root: | ||
|
|
||
| Bash | ||
| docker build -t clem97121/todoapp:1.0.0 . | ||
| Note: Database migrations (python manage.py migrate) are executed as a RUN instruction during the build stage. This assumes the project uses a local SQLite database. | ||
|
|
||
| 3. How to Push the Image to Docker Hub | ||
| To publish the image to your personal Docker Hub account, execute these commands: | ||
|
|
||
| Login to your account: | ||
|
|
||
| Bash | ||
| docker login | ||
| Push the specific tag: | ||
|
|
||
| Bash | ||
| docker push clem97121/todoapp:1.0.0 | ||
| 4. How to Run the Container | ||
| To start the application locally after pulling or building the image, use: | ||
|
|
||
| Bash | ||
| docker run -d -p 8080:8080 --name todoapp clem97121/todoapp:1.0.0 | ||
| 5. How to Access the Application | ||
| Once the container is running, the application is accessible via browser at: | ||
|
|
||
| Main Landing Page: http://localhost:8080/ | ||
|
|
||
| API Documentation: http://localhost:8080/api/ | ||
|
|
||
| 6. Technical Specifications | ||
| Multi-stage build: Implemented to optimize the final image size. | ||
|
|
||
| Python Version: Controlled via ARG PYTHON_VERSION. | ||
|
|
||
| Log Optimization: ENV PYTHONUNBUFFERED=1 is used to ensure real-time logging to stdout/stderr. | ||
|
|
||
| Network: The Django server is configured to run on 0.0.0.0:8080. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: The Docker Hub URL (line 6) uses
Clem97121while the Full Image Path (line 7) usesclem97121. Usernames are effectively case-insensitive on Docker Hub, but please use a consistent casing (prefer lowercase) in the instructions to avoid confusion.