-
Notifications
You must be signed in to change notification settings - Fork 303
feat: add Dockerfile and instructions #300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 7 commits
0649c84
fc4a942
eac33a7
9caa77e
e95f6af
8860e64
c8ff72d
b282e9c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| name: Build Image | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [ "main" ] | ||
|
|
||
| jobs: | ||
|
|
||
| build: | ||
|
|
||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Build the Docker image | ||
| run: docker build . --tag task:${{ github.actor }} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| ARG PYTHON_VERSION=3.10-slim | ||
|
|
||
| FROM python:${PYTHON_VERSION} AS builder | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| ENV PYTHONDONTWRITEBYTECODE=1 | ||
| ENV PYTHONUNBUFFERED=1 | ||
|
|
||
| COPY requirements.txt . | ||
| RUN pip install --no-cache-dir --user -r requirements.txt | ||
|
|
||
| COPY . . | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The INSTRUCTION.md file is missing instructions on how to access the application via a browser. According to requirements, this file must contain instructions for accessing the app (e.g., http://localhost:8080). |
||
| RUN python manage.py migrate | ||
|
|
||
| FROM python:${PYTHON_VERSION} AS runner | ||
|
|
||
| WORKDIR /app | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Comment on lines
+17
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing browser access instructions. Add
Comment on lines
+17
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing Docker Hub push instructions with 1.0.0 tag. Add a section with |
||
|
|
||
| ENV PYTHONUNBUFFERED=1 | ||
|
|
||
| COPY --from=builder /root/.local /root/.local | ||
| COPY --from=builder /app /app | ||
|
|
||
| ENV PATH=/root/.local/bin:$PATH | ||
|
|
||
| EXPOSE 8080 | ||
|
|
||
| CMD ["python", "manage.py", "runserver", "0.0.0.0:8080"] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # ToDo Application — Docker Instructions | ||
|
|
||
| This document provides complete instructions on how to build, run, and access the ToDo web application using Docker. | ||
|
|
||
| ## Docker Hub Repository | ||
| The official pre-built image can be found on Docker Hub: | ||
| [https://hub.docker.com/r/tigerob/todoapp](https://hub.docker.com/r/tigerob/todoapp) | ||
|
|
||
| ## Local Build Instructions | ||
|
|
||
| To build the Docker image locally, run the following command in the project root directory: | ||
|
|
||
| ```bash | ||
| docker build -t todoapp . | ||
| ``` | ||
| ## How to Run the Container | ||
|
|
||
| ```bash | ||
| docker run -p 8080:8080 todoappdocker build -t todoapp . | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line 19 is malformed — the |
||
| ``` | ||
|
Comment on lines
+16
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing Docker Hub push instructions with the |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,39 +1,47 @@ | ||
| # Django-Todolist | ||
| # Django ToDo list | ||
|
|
||
| Django-Todolist is a todolist web application with the most basic features of most web apps, i.e. accounts/login, API and (somewhat) interactive UI. | ||
| This is a to-do list web application with basic features of most web apps, i.e., accounts/login, API, and interactive UI. To do this task, you will need: | ||
|
|
||
| --- | ||
| CSS | [Skeleton](http://getskeleton.com/) | ||
| JS | [jQuery](https://jquery.com/) | ||
| - CSS | [Skeleton](http://getskeleton.com/) | ||
| - JS | [jQuery](https://jquery.com/) | ||
|
|
||
| ## Explore | ||
| Try it out by installing the requirements. (Works only with python >= 3.8, due to Django 4) | ||
|
|
||
| pip install -r requirements.txt | ||
| Try it out by installing the requirements (the following commands work only with Python 3.8 and higher, due to Django 4): | ||
|
|
||
| ``` | ||
| pip install -r requirements.txt | ||
| ``` | ||
|
|
||
| Create a database schema: | ||
|
|
||
| python manage.py migrate | ||
| ``` | ||
| python manage.py migrate | ||
| ``` | ||
|
|
||
| And then start the server (default: http://localhost:8000) | ||
| And then start the server (default is http://localhost:8000): | ||
|
|
||
| python manage.py runserver | ||
| ``` | ||
| python manage.py runserver | ||
| ``` | ||
|
|
||
| You can now browse the [API](http://localhost:8000/api/) or start on the [landing page](http://localhost:8000/). | ||
|
|
||
| Now you can browse the [API](http://localhost:8000/api/) | ||
| or start on the [landing page](http://localhost:8000/) | ||
| ## Task | ||
|
|
||
| ## Task | ||
| Create a Dockerfile for the TODO app: | ||
| - TODO App should start inside a container without an error | ||
| - Dockerfile should contain the build stage and run stage | ||
| - Add ARG to be used as python base image version in dockerfile | ||
| - Execute db migration as RUN instruction | ||
| - Add ENV variable `ENV PYTHONUNBUFFERED=1`. This is needed for optimisation of python app for docker (writing logs directly to stdout and stderr without buffering in the app process memory | ||
| - `runserver` should be followed by `0.0.0.0:8080` parameter to properly start Django server | ||
| - Build an image and name it todoapp | ||
| - An image should be pushed to your personal docker hub account into a repository named “todoapp”, with a tag 1.0.0 (todoapp:1.0.0) | ||
| - README.md should contain all the instructions on how to build and run the container. | ||
| - README.md should contain instructions on how to access the application via a browser. | ||
| - Create PR with your changes and attach it for validation on a platform | ||
| Create a `Dockerfile` for the ToDo app: | ||
|
|
||
| 1. Fork this repository. | ||
| 1. The ToDo app should start inside a container without an error. | ||
| 1. `Dockerfile` should contain the build stage and run stage. | ||
| 1. Add `ARG` as Python base image version in `Dockerfile`. | ||
| 1. Execute database migration as `RUN` instruction. | ||
| 1. Add the `ENV PYTHONUNBUFFERED=1` variable to optimize the Python app for Docker (writing logs directly to `stdout` and `stderr` without buffering in the app process memory. | ||
| 1. `runserver` should be followed by the `0.0.0.0:8080` parameter to start the Django server properly. | ||
| 1. Build an image and name it `todoapp`. | ||
| 1. The image should be pushed to your personal Docker Hub account into the `todoapp` repository with the `1.0.0` tag (`todoapp:1.0.0`). | ||
| 1. Create the `INSTRUCTION.md` file | ||
| 1. `INSTRUCTION.md` should contain a link to your personal Docker Hub repository win an app image. | ||
| 1. `INSTRUCTION.md` should contain all the instructions for building and running the container. | ||
| 1. `INSTRUCTION.md` should contain instructions on accessing the application via a browser. | ||
| 1. Create PR with your changes and attach it for validation on a platform. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The INSTRUCTION.md file is missing the
docker runcommand to run the container. According to requirements, this file must contain all instructions for building AND running the container.