diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f344765 --- /dev/null +++ b/Dockerfile @@ -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"] \ No newline at end of file diff --git a/INSTRUCTION.md b/INSTRUCTION.md new file mode 100644 index 0000000..3052b59 --- /dev/null +++ b/INSTRUCTION.md @@ -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 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 todoapp:1.0.0 +``` + +## 6. Accessing the Application + +Once the container is running, the application will be available at: + +**URL:** http://localhost:8080 \ No newline at end of file diff --git a/todolist/settings.py b/todolist/settings.py index 3b61725..545f4d5 100644 --- a/todolist/settings.py +++ b/todolist/settings.py @@ -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"