From efe67fc8b80fd74429f3155af4c8a1854a8e7efc Mon Sep 17 00:00:00 2001 From: Petro Kravchenko Date: Wed, 27 May 2026 17:12:02 +0300 Subject: [PATCH 1/2] Solution --- INSTRUCTION.md | 15 +++++++++++++++ dockerfile | 31 +++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 INSTRUCTION.md create mode 100644 dockerfile diff --git a/INSTRUCTION.md b/INSTRUCTION.md new file mode 100644 index 0000000..c6b8a58 --- /dev/null +++ b/INSTRUCTION.md @@ -0,0 +1,15 @@ +# ToDo App Dockerization + +Link to Docker Hub repository: [https://hub.docker.com/repository/docker/petrosfas/todoapp/general] + +## How to build the image locally +To build the Docker image, run the following command in the directory containing the Dockerfile: +`docker build -t todoapp .` + +## How to run the container +To start the container, use the following command: +`docker run -p 8080:8080 todoapp` + +## How to access the application +Once the container is running, open your web browser and navigate to: +`http://localhost:8080` \ No newline at end of file diff --git a/dockerfile b/dockerfile new file mode 100644 index 0000000..caec09a --- /dev/null +++ b/dockerfile @@ -0,0 +1,31 @@ +ARG PYTHON_VERSION=3.12 + +FROM python:${PYTHON_VERSION} AS builder + +WORKDIR /app + +RUN python -m venv /opt/venv + +ENV PATH="/opt/venv/bin:$PATH" + +COPY requirements.txt . +RUN pip install -r requirements.txt + + +FROM python:${PYTHON_VERSION} as RunStage + +ENV PYTHONUNBUFFERED=1 + +WORKDIR /app + +COPY --from=builder /opt/venv /opt/venv + +ENV PATH="/opt/venv/bin:$PATH" + +COPY . . + +RUN python manage.py migrate + +EXPOSE 8080 + +ENTRYPOINT ["python", "manage.py", "runserver", "0.0.0.0:8080"] \ No newline at end of file From dbbe9d1b7c398ec34a3ba6c94114b90fcc1aaf3a Mon Sep 17 00:00:00 2001 From: Petro Kravchenko Date: Thu, 28 May 2026 15:14:02 +0300 Subject: [PATCH 2/2] Fix upper letter in word RunStage and instruction.md --- INSTRUCTION.md | 13 ++++++++++--- dockerfile | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/INSTRUCTION.md b/INSTRUCTION.md index c6b8a58..d6c71f3 100644 --- a/INSTRUCTION.md +++ b/INSTRUCTION.md @@ -1,14 +1,21 @@ # ToDo App Dockerization -Link to Docker Hub repository: [https://hub.docker.com/repository/docker/petrosfas/todoapp/general] +Link to Docker Hub repository: [https://hub.docker.com/r/petrosfas/todoapp](https://hub.docker.com/r/petrosfas/todoapp) ## How to build the image locally To build the Docker image, run the following command in the directory containing the Dockerfile: -`docker build -t todoapp .` +`docker build -t todoapp:1.0.0 .` + +## How to tag and push the image to Docker Hub +First, tag the local image with your Docker Hub username: +`docker tag todoapp:1.0.0 petrosfas/todoapp:1.0.0` + +Then, push the image to the repository: +`docker push petrosfas/todoapp:1.0.0` ## How to run the container To start the container, use the following command: -`docker run -p 8080:8080 todoapp` +`docker run -p 8080:8080 petrosfas/todoapp:1.0.0` ## How to access the application Once the container is running, open your web browser and navigate to: diff --git a/dockerfile b/dockerfile index caec09a..c56d373 100644 --- a/dockerfile +++ b/dockerfile @@ -12,7 +12,7 @@ COPY requirements.txt . RUN pip install -r requirements.txt -FROM python:${PYTHON_VERSION} as RunStage +FROM python:${PYTHON_VERSION} as runstage ENV PYTHONUNBUFFERED=1