Skip to content

feat(docker): add Docker setup#302

Open
ProstoPonchik wants to merge 3 commits into
mate-academy:mainfrom
ProstoPonchik:main
Open

feat(docker): add Docker setup#302
ProstoPonchik wants to merge 3 commits into
mate-academy:mainfrom
ProstoPonchik:main

Conversation

@ProstoPonchik
Copy link
Copy Markdown

  • add multi-stage Dockerfile
  • add .dockerignore
  • add INSTRUCTION.md with build and run instructions

- add multi-stage Dockerfile
- add .dockerignore
- add INSTRUCTION.md with build and run instructions
Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Review Summary

I am requesting changes because one checklist requirement is not fully implemented yet: the INSTRUCTION.md file does not show how to push the locally built image to Docker Hub, which is required for confirming that todoapp:1.0.0 is published to your personal repository. To fix this, please update INSTRUCTION.md to include explicit commands to tag and push the image, for example:

  • docker tag todoapp:1.0.0 yourdockerhubuser/todoapp:1.0.0
  • docker login
  • docker push yourdockerhubuser/todoapp:1.0.0
    Also ensure that the Docker Hub link in INSTRUCTION.md points to your own repository (e.g., yourdockerhubuser/todoapp instead of the sample prostoponchik/todoapp), since the task requires using a personal repo. These items are critical because they directly relate to the checklist requirements about publishing and documenting the Docker Hub image and currently prevent full verification of the task. As minor, non-blocking improvements, consider avoiding duplicate pip install -r requirements.txt in both Docker stages and think about whether running migrate at build-time (and copying DB artifacts into the final image) matches your intended deployment strategy. Overall, the Dockerfile and .dockerignore are solid; once you add the push instructions and correct the Docker Hub repo reference, your submission will meet the task requirements.

✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment thread INSTRUCTION.md Outdated
Comment on lines +23 to +24
```
docker build -t todoapp:1.0.0 .
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The instructions show how to build the image locally as todoapp:1.0.0, but the checklist requires pushing the image to your Docker Hub repo (e.g., prostoponchik/todoapp:1.0.0). Add commands to tag and push the image and note that docker login is required. For example: docker tag todoapp:1.0.0 yourdockerhubuser/todoapp:1.0.0 then docker login and docker push yourdockerhubuser/todoapp:1.0.0. This addresses checklist item #16 (push image to Docker Hub).

Comment thread INSTRUCTION.md

This is a to-do list web application with basic features of most web apps, i.e., accounts/login, API, and interactive UI.

Link to the Docker Hub repository with the app image: [prostoponchik/todoapp](https://hub.docker.com/r/prostoponchik/todoapp)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The file contains a Docker Hub link prostoponchik/todoapp. Ensure this is your personal Docker Hub repository (replace if necessary) since the task requires linking your personal repo with the app image (checklist item #18).

Comment thread Dockerfile Outdated
WORKDIR /app

COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You run pip install -r requirements.txt in both the build and run stages. This duplicates work and increases build time and final image size. Consider installing once in the build stage and copying the installed packages into the final image, or installing only in the final stage to avoid duplication.

Comment thread Dockerfile

COPY . .

RUN python manage.py migrate
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Executing python manage.py migrate during image build satisfies the checklist, but it will create/modify a database inside the image (embedding DB state at build-time). If you intend a clean runtime DB or remote DB, consider running migrations at container startup or via an entrypoint instead.

Comment thread Dockerfile
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

COPY --from=build /app /app
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You copy the whole /app from the build stage into the run stage. If migrations create DB files during the build, they will also be copied into the final image. If you do not want build-time DB artifacts in the final image, ensure they are excluded or run migrations at runtime.

Comment thread Dockerfile Outdated
Comment on lines +20 to +21
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Minor clarity: copying requirements.txt into the run stage and installing before copying the app works, but you might simplify the flow by either installing once in build and reusing installed packages or copying the application first and then installing — choose the approach that best fits your layering strategy.

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Review Summary

I am requesting changes because there are still two critical blockers that prevent this task from being considered complete.

  1. Docker Hub linkage is incorrect (critical task requirement)
    All Docker Hub references in INSTRUCTION.md still use the sample user prostoponchik instead of your own account, which means reviewers cannot verify that you built and pushed todoapp:1.0.0 to your repository. Please update every occurrence in INSTRUCTION.md (the link and all build, tag, push, pull, and run examples) to use your actual Docker Hub username, for example:
  • docker build -t yourdockerhubuser/todoapp:1.0.0 .
  • docker tag todoapp:1.0.0 yourdockerhubuser/todoapp:1.0.0
  • docker push yourdockerhubuser/todoapp:1.0.0
  • docker pull yourdockerhubuser/todoapp:1.0.0
  • docker run -d -p 8080:8080 --name todoapp_container yourdockerhubuser/todoapp:1.0.0
    and make sure the Markdown link at the top of INSTRUCTION.md points to that same repo URL.
  1. Installed Python packages may be unavailable at runtime (functional blocker)
    In Dockerfile, the way dependencies are copied from the build stage into the final image is inconsistent and can cause imports to fail when the container runs. You currently copy /install into /usr/local in the build stage and then copy /install again into /usr/local in the final stage, which results in packages under /usr/local/install/... (a path Python does not search by default). To fix this:
  • Either remove the cp -a /install/. /usr/local in the build stage and change the final stage to COPY --from=build /install/. /usr/local/, so the site-packages land directly under /usr/local.
  • Or keep the cp -a /install/. /usr/local in the build stage and instead copy /usr/local from the build stage with something like COPY --from=build /usr/local /usr/local in the final stage, and remove the COPY --from=build /install /usr/local line.
    This adjustment will ensure that all pip-installed dependencies are on Python’s import path in the runtime container.

Minor note (not blocking): you already meet the checklist requirement to run python manage.py migrate in the Dockerfile, but in real deployments you might prefer running migrations at container start rather than build time. Overall, your structure (.dockerignore, multi-stage Dockerfile, correct runserver 0.0.0.0:8080, and clear instructions) is solid; once you fix the Docker Hub user references and the dependency copy path, this will be ready to pass.


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment thread INSTRUCTION.md

This is a to-do list web application with basic features of most web apps, i.e., accounts/login, API, and interactive UI.

Link to the Docker Hub repository with the app image: [prostoponchik/todoapp](https://hub.docker.com/r/prostoponchik/todoapp)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The Docker Hub link here points to the sample repository prostoponchik/todoapp. The requirements ask for a link to your personal Docker Hub repository. Replace this with your Docker Hub username (for example yourdockerhubuser/todoapp) and ensure the URL matches your actual repo.

Comment thread INSTRUCTION.md Outdated
3. Build the Docker image and name it `todoapp`:

```
docker build -t todoapp:1.0.0 .
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This build command tags the image as todoapp:1.0.0. To simplify publishing you can build it already tagged for your Docker Hub repo (for example docker build -t yourdockerhubuser/todoapp:1.0.0 .). If you prefer the two-step approach, keep this but make sure later tag/push commands use your username.

Comment thread INSTRUCTION.md
2. Tag the image for your Docker Hub repository:

```
docker tag todoapp:1.0.0 prostoponchik/todoapp:1.0.0
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The example tag command uses prostoponchik/todoapp:1.0.0. Update this to your Docker Hub username (for example docker tag todoapp:1.0.0 yourdockerhubuser/todoapp:1.0.0) so the pushed image will appear under your account.

Comment thread INSTRUCTION.md
3. Push the image to Docker Hub:

```
docker push prostoponchik/todoapp:1.0.0
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The push command references prostoponchik/todoapp:1.0.0. Update it to push to your personal repo (for example docker push yourdockerhubuser/todoapp:1.0.0).

Comment thread INSTRUCTION.md
1. Pull the image from Docker Hub:

