Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
34 changes: 34 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# ─── Build Stage ───────────────────────────────────────────────────────────────
ARG PYTHON_VERSION=3.11

FROM python:${PYTHON_VERSION}-slim AS builder

WORKDIR /app
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 should be your actual Docker Hub username (e.g., VadymMoldovan) not a placeholder. The requirement states the link should point to your personal Docker Hub repository.


# Install dependencies into a separate location for clean copying
COPY requirements.txt .
RUN pip install --upgrade pip && \
pip install --no-cache-dir --prefix=/install -r requirements.txt


# ─── Run Stage ─────────────────────────────────────────────────────────────────
ARG PYTHON_VERSION=3.11

FROM python:${PYTHON_VERSION}-slim

ENV PYTHONUNBUFFERED=1

WORKDIR /app

# Copy installed packages from builder
COPY --from=builder /install /usr/local

# Copy project source code
COPY . .

# Run database migrations
RUN python manage.py migrate

EXPOSE 8080

CMD ["python", "manage.py", "runserver", "0.0.0.0:8080"]
78 changes: 78 additions & 0 deletions INSTRUCTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# ToDo App — Docker Instructions

## Docker Hub Repository

Image is available at:
**https://hub.docker.com/r/vadymmoldovan/todoapp**

---

## 1. Build the Docker Image

Clone the repository and build the image:

```bash
git clone https://github.com/VadymMoldovan/devops_todolist.git
cd devops_todolist

docker build -t todoapp:1.0.0 .
```

To build with a custom Python version (optional):

```bash
docker build --build-arg PYTHON_VERSION=3.11 -t todoapp:1.0.0 .
```

---

## 2. Run the Container

```bash
docker run -d -p 8080:8080 --name todoapp todoapp:1.0.0
```

| Flag | Description |
|------|-------------|
| `-d` | Run in detached (background) mode |
| `-p 8080:8080` | Map port 8080 of the container to port 8080 on your machine |
| `--name todoapp` | Name the running container |

---

## 3. Access the Application in a Browser

Open your browser and navigate to:

```
http://localhost:8080
```

---

## 4. Pull the Image from Docker Hub (alternative)

Instead of building locally, you can pull the pre-built image:

```bash
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 pull command uses placeholder 'YOUR_DOCKERHUB_USERNAME' - should contain actual Docker Hub username for the repository.

docker pull vadymmoldovan/todoapp:1.0.0
docker run -d -p 8080:8080 --name todoapp vadymmoldovan/todoapp:1.0.0
```

---

## 5. Push Image to Docker Hub (for maintainers)

```bash
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 tag command uses placeholder 'YOUR_DOCKERHUB_USERNAME' - should contain actual Docker Hub username.

docker tag todoapp:1.0.0 vadymmoldovan/todoapp:1.0.0
docker push vadymmoldovan/todoapp:1.0.0
```

---

## 6. Stop and Remove the Container

```bash
docker stop todoapp
docker rm todoapp
```
Loading