-
Notifications
You must be signed in to change notification settings - Fork 303
Add Dockerfile and INSTRUCTION.md #279
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 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| 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 --from=build /devops_todolist /devops_todolist | ||
| 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,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 |
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.
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-packagesis invalid for thepython:3.12-slimimage, 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 thePYTHONPATHenvironment variable. This will ensure that Python can find the packages regardless of the specific version used.