diff --git a/INSTRUCTION.md b/INSTRUCTION.md new file mode 100644 index 0000000..d6c71f3 --- /dev/null +++ b/INSTRUCTION.md @@ -0,0 +1,22 @@ +# ToDo App Dockerization + +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: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 petrosfas/todoapp:1.0.0` + +## 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..c56d373 --- /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