Skip to content
Open

Dev #285

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
33 changes: 33 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
ARG PYTHON_VERSION=3.8

FROM python:${PYTHON_VERSION}-slim AS build

ENV PYTHONUNBUFFERED=1

WORKDIR /build

RUN python -m venv /opt/venv

ENV PATH="/opt/venv/bin:$PATH"

COPY requirements.txt .

RUN pip install --no-cache-dir -r requirements.txt

FROM python:${PYTHON_VERSION}-slim AS run

ENV PYTHONUNBUFFERED=1

WORKDIR /app

COPY --from=build /opt/venv /opt/venv

ENV PATH="/opt/venv/bin:$PATH"

COPY . /app

RUN python ./manage.py migrate

EXPOSE 8080

CMD ["python", "manage.py", "runserver", "0.0.0.0:8080"]
72 changes: 72 additions & 0 deletions INSTRUCTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Todo App - Setup and Execution Guide

This repository contains a containerized Django Todo application. Follow the steps below to set up and run the application.

## 1. Prerequisites

Before you begin, ensure you have Docker installed on your machine:

**Link:** https://www.docker.com/products/docker-desktop/

Verify your installation by running:

```bash
docker --version
```

## 2. Docker Hub Repository

The pre-built image is hosted on Docker Hub:

**Link:** https://hub.docker.com/repository/docker/jijuzo/todoapp

## 3. Building and Running the Container

There are two ways to get your Todo application up and running:

- **Option A (Pull and Run):** Use the pre-built image from Docker Hub if you don't need to make any changes to the source code.
- **Option B (Build and Run):** Clone the repository and build the image locally from the Dockerfile if you want to customize the application or work with the source code.

Select the option that best fits your workflow.

## 4. Option A: Pull and Run

### Pull the image:

```bash
docker pull jijuzo/todoapp:1.0.0
```

### Run the container:

```bash
docker run -d -p 8080:8080 --name <your-container-name> jijuzo/todoapp:1.0.0
```

## 5. Option B: Build and Run

### Clone the repository:

```bash
git clone https://github.com/Jijuzo/devops_todolist.git
cd devops_todolist
git checkout dev
```

### Build the image:

```bash
docker build -t todoapp:1.0.0 .
```

### Run the container:

```bash
docker run -d -p 8080:8080 --name <your-container-name> todoapp:1.0.0
```

## 6. Accessing the Application

Once the container is running, the application will be available at:

**URL:** http://localhost:8080
2 changes: 1 addition & 1 deletion todolist/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []
ALLOWED_HOSTS = ['localhost', '127.0.0.1', '0.0.0.0']

DEFAULT_AUTO_FIELD = "django.db.models.AutoField"

Expand Down
Loading