Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
5 changes: 5 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .idea/devops_todolist.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
ARG PYTHON_VERSION=3.12-slim
FROM python:${PYTHON_VERSION} AS build
WORKDIR /devops_todolist
ENV PYTHONUNBUFFERED=1
COPY requirements.txt /devops_todolist/
RUN pip install --no-cache-dir -r requirements.txt
COPY . /devops_todolist/

RUN python -c "import sysconfig, shutil, pathlib; \
src=pathlib.Path(sysconfig.get_paths()['purelib']); \
shutil.copytree(src, '/tmp/site-packages', \
dirs_exist_ok=True)"



RUN python manage.py migrate
FROM python:${PYTHON_VERSION} AS run
WORKDIR /devops_todolist
ENV PYTHONUNBUFFERED=1
COPY --from=build /tmp/site-packages /usr/local/lib/python3/site-packages
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 is a great improvement in making the source path generic! However, the destination path is now hardcoded and will not work correctly. The path /usr/local/lib/python3/site-packages is invalid for the python:3.12-slim image, which expects /usr/local/lib/python3.12/site-packages.

To make this truly independent of the Python version, consider copying the packages to a generic location (e.g., /opt/site-packages) and then adding that location to the PYTHONPATH environment variable. This will ensure that Python can find the packages regardless of the specific version used.

COPY --from=build /devops_todolist /devops_todolist
EXPOSE 8080
CMD ["python", "manage.py", "runserver", "0.0.0.0:8080"]
4 changes: 4 additions & 0 deletions INSTRUCTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Repo: https://hub.docker.com/repository/docker/midandnight/todoapp/general
Build: docker build -t midandnight/todoapp:1.0.0 .
Run: docker run -p 8080:8080 midandnight/todoapp:1.0.0
Open: http://localhost:8080
Loading