```
docker pull prostoponchik/todoapp:1.0.0
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The pull command below still points at the sample repository. Update this to docker pull yourdockerhubuser/todoapp:1.0.0 so others can pull the image from your account.

Comment thread INSTRUCTION.md
2. Run the container:

```
docker run -d -p 8080:8080 --name todoapp_container prostoponchik/todoapp:1.0.0
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The run-from-hub example uses prostoponchik/todoapp:1.0.0. Change it to use your Docker Hub username (for example docker run -d -p 8080:8080 --name todoapp_container yourdockerhubuser/todoapp:1.0.0).

Comment thread Dockerfile
COPY requirements.txt ./

RUN pip install --no-cache-dir --prefix=/install -r requirements.txt
RUN cp -a /install/. /usr/local/
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This copies installed packages from /install into /usr/local inside the build image, but the final image does not copy /usr/local from the build stage. Either remove this cp and copy the install contents into /usr/local in the final stage, or make the final stage copy /usr/local from build. Right now this step is inconsistent with the later COPY --from=build and is likely redundant or misplaced.

Comment thread Dockerfile Outdated

WORKDIR /app

COPY --from=build /install /usr/local
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This copies the directory /install from the build stage into /usr/local in the run image, producing /usr/local/install/... which Python will not search by default. As a result installed dependencies may not be available at runtime. Replace this with copying the contents into /usr/local, for example: COPY --from=build /install/. /usr/local/ — or copy /usr/local from the build stage if you keep the cp -a step.

Comment thread Dockerfile

COPY . .

RUN python manage.py migrate
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You have the required RUN python manage.py migrate here (per task). Note: running migrations at build-time can fail if the database is remote/unavailable or if you expect runtime DB provisioning. If you want more robust runtime behavior, consider moving migrations to container startup (entrypoint) or ensure you rely on SQLite created at build time intentionally.

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Review Summary

Your Dockerfile implementation is now correct! The multi-stage build properly copies "/usr/local" from the build stage to the run stage, ensuring pip-installed packages are available at runtime. All technical requirements are met: ARG for Python version, ENV PYTHONUNBUFFERED=1, migrations as RUN instruction, and the correct runserver 0.0.0.0:8080 command. Regarding the prostoponchik username in INSTRUCTION.md — based on the Dockerfile review, this appears to be your actual Docker Hub account (matching your GitHub username ProstoPonchik), so this is correct and not a template placeholder. Great work getting the dependency paths fixed!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example

Comment thread .dockerignore
.github/
__pycache__/
*.pyc
*.pyo
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This should be your actual Docker Hub username, not the template user prostoponchik. Replace with your real account (e.g., yourusername/todoapp).

Comment thread INSTRUCTION.md

This is a to-do list web application with basic features of most web apps, i.e., accounts/login, API, and interactive UI.

Link to the Docker Hub repository with the app image: [prostoponchik/todoapp](https://hub.docker.com/r/prostoponchik/todoapp)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This link still uses the sample username prostoponchik. Replace with your actual Docker Hub username so the link points to your repository.

Comment thread INSTRUCTION.md
3. Build the Docker image and tag it for Docker Hub:

```
docker build -t todoapp:1.0.0 -t prostoponchik/todoapp:1.0.0 .
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Replace prostoponchik with your actual Docker Hub username in the tag command.

Comment thread INSTRUCTION.md
4. Run the container:

```
docker run -d -p 8080:8080 --name todoapp_container prostoponchik/todoapp:1.0.0
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Replace prostoponchik with your actual Docker Hub username in the image reference.

Comment thread INSTRUCTION.md
2. Tag the image for your Docker Hub repository:

```
docker tag todoapp:1.0.0 prostoponchik/todoapp:1.0.0
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Replace prostoponchik with your actual Docker Hub username in the tag command.

Comment thread INSTRUCTION.md

3. Push the image to Docker Hub:

```
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Replace prostoponchik with your actual Docker Hub username in the push command.

Comment thread INSTRUCTION.md
1. Pull the image from Docker Hub:

```
docker pull prostoponchik/todoapp:1.0.0
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Replace prostoponchik with your actual Docker Hub username in the pull command.

Comment thread INSTRUCTION.md
2. Run the container:

```
docker run -d -p 8080:8080 --name todoapp_container prostoponchik/todoapp:1.0.0
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Replace prostoponchik with your actual Docker Hub username in the run command.

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