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
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.venv/
.github/
__pycache__/
*.pyc
*.pyo
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, not the template user prostoponchik. Replace with your real account (e.g., yourusername/todoapp).

.travis.yml
.pre-commit-config.yaml
db.sqlite3
README.md
.git/
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
ARG PYTHON_VERSION=3.9

FROM python:${PYTHON_VERSION}-slim AS build

ENV PYTHONUNBUFFERED=1
WORKDIR /app

COPY requirements.txt ./

RUN pip install --no-cache-dir --prefix=/install -r requirements.txt
RUN cp -a /install/. /usr/local/
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 copies installed packages from /install into /usr/local inside the build image, but the final image does not copy /usr/local from the build stage. Either remove this cp and copy the install contents into /usr/local in the final stage, or make the final stage copy /usr/local from build. Right now this step is inconsistent with the later COPY --from=build and is likely redundant or misplaced.


COPY . .

RUN python manage.py migrate
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing python manage.py migrate during image build satisfies the checklist, but it will create/modify a database inside the image (embedding DB state at build-time). If you intend a clean runtime DB or remote DB, consider running migrations at container startup or via an entrypoint instead.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have the required RUN python manage.py migrate here (per task). Note: running migrations at build-time can fail if the database is remote/unavailable or if you expect runtime DB provisioning. If you want more robust runtime behavior, consider moving migrations to container startup (entrypoint) or ensure you rely on SQLite created at build time intentionally.


FROM python:${PYTHON_VERSION}-slim AS run
ENV PYTHONUNBUFFERED=1

WORKDIR /app

COPY --from=build /usr/local /usr/local
COPY --from=build /app /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.

You copy the whole /app from the build stage into the run stage. If migrations create DB files during the build, they will also be copied into the final image. If you do not want build-time DB artifacts in the final image, ensure they are excluded or run migrations at runtime.

EXPOSE 8080

CMD [ "python", "manage.py", "runserver", "0.0.0.0:8080" ]
70 changes: 70 additions & 0 deletions INSTRUCTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
## Todo list application in Docker

This is a to-do list web application with basic features of most web apps, i.e., accounts/login, API, and interactive UI.

Link to the Docker Hub repository with the app image: [prostoponchik/todoapp](https://hub.docker.com/r/prostoponchik/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 file contains a Docker Hub link prostoponchik/todoapp. Ensure this is your personal Docker Hub repository (replace if necessary) since the task requires linking your personal repo with the app image (checklist item #18).

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 Docker Hub link here points to the sample repository prostoponchik/todoapp. The requirements ask for a link to your personal Docker Hub repository. Replace this with your Docker Hub username (for example yourdockerhubuser/todoapp) and ensure the URL matches your actual repo.

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 link still uses the sample username prostoponchik. Replace with your actual Docker Hub username so the link points to your repository.


## Instructions for building and running the container from GitHub repository

1. Clone the repository:

```
git clone https://github.com/ProstoPonchik/devops_todolist
```

2. Navigate to the project directory:

```
cd devops_todolist
```

3. Build the Docker image and tag it for Docker Hub:

```
docker build -t todoapp:1.0.0 -t prostoponchik/todoapp:1.0.0 .
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace prostoponchik with your actual Docker Hub username in the tag command.

```

4. Run the container:

```
docker run -d -p 8080:8080 --name todoapp_container prostoponchik/todoapp:1.0.0
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace prostoponchik with your actual Docker Hub username in the image reference.

```

## Publishing the image to Docker Hub

1. Log in to your Docker Hub account:

```
docker login
```

2. Tag the image for your Docker Hub repository:

```
docker tag todoapp:1.0.0 prostoponchik/todoapp:1.0.0
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 example tag command uses prostoponchik/todoapp:1.0.0. Update this to your Docker Hub username (for example docker tag todoapp:1.0.0 yourdockerhubuser/todoapp:1.0.0) so the pushed image will appear under your account.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace prostoponchik with your actual Docker Hub username in the tag command.

```

3. Push the image to Docker Hub:

```
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace prostoponchik with your actual Docker Hub username in the push command.

docker push prostoponchik/todoapp:1.0.0
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 push command references prostoponchik/todoapp:1.0.0. Update it to push to your personal repo (for example docker push yourdockerhubuser/todoapp:1.0.0).

```


## Instructions for running the container from Docker Hub image

1. Pull the image from Docker Hub:

```
docker pull prostoponchik/todoapp:1.0.0
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 below still points at the sample repository. Update this to docker pull yourdockerhubuser/todoapp:1.0.0 so others can pull the image from your account.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace prostoponchik with your actual Docker Hub username in the pull command.

```

2. Run the container:

```
docker run -d -p 8080:8080 --name todoapp_container prostoponchik/todoapp:1.0.0
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 run-from-hub example uses prostoponchik/todoapp:1.0.0. Change it to use your Docker Hub username (for example docker run -d -p 8080:8080 --name todoapp_container yourdockerhubuser/todoapp:1.0.0).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace prostoponchik with your actual Docker Hub username in the run command.

```

## Accessing the application via a browser

Open your web browser and navigate to `http://localhost:8080/` to access the landing page of the ToDo application. You can also access the API at `http://localhost:8080/api/`.
Loading