-
Notifications
You must be signed in to change notification settings - Fork 303
Docker #281
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?
Docker #281
Changes from 1 commit
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,34 @@ | ||
| ARG PYTHON_VERSION=3.11 | ||
|
|
||
| FROM python:${PYTHON_VERSION}-slim AS build | ||
|
|
||
| ENV PYTHONDONTWRITEBYTECODE=1 | ||
| ENV PYTHONUNBUFFERED=1 | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| RUN python -m venv /opt/venv | ||
| ENV PATH="/opt/venv/bin:$PATH" | ||
|
|
||
| COPY requirements.txt . | ||
| RUN pip install --upgrade pip \ | ||
| && pip install --no-cache-dir -r requirements.txt | ||
|
|
||
| COPY . . | ||
| RUN python manage.py migrate | ||
|
|
||
| FROM python:${PYTHON_VERSION}-slim AS run | ||
|
|
||
| ENV PYTHONDONTWRITEBYTECODE=1 | ||
| ENV PYTHONUNBUFFERED=1 | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| COPY --from=build /opt/venv /opt/venv | ||
| ENV PATH="/opt/venv/bin:$PATH" | ||
|
|
||
| COPY --from=build /app /app | ||
|
|
||
| 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,57 @@ | ||
| # Todo App Docker Instructions | ||
|
|
||
| ## Docker Hub Repository | ||
|
|
||
| Replace `<your-dockerhub-username>` with your Docker Hub username: | ||
|
|
||
| https://hub.docker.com/r/<your-dockerhub-username>/todoapp | ||
|
|
||
| ## Build the image | ||
|
|
||
| From the project root (`devops_todolist`): | ||
|
|
||
| ```powershell | ||
| docker build -f DockerFile -t todoapp . | ||
|
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 as |
||
| ``` | ||
|
|
||
| ## Tag and push image to Docker Hub | ||
|
|
||
| 1. Log in to Docker Hub: | ||
|
|
||
| ```powershell | ||
| docker login | ||
| ``` | ||
|
|
||
| 2. Tag the image with the required version: | ||
|
|
||
| ```powershell | ||
| docker tag todoapp <your-dockerhub-username>/todoapp:1.0.0 | ||
| ``` | ||
|
|
||
| 3. Push the image: | ||
|
|
||
| ```powershell | ||
| docker push <your-dockerhub-username>/todoapp:1.0.0 | ||
| ``` | ||
|
|
||
| ## Run the container | ||
|
|
||
| ```powershell | ||
| docker run --rm -p 8080:8080 <your-dockerhub-username>/todoapp:1.0.0 | ||
| ``` | ||
|
|
||
| If you want to run your local image (without pull), use: | ||
|
|
||
| ```powershell | ||
| docker run --rm -p 8080:8080 todoapp | ||
|
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 example runs |
||
| ``` | ||
|
|
||
| ## Access in browser | ||
|
|
||
| After the container starts, open: | ||
|
|
||
| http://localhost:8080/ | ||
|
|
||
| API endpoint: | ||
|
|
||
| http://localhost:8080/api/ | ||
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 instructions currently use a placeholder. Replace
https://hub.docker.com/r/<your-dockerhub-username>/todoappwith the actual URL of your Docker Hub repository (a direct link to yourtodoapprepository is required by the task checklist).