-
Notifications
You must be signed in to change notification settings - Fork 303
my sollution #283
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?
my sollution #283
Changes from 2 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,23 @@ | ||
| ARG PYTHON_VERSION=3.11 | ||
|
|
||
| #build stage | ||
| FROM python:${PYTHON_кеVERSION}-slim as builder | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| COPY requirements.txt . | ||
| RUN pip install -r requirements.txt | ||
|
|
||
|
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. Consider documenting the caveat that running |
||
| #run stage | ||
| FROM python:${PYTHON_VERSION}-slim | ||
|
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 build command tags the image locally as |
||
|
|
||
| WORKDIR /app | ||
|
|
||
| ENV PYTHONUNBUFFERED=1 | ||
|
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 build command shown earlier uses the |
||
|
|
||
| COPY --from=builder /root/.local /root/.local | ||
|
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. You installed dependencies in the builder stage but then copy |
||
| COPY . . | ||
|
|
||
| EXPOSE 8080 | ||
|
|
||
| CMD [ "python" , "manage.py", "runserver", "0.0.0.0:8080"] | ||
|
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 is missing the required step: |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # ToDo App — Docker Instructions | ||
|
|
||
| ## Docker Hub Repository | ||
|
|
||
|
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 FROM line uses a malformed variable name ( |
||
| https://hub.docker.com/r/ten4i/todoapp | ||
|
|
||
| ## Build the image | ||
|
|
||
| ```bash | ||
|
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. You run |
||
| docker build -t ten4i/todoapp:1.0.0 . | ||
| ``` | ||
|
|
||
| ## Run the container | ||
|
|
||
|
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. This COPY hardcodes the Python 3.11 site-packages path. If you change ARG PYTHON_VERSION the path will no longer match and runtime packages will be missing. Use the build ARG in the path (for example |
||
| ```bash | ||
| docker run -d -p 8080:8080 todoapp:1.0.0 | ||
|
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. You do run 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 |
||
| ``` | ||
|
|
||
|
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. Copying |
||
| ## Access the application | ||
|
|
||
| Open your browser and go to: | ||
|
|
||
| ``` | ||
|
Comment on lines
+19
to
+23
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 task requires executing database migration as a |
||
| http://localhost:8080 | ||
| ``` | ||
|
|
||
| ## Pull and run from Docker Hub | ||
|
|
||
| ```bashas | ||
| docker push ten4i/todoapp:1.0.0 | ||
|
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. Minor: consider documenting |
||
| docker Pull ten4i/todoapp:1.0.0 | ||
| docker run -d -p 8080:8080 ten4i/todoapp:1.0.0 | ||
|
Comment on lines
+29
to
+32
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 "Pull and run from Docker Hub" block contains multiple issues: the code fence is labeled |
||
| ``` | ||
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.
The FROM line has a typo in the build-stage variable:
PYTHON_кеVERSIONcontains invalid characters and doesn't match theARG PYTHON_VERSION. This will make the build fail. UseFROM python:${PYTHON_VERSION}-slim as builder.