Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
34 changes: 34 additions & 0 deletions DockerFile
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"]
57 changes: 57 additions & 0 deletions INSTRUCTION.md
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
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 currently use a placeholder. Replace https://hub.docker.com/r/<your-dockerhub-username>/todoapp with the actual URL of your Docker Hub repository (a direct link to your todoapp repository is required by the task checklist).


## Build the image

From the project root (`devops_todolist`):

```powershell
docker build -f DockerFile -t 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 build command tags the image as todoapp and later you re-tag it for Docker Hub. Consider adding an example build command that directly tags with the required version (e.g. docker build -f DockerFile -t <your-dockerhub-username>/todoapp:1.0.0 .) to simplify the workflow, or explicitly note that the image will be re-tagged before pushing.

```

## 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
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 example runs todoapp (unqualified). That will fail unless you have a local image named todoapp. Consider replacing this with dimonalek/todoapp:1.0.0 or show a docker tag command to create the todoapp alias locally so users can run the unqualified name.

```

## Access in browser

After the container starts, open:

http://localhost:8080/

API endpoint:

http://localhost:8080/api/
Loading